VecMath.hpp   VecMath.hpp 
skipping to change at line 74 skipping to change at line 74
//! A 4x4 matrix of floats compatible with openGL. //! A 4x4 matrix of floats compatible with openGL.
typedef Matrix4<float> Mat4f; typedef Matrix4<float> Mat4f;
//! @class Vector2 //! @class Vector2
//! A templatized 2d vector compatible with openGL. //! A templatized 2d vector compatible with openGL.
//! Use Vec2d or Vec2f typdef for vectors of double and float respectively. //! Use Vec2d or Vec2f typdef for vectors of double and float respectively.
template<class T> class Vector2 template<class T> class Vector2
{ {
public: public:
inline Vector2(); inline Vector2();
inline Vector2(const Vector2<T>&);
inline Vector2(T, T); inline Vector2(T, T);
inline Vector2& operator=(const Vector2<T>&);
inline Vector2& operator=(const T*); inline Vector2& operator=(const T*);
inline void set(T, T); inline void set(T, T);
inline bool operator==(const Vector2<T>&) const; inline bool operator==(const Vector2<T>&) const;
inline bool operator!=(const Vector2<T>&) const; inline bool operator!=(const Vector2<T>&) const;
inline const T& operator[](int x) const; inline const T& operator[](int x) const;
inline T& operator[](int); inline T& operator[](int);
inline operator const T*() const; inline operator const T*() const;
inline operator T*(); inline operator T*();
skipping to change at line 119 skipping to change at line 117
T v[2]; T v[2];
}; };
//! @class Vector3 //! @class Vector3
//! A templatized 3d vector compatible with openGL. //! A templatized 3d vector compatible with openGL.
//! Use Vec3d or Vec3f typdef for vectors of double and float respectively. //! Use Vec3d or Vec3f typdef for vectors of double and float respectively.
template<class T> class Vector3 template<class T> class Vector3
{ {
public: public:
inline Vector3(); inline Vector3();
inline Vector3(const Vector3&); //inline Vector3(const Vector3&);
template <class T2> inline Vector3(const Vector3<T2>&); //template <class T2> inline Vector3(const Vector3<T2>&);
inline Vector3(T, T, T); inline Vector3(T, T, T);
inline Vector3(T); inline Vector3(T);
inline Vector3& operator=(const Vector3&); //inline Vector3& operator=(const Vector3&);
inline Vector3& operator=(const T*); inline Vector3& operator=(const T*);
template <class T2> inline Vector3& operator=(const Vector3<T2>&); //template <class T2> inline Vector3& operator=(const Vector3<T2>&);
inline void set(T, T, T); inline void set(T, T, T);
inline bool operator==(const Vector3<T>&) const; inline bool operator==(const Vector3<T>&) const;
inline bool operator!=(const Vector3<T>&) const; inline bool operator!=(const Vector3<T>&) const;
inline T& operator[](int); inline T& operator[](int);
inline const T& operator[](int) const; inline const T& operator[](int) const;
inline operator const T*() const; inline operator const T*() const;
inline operator T*(); inline operator T*();
inline const T* data() const {return v;} inline const T* data() const {return v;}
skipping to change at line 183 skipping to change at line 181
QString toStringLonLat() const {return QString("[") + QString::numbe r(longitude()*180./M_PI, 'g', 12) + "," + QString::number(latitude()*180./M _PI, 'g', 12)+"]";} QString toStringLonLat() const {return QString("[") + QString::numbe r(longitude()*180./M_PI, 'g', 12) + "," + QString::number(latitude()*180./M _PI, 'g', 12)+"]";}
}; };
//! @class Vector4 //! @class Vector4
//! A templatized 4d vector compatible with openGL. //! A templatized 4d vector compatible with openGL.
//! Use Vec4d or Vec4f typdef for vectors of double and float respectively. //! Use Vec4d or Vec4f typdef for vectors of double and float respectively.
template<class T> class Vector4 template<class T> class Vector4
{ {
public: public:
inline Vector4(); inline Vector4();
inline Vector4(const Vector4<T>&);
inline Vector4(const Vector3<T>&); inline Vector4(const Vector3<T>&);
inline Vector4(T, T, T); inline Vector4(T, T, T);
inline Vector4(T, T, T, T); inline Vector4(T, T, T, T);
inline Vector4& operator=(const Vector4<T>&);
inline Vector4& operator=(const Vector3<T>&); inline Vector4& operator=(const Vector3<T>&);
inline Vector4& operator=(const T*); inline Vector4& operator=(const T*);
inline void set(T, T, T, T); inline void set(T, T, T, T);
inline bool operator==(const Vector4<T>&) const; inline bool operator==(const Vector4<T>&) const;
inline bool operator!=(const Vector4<T>&) const; inline bool operator!=(const Vector4<T>&) const;
inline T& operator[](int); inline T& operator[](int);
inline const T& operator[](int) const; inline const T& operator[](int) const;
inline operator T*(); inline operator T*();
skipping to change at line 233 skipping to change at line 229
T v[4]; // The 4 values T v[4]; // The 4 values
}; };
//! @class Matrix4 //! @class Matrix4
//! A templatized column-major 4x4 matrix compatible with openGL. //! A templatized column-major 4x4 matrix compatible with openGL.
//! Use Mat4d or Mat4f typdef for matrices of doubles and floats respective ly. //! Use Mat4d or Mat4f typdef for matrices of doubles and floats respective ly.
template<class T> class Matrix4 template<class T> class Matrix4
{ {
public: public:
Matrix4(); Matrix4();
Matrix4(const Matrix4<T>& m);
Matrix4(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T); Matrix4(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);
Matrix4(const T*); Matrix4(const T*);
Matrix4(const Vector4<T>&, const Vector4<T>&, Matrix4(const Vector4<T>&, const Vector4<T>&,
const Vector4<T>&, const Vector4<T>&); const Vector4<T>&, const Vector4<T>&);
inline Matrix4& operator=(const Matrix4<T>&);
inline Matrix4& operator=(const T*); inline Matrix4& operator=(const T*);
inline void set(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T); inline void set(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);
inline T& operator[](int); inline T& operator[](int);
inline operator T*(); inline operator T*();
inline operator const T*() const; inline operator const T*() const;
inline Matrix4 operator-(const Matrix4<T>&) const; inline Matrix4 operator-(const Matrix4<T>&) const;
inline Matrix4 operator+(const Matrix4<T>&) const; inline Matrix4 operator+(const Matrix4<T>&) const;
inline Matrix4 operator*(const Matrix4<T>&) const; inline Matrix4 operator*(const Matrix4<T>&) const;
skipping to change at line 291 skipping to change at line 285
template<class T> QDataStream& operator>>(QDataStream& in, Vector2<T>& v) { in >> v[0] >> v[1]; return in;} template<class T> QDataStream& operator>>(QDataStream& in, Vector2<T>& v) { in >> v[0] >> v[1]; return in;}
template<class T> QDataStream& operator>>(QDataStream& in, Vector3<T>& v) { in >> v[0] >> v[1] >> v[2]; return in;} template<class T> QDataStream& operator>>(QDataStream& in, Vector3<T>& v) { in >> v[0] >> v[1] >> v[2]; return in;}
template<class T> QDataStream& operator>>(QDataStream& in, Vector4<T>& v) { in >> v[0] >> v[1] >> v[2] >> v[3]; return in;} template<class T> QDataStream& operator>>(QDataStream& in, Vector4<T>& v) { in >> v[0] >> v[1] >> v[2] >> v[3]; return in;}
template<class T> QDataStream& operator>>(QDataStream& in, Matrix4<T>& m) { in >> m[0] >> m[1] >> m[2] >> m[3] >> m[4] >> m[5] >> m[6] >> m[7] >> m[8] >> m[9] >> m[10] >> m[11] >> m[12] >> m[13] >> m[14] >> m[15]; return in;} template<class T> QDataStream& operator>>(QDataStream& in, Matrix4<T>& m) { in >> m[0] >> m[1] >> m[2] >> m[3] >> m[4] >> m[5] >> m[6] >> m[7] >> m[8] >> m[9] >> m[10] >> m[11] >> m[12] >> m[13] >> m[14] >> m[15]; return in;}
////////////////////////// Vector2 class methods ////////////////////////// ///// ////////////////////////// Vector2 class methods ////////////////////////// /////
template<class T> Vector2<T>::Vector2() {} template<class T> Vector2<T>::Vector2() {}
template<class T> Vector2<T>::Vector2(const Vector2<T>& a)
{
v[0]=a.v[0]; v[1]=a.v[1];
}
template<class T> Vector2<T>::Vector2(T x, T y) template<class T> Vector2<T>::Vector2(T x, T y)
{ {
v[0]=x; v[1]=y; v[0]=x; v[1]=y;
} }
template<class T> Vector2<T>& Vector2<T>::operator=(const Vector2<T>& a)
{
v[0]=a.v[0]; v[1]=a.v[1];
return *this;
}
template<class T> Vector2<T>& Vector2<T>::operator=(const T* a) template<class T> Vector2<T>& Vector2<T>::operator=(const T* a)
{ {
v[0]=a[0]; v[1]=a[1]; v[0]=a[0]; v[1]=a[1];
return *this; return *this;
} }
template<class T> void Vector2<T>::set(T x, T y) template<class T> void Vector2<T>::set(T x, T y)
{ {
v[0]=x; v[1]=y; v[0]=x; v[1]=y;
} }
skipping to change at line 427 skipping to change at line 410
// template<class T> // template<class T>
// std::ostream& operator<<(std::ostream &o,const Vector2<T> &v) { // std::ostream& operator<<(std::ostream &o,const Vector2<T> &v) {
// return o << '[' << v[0] << ',' << v[1] << ']'; // return o << '[' << v[0] << ',' << v[1] << ']';
// } // }
////////////////////////// Vector3 class methods ////////////////////////// ///// ////////////////////////// Vector3 class methods ////////////////////////// /////
template<class T> Vector3<T>::Vector3() {} template<class T> Vector3<T>::Vector3() {}
template<class T> Vector3<T>::Vector3(const Vector3& a) //template<class T> Vector3<T>::Vector3(const Vector3& a)
{ //{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; // v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2];
} //}
template<class T> template<class T2> Vector3<T>::Vector3(const Vector3<T2>& //template<class T> template<class T2> Vector3<T>::Vector3(const Vector3<T2
a) >& a)
{ //{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; // v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2];
} //}
template<class T> Vector3<T>::Vector3(T x) template<class T> Vector3<T>::Vector3(T x)
{ {
v[0]=x; v[1]=x; v[2]=x; v[0]=x; v[1]=x; v[2]=x;
} }
template<class T> Vector3<T>::Vector3(T x, T y, T z) template<class T> Vector3<T>::Vector3(T x, T y, T z)
{ {
v[0]=x; v[1]=y; v[2]=z; v[0]=x; v[1]=y; v[2]=z;
} }
template<class T> Vector3<T>& Vector3<T>::operator=(const Vector3& a) //template<class T> Vector3<T>& Vector3<T>::operator=(const Vector3& a)
{ //{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; // v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2];
return *this; // return *this;
} //}
template<class T> template <class T2> Vector3<T>& Vector3<T>::operator=(con //template<class T> template <class T2> Vector3<T>& Vector3<T>::operator=(c
st Vector3<T2>& a) onst Vector3<T2>& a)
{ //{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; // v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2];
return *this; // return *this;
} //}
template<class T> Vector3<T>& Vector3<T>::operator=(const T* a) template<class T> Vector3<T>& Vector3<T>::operator=(const T* a)
{ {
v[0]=a[0]; v[1]=a[1]; v[2]=a[2]; v[0]=a[0]; v[1]=a[1]; v[2]=a[2];
return *this; return *this;
} }
template<class T> void Vector3<T>::set(T x, T y, T z) template<class T> void Vector3<T>::set(T x, T y, T z)
{ {
v[0]=x; v[1]=y; v[2]=z; v[0]=x; v[1]=y; v[2]=z;
skipping to change at line 625 skipping to change at line 608
// Return longitude in rad // Return longitude in rad
template<class T> T Vector3<T>::longitude() const template<class T> T Vector3<T>::longitude() const
{ {
return std::atan2(v[1],v[0]); return std::atan2(v[1],v[0]);
} }
////////////////////////// Vector4 class methods ////////////////////////// ///// ////////////////////////// Vector4 class methods ////////////////////////// /////
template<class T> Vector4<T>::Vector4() {} template<class T> Vector4<T>::Vector4() {}
template<class T> Vector4<T>::Vector4(const Vector4<T>& a)
{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=a.v[3];
}
template<class T> Vector4<T>::Vector4(const Vector3<T>& a) template<class T> Vector4<T>::Vector4(const Vector3<T>& a)
{ {
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=1; v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=1;
} }
template<class T> Vector4<T>::Vector4(T x, T y, T z) template<class T> Vector4<T>::Vector4(T x, T y, T z)
{ {
v[0]=x; v[1]=y; v[2]=z; v[3]=1; v[0]=x; v[1]=y; v[2]=z; v[3]=1;
} }
template<class T> Vector4<T>::Vector4(T x, T y, T z, T a) template<class T> Vector4<T>::Vector4(T x, T y, T z, T a)
{ {
v[0]=x; v[1]=y; v[2]=z; v[3]=a; v[0]=x; v[1]=y; v[2]=z; v[3]=a;
} }
template<class T> Vector4<T>& Vector4<T>::operator=(const Vector4<T>& a)
{
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=a.v[3];
return *this;
}
template<class T> Vector4<T>& Vector4<T>::operator=(const Vector3<T>& a) template<class T> Vector4<T>& Vector4<T>::operator=(const Vector3<T>& a)
{ {
v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=1; v[0]=a.v[0]; v[1]=a.v[1]; v[2]=a.v[2]; v[3]=1;
return *this; return *this;
} }
template<class T> Vector4<T>& Vector4<T>::operator=(const T* a) template<class T> Vector4<T>& Vector4<T>::operator=(const T* a)
{ {
v[0]=a[0]; v[1]=a[1]; v[2]=a[2]; v[3]=a[3]; v[0]=a[0]; v[1]=a[1]; v[2]=a[2]; v[3]=a[3];
return *this; return *this;
skipping to change at line 784 skipping to change at line 756
/* /*
template<class T> template<class T>
std::ostream& operator<<(std::ostream &o,const Vector4<T> &v) { std::ostream& operator<<(std::ostream &o,const Vector4<T> &v) {
return o << '[' << v[0] << ',' << v[1] << ',' << v[2] << ',' << v[3] << ' ]'; return o << '[' << v[0] << ',' << v[1] << ',' << v[2] << ',' << v[3] << ' ]';
}*/ }*/
////////////////////////// Matrix4 class methods ////////////////////////// ///// ////////////////////////// Matrix4 class methods ////////////////////////// /////
template<class T> Matrix4<T>::Matrix4() {} template<class T> Matrix4<T>::Matrix4() {}
template<class T> Matrix4<T>::Matrix4(const Matrix4<T>& m)
{
memcpy(r,m.r,sizeof(T)*16);
}
template<class T> Matrix4<T>::Matrix4(const T* m) template<class T> Matrix4<T>::Matrix4(const T* m)
{ {
memcpy(r,m,sizeof(T)*16); memcpy(r,m,sizeof(T)*16);
} }
template<class T> Matrix4<T>& Matrix4<T>::operator=(const Matrix4<T>& m)
{
memcpy(r,m.r,sizeof(T)*16);
return (*this);
}
template<class T> Matrix4<T>::Matrix4(const Vector4<T>& v0, template<class T> Matrix4<T>::Matrix4(const Vector4<T>& v0,
co nst Vector4<T>& v1, co nst Vector4<T>& v1,
co nst Vector4<T>& v2, co nst Vector4<T>& v2,
co nst Vector4<T>& v3) co nst Vector4<T>& v3)
{ {
r[0] = v0.v[0]; r[0] = v0.v[0];
r[1] = v0.v[1]; r[1] = v0.v[1];
r[2] = v0.v[2]; r[2] = v0.v[2];
r[3] = v0.v[3]; r[3] = v0.v[3];
r[4] = v1.v[0]; r[4] = v1.v[0];
skipping to change at line 868 skipping to change at line 829
template<class T> Matrix4<T> Matrix4<T>::translation(const Vector3<T>& a) template<class T> Matrix4<T> Matrix4<T>::translation(const Vector3<T>& a)
{ {
return Matrix4<T>( 1, 0, 0, 0, return Matrix4<T>( 1, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
a.v[0], a.v[1], a.v[2], 1); a.v[0], a.v[1], a.v[2], 1);
} }
template<class T> Matrix4<T> Matrix4<T>::rotation(const Vector3<T>& axis, T angle) template<class T> Matrix4<T> Matrix4<T>::rotation(const Vector3<T>& axis, T angle)
{ {
Vec3d a(axis); Vector3<T> a(axis);
a.normalize(); a.normalize();
const T c = (T) cos(angle); const T c = (T) cos(angle);
const T s = (T) sin(angle); const T s = (T) sin(angle);
const T d = 1-c; const T d = 1-c;
return Matrix4<T>( a[0]*a[0]*d+c , a[1]*a[0]*d+a[2]*s, a[0] *a[2]*d-a[1]*s, 0, return Matrix4<T>( a[0]*a[0]*d+c , a[1]*a[0]*d+a[2]*s, a[0] *a[2]*d-a[1]*s, 0,
a[0]*a[1]*d-a[2]*s, a[1]*a[1 ]*d+c , a[1]*a[2]*d+a[0]*s, 0, a[0]*a[1]*d-a[2]*s, a[1]*a[1 ]*d+c , a[1]*a[2]*d+a[0]*s, 0,
a[0]*a[2]*d+a[1]*s, a[1]*a[2 ]*d-a[0]*s, a[2]*a[2]*d+c , 0, a[0]*a[2]*d+a[1]*s, a[1]*a[2 ]*d-a[0]*s, a[2]*a[2]*d+c , 0,
0,0,0,1 ); 0,0,0,1 );
} }
skipping to change at line 1213 skipping to change at line 1174
template<class T> inline template<class T> inline
Vector3<T> operator*(T s,const Vector3<T>&v) { Vector3<T> operator*(T s,const Vector3<T>&v) {
return Vector3<T>(s*v[0],s*v[1],s*v[2]); return Vector3<T>(s*v[0],s*v[1],s*v[2]);
} }
template<class T> inline template<class T> inline
Vector4<T> operator*(T s,const Vector4<T>&v) { Vector4<T> operator*(T s,const Vector4<T>&v) {
return Vector4<T>(s*v[0],s*v[1],s*v[2],s*v[3]); return Vector4<T>(s*v[0],s*v[1],s*v[2],s*v[3]);
} }
Q_DECLARE_TYPEINFO(Vec2d, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec2f, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec2i, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec3d, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec3f, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec4d, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec4f, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Vec4i, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Mat4d, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(Mat4f, Q_PRIMITIVE_TYPE);
#endif // _VECMATH_H_ #endif // _VECMATH_H_
 End of changes. 19 change blocks. 
66 lines changed or deleted 38 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/