53 #ifndef ACG_GLMATRIX_HH 54 #define ACG_GLMATRIX_HH 60 #include "Matrix4x4T.hh" 61 #include "../Config/ACGDefines.hh" 78 template <
class Scalar>
90 template <
class OtherScalar>
107 inline GLMatrixT(
const Vec3 &col1,
const Vec3 &col2,
const Vec3 &col3) {
132 memcpy(this->mat_ + 0, col1.
data(),
sizeof(Scalar) * 3);
134 memcpy(this->mat_ + 4, col2.
data(),
sizeof(Scalar) * 3);
136 memcpy(this->mat_ + 8, col3.
data(),
sizeof(Scalar) * 3);
137 for (
int i = 11; i < 15; ++i) this->mat_[i] = 0;
147 template<
typename otherScalar>
152 template<
typename otherScalar>
159 inline void scale( Scalar _x, Scalar _y, Scalar _z,
164 scale(_v[0], _v[1], _v[2], _mult_from);
169 inline void translate( Scalar _x, Scalar _y, Scalar _z,
174 translate(_v[0], _v[1], _v[2], _mult_from);
180 void rotate( Scalar angle, Scalar x, Scalar y, Scalar z,
184 void rotate( Scalar _angle,
const Vec3& _axis,
186 rotate(_angle, _axis[0], _axis[1], _axis[2], _mult_from);
194 rotateXYZ( X, _angle, _mult_from );
200 rotateXYZ( Y, _angle, _mult_from );
206 rotateXYZ( Z, _angle, _mult_from );
215 void lookAt(
const Vec3& eye,
236 Scalar near_plane, Scalar far_plane);
240 Scalar near_plane,Scalar far_plane);
243 void frustum(Scalar left, Scalar right,
244 Scalar bottom, Scalar top,
245 Scalar near_plane, Scalar far_plane);
249 Scalar bottom, Scalar top,
250 Scalar near_plane, Scalar far_plane);
253 void ortho(Scalar left, Scalar right,
254 Scalar bottom, Scalar top,
255 Scalar near_plane, Scalar far_plane);
259 Scalar bottom, Scalar top,
260 Scalar near_plane, Scalar far_plane);
304 template <
typename T>
313 enum Axis { X, Y, Z };
314 void rotateXYZ( Axis _axis, Scalar _angle,
MultiplyFrom _mult_from );
332 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_GLMATRIX_C) 333 #define ACG_GLMATRIX_TEMPLATES 334 #include "GLMatrixT_impl.hh" 337 #endif // ACG_GLMATRIX_HH defined Matrix4x4T & leftMult(const Matrix4x4T< Scalar > &_rhs)
multiply from left: self = _rhs * self
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
Namespace providing different geometric functions concerning angles.
bool isPerspective() const
check if the matrix is a perspective projection matrix
void inverse_perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
GLMatrixT< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignement from other matrix type
GLMatrixT(const Scalar _array[16])
void scale(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
void lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
GLMatrixT(const Vec3 &col1, const Vec3 &col2, const Vec3 &col3)
void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
GLMatrixT< double > GLMatrixd
typedef
Scalar * data()
access to Scalar array
Matrix4x4T & operator-=(const Matrix4x4T< Scalar > &_rhs)
self -= _rhs
GLMatrixT(const Matrix4x4T< OtherScalar > &_rhs)
construct from other matrix type
void translate(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
VectorT< Scalar, 2 > extract_planes_perspective() const
extract near and far clipping planes from a perspective projection matrix
Matrix4x4T operator*(const Matrix4x4T< Scalar > &inst) const
self * _rhs
void rotateZ(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, z-axis)
Matrix4x4T & operator*=(const Matrix4x4T< Scalar > &_rhs)
self *= _rhs
void inverse_ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse orthographic projection matrix
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
4x4 matrix implementing OpenGL commands.
void rotateY(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, y-axis)
Matrix4x4T< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignment from other matrix type
void inverse_frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
void rotateX(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, x-axis)
void rotate(Scalar _angle, const Vec3 &_axis, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
GLMatrixT< float > GLMatrixf
typedef
VectorT< Scalar, 2 > extract_planes_ortho() const
extract near and far clipping planes from an orthographic projection matrix
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
VectorT< Scalar, 2 > extract_planes() const
detect type of projection matrix and extract near and far clipping planes
GLMatrixT()
constructor: uninitialized values
Matrix4x4T & operator+=(const Matrix4x4T< Scalar > &_rhs)
self += _rhs
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
bool isOrtho() const
check if the matrix is an orthographic projection matrix
GLMatrixT(const GLMatrixT< Scalar > &_rhs)
copy constructor
GLMatrixT< Scalar > & operator=(const GLMatrixT< otherScalar > &_rhs)
assignement from other matrix type