59 #ifndef ACG_GLMATRIX_HH
60 #define ACG_GLMATRIX_HH
66 #include "Matrix4x4T.hh"
67 #include "../Config/ACGDefines.hh"
84 template <
class Scalar>
96 template <
class OtherScalar>
108 inline GLMatrixT(
const Vec3 &col1,
const Vec3 &col2,
const Vec3 &col3) {
133 memcpy(this->mat_ + 0, col1.data(),
sizeof(Scalar) * 3);
135 memcpy(this->mat_ + 4, col2.data(),
sizeof(Scalar) * 3);
137 memcpy(this->mat_ + 8, col3.data(),
sizeof(Scalar) * 3);
138 for (
int i = 11; i < 15; ++i) this->mat_[i] = 0;
148 template<
typename otherScalar>
153 template<
typename otherScalar>
160 inline void scale( Scalar _x, Scalar _y, Scalar _z,
165 scale(_v[0], _v[1], _v[2], _mult_from);
170 inline void translate( Scalar _x, Scalar _y, Scalar _z,
175 translate(_v[0], _v[1], _v[2], _mult_from);
181 void rotate( Scalar angle, Scalar x, Scalar y, Scalar z,
185 void rotate( Scalar _angle,
const Vec3& _axis,
187 rotate(_angle, _axis[0], _axis[1], _axis[2], _mult_from);
195 rotateXYZ( X, _angle, _mult_from );
201 rotateXYZ( Y, _angle, _mult_from );
207 rotateXYZ( Z, _angle, _mult_from );
216 void lookAt(
const Vec3& eye,
237 Scalar near_plane, Scalar far_plane);
241 Scalar near_plane,Scalar far_plane);
244 void frustum(Scalar left, Scalar right,
245 Scalar bottom, Scalar top,
246 Scalar near_plane, Scalar far_plane);
250 Scalar bottom, Scalar top,
251 Scalar near_plane, Scalar far_plane);
254 void ortho(Scalar left, Scalar right,
255 Scalar bottom, Scalar top,
256 Scalar near_plane, Scalar far_plane);
260 Scalar bottom, Scalar top,
261 Scalar near_plane, Scalar far_plane);
285 GLMatrixT& operator-= (
const Matrix4x4T<Scalar>& _rhs) {
288 GLMatrixT& operator*= (
const Matrix4x4T<Scalar>& _rhs) {
291 GLMatrixT& leftMult(
const Matrix4x4T<Scalar>& _rhs) {
295 GLMatrixT operator+ (
const Matrix4x4T<Scalar>& _rhs)
const {
296 return GLMatrixT<Scalar>(*this) += _rhs;
298 GLMatrixT operator- (
const Matrix4x4T<Scalar>& _rhs)
const {
299 return GLMatrixT<Scalar>(*this) -= _rhs;
301 GLMatrixT operator*(
const Matrix4x4T<Scalar>& _rhs)
const {
302 return GLMatrixT<Scalar>(*this) *= _rhs;
305 template <
typename T>
314 enum Axis { X, Y, Z };
315 void rotateXYZ( Axis _axis, Scalar _angle,
MultiplyFrom _mult_from );
333 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_GLMATRIX_C)
334 #define ACG_GLMATRIX_TEMPLATES
335 #include "GLMatrixT.cc"
338 #endif // ACG_GLMATRIX_HH defined
Matrix4x4T & operator*=(const Matrix4x4T< Scalar > &_rhs)
self *= _rhs
GLMatrixT< Scalar > & operator=(const GLMatrixT< otherScalar > &_rhs)
assignement from other matrix type
bool isPerspective() const
check if the matrix is a perspective projection matrix
Namespace providing different geometric functions concerning angles.
GLMatrixT< float > GLMatrixf
typedef
void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
VectorT< Scalar, 2 > extract_planes_perspective() const
extract near and far clipping planes from 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(const GLMatrixT< OtherScalar > &_rhs)
construct from other matrix type
bool isOrtho() const
check if the matrix is an orthographic projection matrix
VectorT< Scalar, 2 > extract_planes() const
detect type of projection matrix and extract near and far clipping planes
GLMatrixT(const Scalar _array[16])
void rotateZ(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, z-axis)
GLMatrixT< double > GLMatrixd
typedef
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 translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
VectorT< Scalar, 2 > extract_planes_ortho() const
extract near and far clipping planes from an orthographic projection matrix
GLMatrixT()
constructor: uninitialized values
4x4 matrix implementing OpenGL commands.
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
GLMatrixT(const Vec3 &col1, const Vec3 &col2, const Vec3 &col3)
Matrix4x4T & leftMult(const Matrix4x4T< Scalar > &_rhs)
multiply from left: self = _rhs * self
void translate(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
Matrix4x4T & operator+=(const Matrix4x4T< Scalar > &_rhs)
self += _rhs
void rotateX(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, x-axis)
void scale(const Vec3 &_v, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
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 rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
void rotateY(Scalar _angle, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with a rotation matrix (angle in degree, y-axis)
4x4 matrix implementing OpenGL commands.
Matrix4x4T operator*(const Matrix4x4T< Scalar > &inst) const
self * _rhs
void lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
Matrix4x4T< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignment from other matrix type
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
void rotate(Scalar _angle, const Vec3 &_axis, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
Matrix4x4T & operator-=(const Matrix4x4T< Scalar > &_rhs)
self -= _rhs
GLMatrixT< Scalar > & operator=(const Matrix4x4T< otherScalar > &_rhs)
assignement from other matrix type