VecMath.hpp   VecMath.hpp
skipping to change at line 161 skipping to change at line 161
inline T dot(const Vector3<T>&) const; inline T dot(const Vector3<T>&) const;
inline Vector3 operator^(const Vector3<T>&) const; inline Vector3 operator^(const Vector3<T>&) const;
inline T latitude() const; inline T latitude() const;
inline T longitude() const; inline T longitude() const;
// Distance in radian between two // Distance in radian between two
inline T angle(const Vector3<T>&) const; inline T angle(const Vector3<T>&) const;
inline T angleNormalized(const Vector3<T>&) const;
inline T length() const; inline T length() const;
inline T lengthSquared() const; inline T lengthSquared() const;
inline void normalize(); inline void normalize();
inline void transfo4d(const Mat4d&); inline void transfo4d(const Mat4d&);
inline void transfo4d(const Mat4f&); inline void transfo4d(const Mat4f&);
T v[3]; // The 3 values T v[3]; // The 3 values
QString toString() const {return QString("[%1, %2, %3]").arg(v[0]).a rg(v[1]).arg(v[2]);} QString toString() const {return QString("[%1, %2, %3]").arg(v[0]).a rg(v[1]).arg(v[2]);}
skipping to change at line 550 skipping to change at line 551
} }
// cross product // cross product
template<class T> Vector3<T> Vector3<T>::operator^(const Vector3<T>& b) con st template<class T> Vector3<T> Vector3<T>::operator^(const Vector3<T>& b) con st
{ {
return Vector3<T>(v[1] * b.v[2] - v[2] * b.v[1], return Vector3<T>(v[1] * b.v[2] - v[2] * b.v[1],
v[2] * b.v[0] - v[0] * b.v[2], v[2] * b.v[0] - v[0] * b.v[2],
v[0] * b.v[1] - v[1] * b.v[0]); v[0] * b.v[1] - v[1] * b.v[0]);
} }
// Angle in radian between two vectors // Angle in radian between two vectors
template<class T> T Vector3<T>::angle(const Vector3<T>& b) const template<class T> T Vector3<T>::angle(const Vector3<T>& b) const
{ {
return const T cosAngle = dot(b)/sqrt(lengthSquared()*b.lengthSquared());
return cosAngle>=1 ? 0 : (cosAngle<=-1 ? M_PI : std::acos(cosAngle))
;
}
// Angle in radian between two normalized vectors
template<class T> T Vector3<T>::angleNormalized(const Vector3<T>& b) const
{
const T cosAngle = dot(b);
return cosAngle>=1 ? 0 : (cosAngle<=-1 ? M_PI : std::acos(cosAngle))
;
} }
template<class T> T Vector3<T>::length() const template<class T> T Vector3<T>::length() const
{ {
return (T) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); return (T) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
} }
template<class T> T Vector3<T>::lengthSquared() const template<class T> T Vector3<T>::lengthSquared() const
{ {
return v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; return v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
End of changes. 3 change blocks.
2 lines changed or deleted 13 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/