Browse Source

Use std:: variants for sin(), cos() and sqrt().

They should have overloads for given type, so we're not using doubles
when only float is needed.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
4aa07d3029
  1. 4
      src/Math/Matrix4.h
  2. 4
      src/Math/Vector.h

4
src/Math/Matrix4.h

@ -75,8 +75,8 @@ template<class T> class Matrix4: public Matrix<4, T> {
static Matrix4<T> rotation(T angle, const Vector3<T>& vec) { static Matrix4<T> rotation(T angle, const Vector3<T>& vec) {
Vector3<T> vn = vec.normalized(); Vector3<T> vn = vec.normalized();
T sine = sin(angle); T sine = std::sin(angle);
T cosine = cos(angle); T cosine = std::cos(angle);
T oneMinusCosine = T(1) - cosine; T oneMinusCosine = T(1) - cosine;
T xx = vn.x()*vn.x(); T xx = vn.x()*vn.x();

4
src/Math/Vector.h

@ -90,7 +90,7 @@ template<size_t size, class T> class Vector {
* @todo optimize - Assume the vectors are normalized? * @todo optimize - Assume the vectors are normalized?
*/ */
inline static T angle(const Vector<size, T>& a, const Vector<size, T>& b) { inline static T angle(const Vector<size, T>& a, const Vector<size, T>& b) {
return acos(dot(a, b)/(a.length()*b.length())); return std::acos(dot(a, b)/(a.length()*b.length()));
} }
/** @brief Default constructor */ /** @brief Default constructor */
@ -248,7 +248,7 @@ template<size_t size, class T> class Vector {
* @see lengthSquared() * @see lengthSquared()
*/ */
inline T length() const { inline T length() const {
return sqrt(dot(*this, *this)); return std::sqrt(dot(*this, *this));
} }
/** /**

Loading…
Cancel
Save