Browse Source

Specialization should return also specialized class.

vectorfields
Vladimír Vondruš 16 years ago
parent
commit
6720bc19f0
  1. 2
      src/Magnum.h
  2. 22
      src/Math/Matrix3.h
  3. 29
      src/Math/Matrix4.h
  4. 21
      src/Math/Vector3.h
  5. 21
      src/Math/Vector4.h

2
src/Magnum.h

@ -21,9 +21,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include "Math/Matrix3.h"
#include "Math/Matrix4.h" #include "Math/Matrix4.h"
#include "Math/Vector4.h"
namespace Magnum { namespace Magnum {

22
src/Math/Matrix3.h

@ -20,6 +20,7 @@
*/ */
#include "Matrix.h" #include "Matrix.h"
#include "Vector3.h"
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
@ -34,6 +35,27 @@ template<class T> class Matrix3: public Matrix<T, 3> {
/** @copydoc Matrix::Matrix(const Matrix<T, size>&) */ /** @copydoc Matrix::Matrix(const Matrix<T, size>&) */
inline Matrix3(const Matrix<T, 3>& other): Matrix<T, 3>(other) {} inline Matrix3(const Matrix<T, 3>& other): Matrix<T, 3>(other) {}
/** @copydoc Matrix::operator=() */
inline Matrix3<T>& operator=(const Matrix<T, 3>& other) { return Matrix<T, 3>::operator=(other); }
/** @copydoc Matrix::at(size_t) */
inline Vector3<T> at(size_t col) const { return Matrix<T, 3>::at(col); }
/** @copydoc Matrix::at(size_t, size_t) */
inline T at(size_t row, size_t col) const { return Matrix<T, 3>::at(row, col); }
/** @copydoc Matrix::operator*(const Matrix<T, size>&) */
inline Matrix3<T> operator*(const Matrix<T, 3>& other) const { return Matrix<T, 3>::operator*(other); }
/** @copydoc Matrix::operator*(const Vector<T, size>&) */
inline Vector3<T> operator*(const Vector<T, 3>& other) const { return Matrix<T, 3>::operator*(other); }
/** @copydoc Matrix::transposed() */
inline Matrix3<T> transposed() const { return Matrix<T, 3>::transposed(); }
/** @copydoc Matrix::inverse() */
inline Matrix3<T> inverse() const { return Matrix<T, 3>::inverse(); }
}; };
}} }}

29
src/Math/Matrix4.h

@ -19,9 +19,8 @@
* @brief Class Magnum::Math::Matrix4 * @brief Class Magnum::Math::Matrix4
*/ */
#include "Matrix.h" #include "Matrix3.h"
#include "Vector4.h"
#include "Vector3.h"
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
@ -136,6 +135,30 @@ template<class T> class Matrix4: public Matrix<T, 4> {
/** @copydoc Matrix::Matrix(const Matrix<T, size>&) */ /** @copydoc Matrix::Matrix(const Matrix<T, size>&) */
inline Matrix4(const Matrix<T, 4>& other): Matrix<T, 4>(other) {} inline Matrix4(const Matrix<T, 4>& other): Matrix<T, 4>(other) {}
/** @copydoc Matrix::operator=() */
inline Matrix4<T>& operator=(const Matrix<T, 4>& other) { return Matrix<T, 4>::operator=(other); }
/** @copydoc Matrix::at(size_t) */
inline Vector4<T> at(size_t col) const { return Matrix<T, 4>::at(col); }
/** @copydoc Matrix::at(size_t, size_t) */
inline T at(size_t row, size_t col) const { return Matrix<T, 4>::at(row, col); }
/** @copydoc Matrix::operator*(const Matrix<T, size>&) */
inline Matrix4<T> operator*(const Matrix<T, 4>& other) const { return Matrix<T, 4>::operator*(other); }
/** @copydoc Matrix::operator*(const Vector<T, size>&) */
inline Vector4<T> operator*(const Vector<T, 4>& other) const { return Matrix<T, 4>::operator*(other); }
/** @copydoc Matrix::transposed() */
inline Matrix4<T> transposed() const { return Matrix<T, 4>::transposed(); }
/** @copydoc Matrix::ij() */
inline Matrix3<T> ij(size_t skipRow, size_t skipCol) const { return Matrix<T, 4>::ij(skipRow, skipCol); }
/** @copydoc Matrix::inverse() */
inline Matrix4<T> inverse() const { return Matrix<T, 4>::inverse(); }
}; };
}} }}

21
src/Math/Vector3.h

@ -76,6 +76,27 @@ template<class T> class Vector3: public Vector<T, 3> {
inline void setR(T value) { setX(value); } /**< @brief Set R component */ inline void setR(T value) { setX(value); } /**< @brief Set R component */
inline void setG(T value) { setY(value); } /**< @brief Set G component */ inline void setG(T value) { setY(value); } /**< @brief Set G component */
inline void setB(T value) { setZ(value); } /**< @brief Set B component */ inline void setB(T value) { setZ(value); } /**< @brief Set B component */
/** @copydoc Vector::operator=() */
inline Vector3<T>& operator=(const Vector<T, 3>& other) { return Vector<T, 3>::operator=(other); }
/** @copydoc Vector::operator*(T) */
inline Vector3<T> operator*(T number) const { return Vector<T, 3>::operator*(number); }
/** @copydoc Vector::operator/() */
inline Vector3<T> operator/(T number) const { return Vector<T, 3>::operator/(number); }
/** @copydoc Vector::operator+() */
inline Vector3<T> operator+(const Vector<T, 3>& other) const { return Vector<T, 3>::operator+(other); }
/** @copydoc Vector::operator-(const Vector<T, size>&) */
inline Vector3<T> operator-(const Vector<T, 3>& other) const { return Vector<T, 3>::operator-(other); }
/** @copydoc Vector::operator-() */
inline Vector3<T> operator-() const { return Vector<T, 3>::operator-(); }
/** @copydoc Vector::normalized() */
inline Vector3<T> normalized() const { return Vector<T, 3>::normalized(); }
}; };
}} }}

21
src/Math/Vector4.h

@ -83,6 +83,27 @@ template<class T> class Vector4: public Vector<T, 4> {
* @return First three components of the vector * @return First three components of the vector
*/ */
inline Vector3<T> rgb() const { return xyz(); } inline Vector3<T> rgb() const { return xyz(); }
/** @copydoc Vector::operator=() */
inline Vector4<T>& operator=(const Vector<T, 4>& other) { return Vector<T, 4>::operator=(other); }
/** @copydoc Vector::operator*(T) */
inline Vector4<T> operator*(T number) const { return Vector<T, 4>::operator*(number); }
/** @copydoc Vector::operator/() */
inline Vector4<T> operator/(T number) const { return Vector<T, 4>::operator/(number); }
/** @copydoc Vector::operator+() */
inline Vector4<T> operator+(const Vector<T, 4>& other) const { return Vector<T, 4>::operator+(other); }
/** @copydoc Vector::operator-(const Vector<T, size>&) */
inline Vector4<T> operator-(const Vector<T, 4>& other) const { return Vector<T, 4>::operator-(other); }
/** @copydoc Vector::operator-() */
inline Vector4<T> operator-() const { return Vector<T, 4>::operator-(); }
/** @copydoc Vector::normalized() */
inline Vector4<T> normalized() const { return Vector<T, 4>::normalized(); }
}; };
}} }}

Loading…
Cancel
Save