Minor changes to math module

-Fixed missing Set method: "X::Set(const X&)"
-Removed operator String


Former-commit-id: 690f161704ed85fc57a62b812af7933e390572b5
This commit is contained in:
Lynix 2013-02-16 19:21:14 +01:00
parent 3a4fb198e8
commit cdf632ac96
16 changed files with 48 additions and 72 deletions

View File

@ -43,14 +43,13 @@ class NzCube
NzCube& Set(T X, T Y, T Z, T Width, T Height, T Depth);
NzCube& Set(const T cube[6]);
NzCube& Set(const NzCube& cube);
NzCube& Set(const NzRect<T>& rect);
NzCube& Set(const NzVector3<T>& vec1, const NzVector3<T>& vec2);
template<typename U> NzCube& Set(const NzCube<U>& cube);
NzString ToString() const;
operator NzString() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;

View File

@ -187,6 +187,14 @@ NzCube<T>& NzCube<T>::Set(const T cube[6])
return *this;
}
template<typename T>
NzCube<T>& NzCube<T>::Set(const NzCube& cube)
{
std::memcpy(this, &cube, sizeof(NzCube));
return *this;
}
template<typename T>
NzCube<T>& NzCube<T>::Set(const NzRect<T>& rect)
{
@ -235,12 +243,6 @@ NzString NzCube<T>::ToString() const
return ss << "Cube(" << x << ", " << y << ", " << z << ", " << width << ", " << height << ", " << depth << ')';
}
template<typename T>
NzCube<T>::operator NzString() const
{
return ToString();
}
template<typename T>
T& NzCube<T>::operator[](unsigned int i)
{

View File

@ -38,8 +38,6 @@ template<typename T> class NzEulerAngles
NzQuaternion<T> ToQuaternion() const;
NzString ToString() const;
operator NzString() const;
NzEulerAngles operator+(const NzEulerAngles& angles) const;
NzEulerAngles operator-(const NzEulerAngles& angles) const;
/*NzEulerAngles operator*(const NzEulerAngles& angles) const;

View File

@ -69,9 +69,7 @@ void NzEulerAngles<T>::Set(const T angles[3])
template<typename T>
void NzEulerAngles<T>::Set(const NzEulerAngles& angles)
{
pitch = angles.pitch;
yaw = angles.yaw;
roll = angles.roll;
std::memcpy(this, &angles, sizeof(NzEulerAngles));
}
template<typename T>
@ -107,12 +105,6 @@ NzString NzEulerAngles<T>::ToString() const
return ss << "EulerAngles(" << pitch << ", " << yaw << ", " << roll << ')';
}
template<typename T>
NzEulerAngles<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzEulerAngles<T> NzEulerAngles<T>::operator+(const NzEulerAngles& angles) const
{

View File

@ -84,8 +84,6 @@ class NzMatrix4
NzMatrix4& Transpose();
operator NzString() const;
operator T*();
operator const T*() const;

View File

@ -626,7 +626,7 @@ NzMatrix4<T>& NzMatrix4<T>::Set(const T matrix[16])
template<typename T>
NzMatrix4<T>& NzMatrix4<T>::Set(const NzMatrix4& matrix)
{
std::memcpy(&m11, &matrix.m11, 16*sizeof(T));
std::memcpy(this, &matrix, sizeof(NzMatrix4));
return *this;
}
@ -741,12 +741,6 @@ NzMatrix4<T>& NzMatrix4<T>::Transpose()
return *this;
}
template<typename T>
NzMatrix4<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzMatrix4<T>::operator T*()
{

View File

@ -57,8 +57,6 @@ template<typename T> class NzQuaternion
//NzMatrix3<T> ToRotationMatrix() const;
NzString ToString() const;
operator NzString() const;
NzQuaternion& operator=(const NzQuaternion& quat);
NzQuaternion operator+(const NzQuaternion& quat) const;

View File

@ -221,10 +221,7 @@ NzQuaternion<T>& NzQuaternion<T>::Set(const NzQuaternion<U>& quat)
template<typename T>
NzQuaternion<T>& NzQuaternion<T>::Set(const NzQuaternion& quat)
{
w = quat.w;
x = quat.x;
y = quat.y;
z = quat.z;
std::memcpy(this, &quat, sizeof(NzQuaternion));
return *this;
}
@ -259,12 +256,6 @@ NzString NzQuaternion<T>::ToString() const
return ss << "Quaternion(" << w << " | " << x << ", " << y << ", " << z << ')';
}
template<typename T>
NzQuaternion<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzQuaternion<T>& NzQuaternion<T>::operator=(const NzQuaternion& quat)
{

View File

@ -41,13 +41,12 @@ class NzRect
NzRect& Set(T X, T Y, T Width, T Height);
NzRect& Set(const T rect[4]);
NzRect& Set(const NzRect<T>& rect);
NzRect& Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2);
template<typename U> NzRect& Set(const NzRect<U>& rect);
NzString ToString() const;
operator NzString() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;

View File

@ -164,6 +164,14 @@ NzRect<T>& NzRect<T>::Set(const T rect[4])
return *this;
}
template<typename T>
NzRect<T>& NzRect<T>::Set(const NzRect<T>& rect)
{
std::memcpy(this, &rect, sizeof(NzRect));
return *this;
}
template<typename T>
NzRect<T>& NzRect<T>::Set(const NzVector2<T>& vec1, const NzVector2<T>& vec2)
{
@ -195,12 +203,6 @@ NzString NzRect<T>::ToString() const
return ss << "Rect(" << x << ", " << y << ", " << width << ", " << height << ')';
}
template<typename T>
NzRect<T>::operator NzString() const
{
return ToString();
}
template<typename T>
T& NzRect<T>::operator[](unsigned int i)
{

View File

@ -45,6 +45,7 @@ class NzVector2
NzVector2& Set(T X, T Y);
NzVector2& Set(T scale);
NzVector2& Set(const T vec[2]);
NzVector2& Set(const NzVector2& vec);
template<typename U> NzVector2& Set(const NzVector2<U>& vec);
T SquaredDistance(const NzVector2& vec) const;
@ -52,8 +53,6 @@ class NzVector2
NzString ToString() const;
operator NzString() const;
operator T*();
operator const T*() const;

View File

@ -177,6 +177,14 @@ NzVector2<T>& NzVector2<T>::Set(const T vec[2])
return *this;
}
template<typename T>
NzVector2<T>& NzVector2<T>::Set(const NzVector2& vec)
{
std::memcpy(this, &vec, sizeof(NzVector2));
return *this;
}
template<typename T>
template<typename U>
NzVector2<T>& NzVector2<T>::Set(const NzVector2<U>& vec)
@ -207,12 +215,6 @@ NzString NzVector2<T>::ToString() const
return ss << "Vector2(" << x << ", " << y << ')';
}
template<typename T>
NzVector2<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzVector2<T>::operator T*()
{

View File

@ -53,6 +53,7 @@ template<typename T> class NzVector3
NzVector3& Set(T scale);
NzVector3& Set(const T vec[3]);
NzVector3& Set(const NzVector2<T>& vec, T Z = 0.0);
NzVector3& Set(const NzVector3<T>& vec);
template<typename U> NzVector3& Set(const NzVector3<U>& vec);
T SquaredDistance(const NzVector3& vec) const;
@ -60,8 +61,6 @@ template<typename T> class NzVector3
NzString ToString() const;
operator NzString() const;
operator T*();
operator const T*() const;

View File

@ -232,6 +232,14 @@ NzVector3<T>& NzVector3<T>::Set(const NzVector2<T>& vec, T Z)
return *this;
}
template<typename T>
NzVector3<T>& NzVector3<T>::Set(const NzVector3& vec)
{
std::memcpy(this, &vec, sizeof(NzVector3));
return *this;
}
template<typename T>
template<typename U>
NzVector3<T>& NzVector3<T>::Set(const NzVector3<U>& vec)
@ -263,12 +271,6 @@ NzString NzVector3<T>::ToString() const
return ss << "Vector3(" << x << ", " << y << ", " << z <<')';
}
template<typename T>
NzVector3<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzVector3<T>::operator T*()
{

View File

@ -40,12 +40,11 @@ template<typename T> class NzVector4
NzVector4& Set(T scale);
NzVector4& Set(const T vec[4]);
NzVector4& Set(const NzVector3<T>& vec, T W = 1.0);
NzVector4& Set(const NzVector4<T>& vec);
template<typename U> NzVector4& Set(const NzVector4<U>& vec);
NzString ToString() const;
operator NzString() const;
operator T*();
operator const T*() const;

View File

@ -184,6 +184,14 @@ NzVector4<T>& NzVector4<T>::Set(const NzVector3<T>& vec, T W)
return *this;
}
template<typename T>
NzVector4<T>& NzVector4<T>::Set(const NzVector4& vec)
{
std::memcpy(this, &vec, sizeof(NzVector4));
return *this;
}
template<typename T>
template<typename U>
NzVector4<T>& NzVector4<T>::Set(const NzVector4<U>& vec)
@ -204,12 +212,6 @@ NzString NzVector4<T>::ToString() const
return ss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ')';
}
template<typename T>
NzVector4<T>::operator NzString() const
{
return ToString();
}
template<typename T>
NzVector4<T>::operator T*()
{