CUGL
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
cugl::Mat4 Class Reference

#include <CUMat4.h>

Public Member Functions

 Mat4 ()
 
 Mat4 (float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
 
 Mat4 (const float *mat)
 
 Mat4 (const Mat4 &copy)
 
 Mat4 (const Quaternion &rotation)
 
 ~Mat4 ()
 
Mat4operator= (const Mat4 &mat)
 
Mat4operator= (const float *array)
 
Mat4operator= (const Quaternion &quat)
 
Mat4set (float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
 
Mat4set (const float *mat)
 
Mat4set (const Quaternion &quat)
 
Mat4set (const Mat4 &mat)
 
Mat4setIdentity ()
 
Mat4setZero ()
 
Mat4add (float scalar)
 
Mat4add (const Mat4 &mat)
 
Mat4subtract (float scalar)
 
Mat4subtract (const Mat4 &mat)
 
Mat4multiply (float scalar)
 
Mat4multiply (const Mat4 &mat)
 
Mat4negate ()
 
Mat4 getNegation () const
 
Mat4invert ()
 
Mat4 getInverse () const
 
Mat4transpose ()
 
Mat4 getTranspose () const
 
Mat4operator+= (const Mat4 &mat)
 
Mat4operator-= (const Mat4 &mat)
 
Mat4operator*= (const Mat4 &mat)
 
Mat4operator*= (float scalar)
 
const Mat4 operator+ (const Mat4 &mat) const
 
const Mat4 operator- (const Mat4 &mat) const
 
const Mat4 operator- () const
 
const Mat4 operator* (const Mat4 &mat) const
 
const Mat4 operator* (float scalar) const
 
bool isExactly (const Mat4 &mat) const
 
bool equals (const Mat4 &mat, float variance=CU_MATH_EPSILON) const
 
bool operator== (const Mat4 &mat) const
 
bool operator!= (const Mat4 &mat) const
 
bool isIdentity (float variance=0.0f) const
 
bool isInvertible (float variance=CU_MATH_EPSILON) const
 
bool isOrthogonal (float variance=CU_MATH_EPSILON) const
 
float getDeterminant () const
 
Vec3 getScale () const
 
Quaternion getRotation () const
 
Vec3 getTranslation () const
 
Vec3 getUpVector () const
 
Vec3 getDownVector () const
 
Vec3 getLeftVector () const
 
Vec3 getRightVector () const
 
Vec3 getForwardVector () const
 
Vec3 getBackVector () const
 
Vec2 transform (const Vec2 &point) const
 
Rect transform (const Rect &rect) const
 
Vec2 transformVector (const Vec2 &vec) const
 
Vec3 transform (const Vec3 &point) const
 
Vec3 transformVector (const Vec3 &vec) const
 
Vec4 transform (const Vec4 &vec) const
 
Mat4rotate (const Quaternion &q)
 
Mat4rotate (const Vec3 &axis, float angle)
 
Mat4rotateX (float angle)
 
Mat4rotateY (float angle)
 
Mat4rotateZ (float angle)
 
Mat4scale (float value)
 
Mat4scale (const Vec3 &s)
 
Mat4scale (float sx, float sy, float sz)
 
Mat4translate (const Vec3 &t)
 
Mat4translate (float tx, float ty, float tz)
 
std::string toString (bool verbose=false) const
 
 operator std::string () const
 
 operator Affine2 () const
 
 Mat4 (const Affine2 &aff)
 
Mat4operator= (const Affine2 &aff)
 
Mat4set (const Affine2 &aff)
 

Static Public Member Functions

static Mat4 createLookAt (const Vec3 &eye, const Vec3 &target, const Vec3 &up)
 
static Mat4createLookAt (const Vec3 &eye, const Vec3 &target, const Vec3 &up, Mat4 *dst)
 
static Mat4 createLookAt (float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
 
static Mat4createLookAt (float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ, Mat4 *dst)
 
static Mat4 createPerspective (float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
 
static Mat4createPerspective (float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane, Mat4 *dst)
 
static Mat4 createOrthographic (float width, float height, float zNearPlane, float zFarPlane)
 
static Mat4createOrthographic (float width, float height, float zNearPlane, float zFarPlane, Mat4 *dst)
 
static Mat4 createOrthographicOffCenter (float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
 
static Mat4createOrthographicOffCenter (float left, float right, float bottom, float top, float zNearPlane, float zFarPlane, Mat4 *dst)
 
static Mat4 createScale (float scale)
 
static Mat4createScale (float scale, Mat4 *dst)
 
static Mat4 createScale (float sx, float sy, float sz)
 
static Mat4createScale (float sx, float sy, float sz, Mat4 *dst)
 
static Mat4 createScale (const Vec3 &scale)
 
static Mat4createScale (const Vec3 &scale, Mat4 *dst)
 
static Mat4 createRotation (const Quaternion &quat)
 
static Mat4createRotation (const Quaternion &quat, Mat4 *dst)
 
static Mat4 createRotation (const Vec3 &axis, float angle)
 
static Mat4createRotation (const Vec3 &axis, float angle, Mat4 *dst)
 
static Mat4 createRotationX (float angle)
 
static Mat4createRotationX (float angle, Mat4 *dst)
 
static Mat4 createRotationY (float angle)
 
static Mat4createRotationY (float angle, Mat4 *dst)
 
static Mat4 createRotationZ (float angle)
 
static Mat4createRotationZ (float angle, Mat4 *dst)
 
static Mat4 createTranslation (const Vec3 &trans)
 
static Mat4createTranslation (const Vec3 &trans, Mat4 *dst)
 
static Mat4 createTranslation (float tx, float ty, float tz)
 
static Mat4createTranslation (float tx, float ty, float tz, Mat4 *dst)
 
static Mat4add (const Mat4 &mat, float scalar, Mat4 *dst)
 
static Mat4add (const Mat4 &m1, const Mat4 &m2, Mat4 *dst)
 
static Mat4subtract (const Mat4 &mat, float scalar, Mat4 *dst)
 
static Mat4subtract (const Mat4 &m1, const Mat4 &m2, Mat4 *dst)
 
static Mat4multiply (const Mat4 &mat, float scalar, Mat4 *dst)
 
static Mat4multiply (const Mat4 &m1, const Mat4 &m2, Mat4 *dst)
 
static Mat4negate (const Mat4 &m1, Mat4 *dst)
 
static Mat4invert (const Mat4 &m1, Mat4 *dst)
 
static Mat4transpose (const Mat4 &m1, Mat4 *dst)
 
static Vec2transform (const Mat4 &mat, const Vec2 &point, Vec2 *dst)
 
static Recttransform (const Mat4 &mat, const Rect &rect, Rect *dst)
 
static Vec2transformVector (const Mat4 &mat, const Vec2 &vec, Vec2 *dst)
 
static Vec3transform (const Mat4 &mat, const Vec3 &point, Vec3 *dst)
 
static Vec3transformVector (const Mat4 &mat, const Vec3 &vec, Vec3 *dst)
 
static Vec4transform (const Mat4 &mat, const Vec4 &vec, Vec4 *dst)
 
static Mat4rotate (const Mat4 &mat, const Quaternion &quat, Mat4 *dst)
 
static Mat4rotate (const Mat4 &mat, const Vec3 &axis, float angle, Mat4 *dst)
 
static Mat4rotateX (const Mat4 &mat, float angle, Mat4 *dst)
 
static Mat4rotateY (const Mat4 &mat, float angle, Mat4 *dst)
 
static Mat4rotateZ (const Mat4 &mat, float angle, Mat4 *dst)
 
static Mat4scale (const Mat4 &mat, float value, Mat4 *dst)
 
static Mat4scale (const Mat4 &mat, const Vec3 &s, Mat4 *dst)
 
static Mat4scale (const Mat4 &mat, float sx, float sy, float sz, Mat4 *dst)
 
static Mat4translate (const Mat4 &mat, const Vec3 &t, Mat4 *dst)
 
static Mat4translate (const Mat4 &mat, float tx, float ty, float tz, Mat4 *dst)
 
static bool decompose (const Mat4 &mat, Vec3 *scale, Quaternion *rot, Vec3 *trans)
 

Public Attributes

float m [16]
 

Static Public Attributes

static const Mat4 ZERO
 
static const Mat4 ONE
 
static const Mat4 IDENTITY
 

Detailed Description

This class defines a 4 x 4 floating point matrix representing a 3D transformation.

Vectors are treated as columns, resulting in a matrix that is represented as follows, where x, y and z are the translation components of the matrix:

1  0  0  x
0  1  0  y
0  0  1  z
0  0  0  1

This matrix class is directly compatible with OpenGL since its elements are laid out in memory exactly as they are expected by OpenGL.

The matrix uses column-major format such that array indices increase down column first. However, this is only a data representation format, and it should not have any affect on issues such as multiplication order.

With that said, the convention in OpenGL (and respected by this class) is that transforms are applied by multiplying a vector on the right. For example, suppose we have a translation matrix T and a rotation matrix R. To first rotate an object around the origin and then translate it, you would multiply the two matrices as RT, with T on the right.

Constructor & Destructor Documentation

cugl::Mat4::Mat4 ( )

Creates the identity matrix.

1  0  0  0
0  1  0  0
0  0  1  0
0  0  0  1
cugl::Mat4::Mat4 ( float  m11,
float  m12,
float  m13,
float  m14,
float  m21,
float  m22,
float  m23,
float  m24,
float  m31,
float  m32,
float  m33,
float  m34,
float  m41,
float  m42,
float  m43,
float  m44 
)

Constructs a matrix initialized to the specified values.

Parameters
m11The first element of the first row.
m12The second element of the first row.
m13The third element of the first row.
m14The fourth element of the first row.
m21The first element of the second row.
m22The second element of the second row.
m23The third element of the second row.
m24The fourth element of the second row.
m31The first element of the third row.
m32The second element of the third row.
m33The third element of the third row.
m34The fourth element of the third row.
m41The first element of the fourth row.
m42The second element of the fourth row.
m43The third element of the fourth row.
m44The fourth element of the fourth row.
cugl::Mat4::Mat4 ( const float *  mat)

Creates a matrix initialized to the specified column-major array.

The passed-in array is in column-major order, so the memory layout of the array is as follows:

0   4   8   12
1   5   9   13
2   6   10  14
3   7   11  15
Parameters
matAn array containing 16 elements in column-major order.
cugl::Mat4::Mat4 ( const Mat4 copy)

Constructs a new matrix that is the copy of the specified one.

Parameters
copyThe matrix to copy.
cugl::Mat4::Mat4 ( const Quaternion rotation)
inline

Constructs a new matrix that is specified by the given quaternion.

Parameters
rotationThe quaternion specifying a rotation.
cugl::Mat4::~Mat4 ( )
inline

Destroys this matrix, releasing all resources.

cugl::Mat4::Mat4 ( const Affine2 aff)
explicit

Creates a matrix from the given affine transform.

The z values are set to the identity.

Parameters
affThe transform to convert

Member Function Documentation

static Mat4* cugl::Mat4::add ( const Mat4 mat,
float  scalar,
Mat4 dst 
)
static

Adds a scalar to each component of mat and stores the result in dst.

Parameters
matThe matrix to add to.
scalarThe scalar value to add.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::add ( const Mat4 m1,
const Mat4 m2,
Mat4 dst 
)
static

Adds the specified matrices and stores the result in dst.

Parameters
m1The first matrix.
m2The second matrix.
dstThe destination matrix to add to.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::add ( float  scalar)
inline

Adds a scalar value to each component of this matrix.

Parameters
scalarThe scalar to add.
Returns
A reference to the Mat4 after addition.
Mat4& cugl::Mat4::add ( const Mat4 mat)
inline

Adds the specified matrix to this matrix.

Parameters
matThe matrix to add.
Returns
A reference to the Mat4 after addition.
static Mat4 cugl::Mat4::createLookAt ( const Vec3 eye,
const Vec3 target,
const Vec3 up 
)
inlinestatic

Creates a view matrix based on the specified input vectors.

Parameters
eyeThe eye position.
targetThe target's center position.
upThe up vector.
Returns
a view matrix based on the specified input vectors.
static Mat4* cugl::Mat4::createLookAt ( const Vec3 eye,
const Vec3 target,
const Vec3 up,
Mat4 dst 
)
static

Creates a view matrix based on the specified input vectors, putting it in dst.

Parameters
eyeThe eye position.
targetThe target's center position.
upThe up vector.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createLookAt ( float  eyeX,
float  eyeY,
float  eyeZ,
float  targetX,
float  targetY,
float  targetZ,
float  upX,
float  upY,
float  upZ 
)
inlinestatic

Returns a view matrix based on the specified input parameters.

Parameters
eyeXThe eye x-coordinate position.
eyeYThe eye y-coordinate position.
eyeZThe eye z-coordinate position.
targetXThe target's center x-coordinate position.
targetYThe target's center y-coordinate position.
targetZThe target's center z-coordinate position.
upXThe up vector x-coordinate value.
upYThe up vector y-coordinate value.
upZThe up vector z-coordinate value.
Returns
a view matrix based on the specified input parameters.
static Mat4* cugl::Mat4::createLookAt ( float  eyeX,
float  eyeY,
float  eyeZ,
float  targetX,
float  targetY,
float  targetZ,
float  upX,
float  upY,
float  upZ,
Mat4 dst 
)
static

Creates a view matrix based on the specified input parameters, putting it in dst.

Parameters
eyeXThe eye x-coordinate position.
eyeYThe eye y-coordinate position.
eyeZThe eye z-coordinate position.
targetXThe target's center x-coordinate position.
targetYThe target's center y-coordinate position.
targetZThe target's center z-coordinate position.
upXThe up vector x-coordinate value.
upYThe up vector y-coordinate value.
upZThe up vector z-coordinate value.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createOrthographic ( float  width,
float  height,
float  zNearPlane,
float  zFarPlane 
)
inlinestatic

Returns an orthographic projection matrix anchored at the origin.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x and y coordinates ranging from -1 to 1, and z coordinates ranging from 0 to 1. Unlike perspective projection, there is no perspective foreshortening in orthographic projection.

The viewable area of this orthographic projection places the origin at the center, with the given width and height.. The z-axis is bound between zNearPlane and zFarPlane. These values are relative to the position and x, y, and z-axes of the view.

To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
widthThe width of the view.
heightThe height of the view.
zNearPlaneThe minimum z-value of the view volume.
zFarPlaneThe maximum z-value of the view volume.
Returns
an orthographic projection matrix anchored at the origin.
static Mat4* cugl::Mat4::createOrthographic ( float  width,
float  height,
float  zNearPlane,
float  zFarPlane,
Mat4 dst 
)
inlinestatic

Creates an orthographic projection matrix anchored at the origin, putting it in dst.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x and y coordinates ranging from -1 to 1, and z coordinates ranging from 0 to 1. Unlike perspective projection, there is no perspective foreshortening in orthographic projection.

The viewable area of this orthographic projection places the origin at the center, with the given width and height.. The z-axis is bound between zNearPlane and zFarPlane. These values are relative to the position and x, y, and z-axes of the view.

To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
widthThe width of the view.
heightThe height of the view.
zNearPlaneThe minimum z-value of the view volume.
zFarPlaneThe maximum z-value of the view volume.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createOrthographicOffCenter ( float  left,
float  right,
float  bottom,
float  top,
float  zNearPlane,
float  zFarPlane 
)
inlinestatic

Returns an orthographic projection matrix.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x and y coordinates ranging from -1 to 1, and z coordinates ranging from 0 to 1. Unlike perspective projection, there is no perspective foreshortening in orthographic projection.

The viewable area of this orthographic projection extends from left to right on the x-axis and bottom to top on the y-axis. The z-axis is bound between zNearPlane and zFarPlane. These values are relative to the position and x, y, and z-axes of the view.

To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
leftThe minimum x-value of the view volume.
rightThe maximum x-value of the view volume.
bottomThe minimum y-value of the view volume.
topThe maximum y-value of the view volume.
zNearPlaneThe minimum z-value of the view volume.
zFarPlaneThe maximum z-value of the view volume.
Returns
an orthographic projection matrix.
static Mat4* cugl::Mat4::createOrthographicOffCenter ( float  left,
float  right,
float  bottom,
float  top,
float  zNearPlane,
float  zFarPlane,
Mat4 dst 
)
static

Creates an orthographic projection matrix, putting it in dst.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x and y coordinates ranging from -1 to 1, and z coordinates ranging from 0 to 1. Unlike perspective projection, there is no perspective foreshortening in orthographic projection.

The viewable area of this orthographic projection extends from left to right on the x-axis and bottom to top on the y-axis. The z-axis is bound between zNearPlane and zFarPlane. These values are relative to the position and x, y, and z-axes of the view.

To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
leftThe minimum x-value of the view volume.
rightThe maximum x-value of the view volume.
bottomThe minimum y-value of the view volume.
topThe maximum y-value of the view volume.
zNearPlaneThe minimum z-value of the view volume.
zFarPlaneThe maximum z-value of the view volume.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createPerspective ( float  fieldOfView,
float  aspectRatio,
float  zNearPlane,
float  zFarPlane 
)
inlinestatic

Returns a perspective projection matrix based on a field of view.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x- and y-coordinates ranging from -1 to 1, and a z-coordinate ranging from 0 to 1. To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
fieldOfViewThe field of view in the y direction (in degrees).
aspectRatioThe aspect ratio, defined as view space width divided by height.
zNearPlaneThe distance to the near view plane.
zFarPlaneThe distance to the far view plane.
Returns
a perspective projection matrix based on a field of view.
static Mat4* cugl::Mat4::createPerspective ( float  fieldOfView,
float  aspectRatio,
float  zNearPlane,
float  zFarPlane,
Mat4 dst 
)
static

Creates a perspective projection matrix based on a field of view, putting it in dst.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x- and y-coordinates ranging from -1 to 1, and a z-coordinate ranging from 0 to 1. To obtain the viewable area (in world space) of a scene, create a bounding frustum and pass the combined view and projection matrix to the constructor.

Parameters
fieldOfViewThe field of view in the y direction (in degrees).
aspectRatioThe aspect ratio, defined as view space width divided by height.
zNearPlaneThe distance to the near view plane.
zFarPlaneThe distance to the far view plane.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createRotation ( const Quaternion quat)
inlinestatic

Returns a rotation matrix from the specified quaternion.

Parameters
quatA quaternion describing a 3D orientation.
Returns
a rotation matrix from the specified quaternion.
static Mat4* cugl::Mat4::createRotation ( const Quaternion quat,
Mat4 dst 
)
static

Creates a rotation matrix from the specified quaternion, putting it in dst.

Parameters
quatA quaternion describing a 3D orientation.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createRotation ( const Vec3 axis,
float  angle 
)
inlinestatic

Returns a rotation matrix from the specified axis and angle.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
axisA vector describing the axis to rotate about.
angleThe angle (in radians).
Returns
a rotation matrix from the specified axis and angle.
static Mat4* cugl::Mat4::createRotation ( const Vec3 axis,
float  angle,
Mat4 dst 
)
static

Creates a rotation matrix from the specified axis and angle, putting it in dst.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
axisA vector describing the axis to rotate about.
angleThe angle (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createRotationX ( float  angle)
inlinestatic

Returns a matrix specifying a rotation around the x-axis.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
Returns
a matrix specifying a rotation around the x-axis.
static Mat4* cugl::Mat4::createRotationX ( float  angle,
Mat4 dst 
)
static

Creates a matrix specifying a rotation around the x-axis, putting it in dst.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createRotationY ( float  angle)
inlinestatic

Returns a matrix specifying a rotation around the y-axis.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
Returns
a matrix specifying a rotation around the y-axis.
static Mat4* cugl::Mat4::createRotationY ( float  angle,
Mat4 dst 
)
static

Creates a matrix specifying a rotation around the y-axis, putting it in dst.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createRotationZ ( float  angle)
inlinestatic

Returns a matrix specifying a rotation around the z-axis.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
Returns
a matrix specifying a rotation around the z-axis.
static Mat4* cugl::Mat4::createRotationZ ( float  angle,
Mat4 dst 
)
static

Creates a matrix specifying a rotation around the z-axis, putting it in dst.

The angle measurement is in radians. The rotation is counter clockwise about the axis.

Parameters
angleThe angle of rotation (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createScale ( float  scale)
inlinestatic

Returns a uniform scale matrix.

Parameters
scaleThe amount to scale.
Returns
a uniform scale matrix.
static Mat4* cugl::Mat4::createScale ( float  scale,
Mat4 dst 
)
static

Creates a uniform scale matrix, putting it in dst.

Parameters
scaleThe amount to scale.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createScale ( float  sx,
float  sy,
float  sz 
)
inlinestatic

Returns a nonuniform scale matrix.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
szThe amount to scale along the z-axis.
Returns
a nonuniform scale matrix.
static Mat4* cugl::Mat4::createScale ( float  sx,
float  sy,
float  sz,
Mat4 dst 
)
static

Creates a nonuniform scale matrix, putting it in dst.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
szThe amount to scale along the z-axis.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createScale ( const Vec3 scale)
inlinestatic

Returns a nonuniform scale matrix from the given vector.

Parameters
scaleThe nonuniform scale value.
Returns
a nonuniform scale matrix from the given vector.
static Mat4* cugl::Mat4::createScale ( const Vec3 scale,
Mat4 dst 
)
static

Creates a nonuniform scale matrix from the given vector, putting it in dst.

Parameters
scaleThe nonuniform scale value.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createTranslation ( const Vec3 trans)
inlinestatic

Returns a translation matrix from the given offset.

Parameters
transThe translation offset.
Returns
a translation matrix from the given offset.
static Mat4* cugl::Mat4::createTranslation ( const Vec3 trans,
Mat4 dst 
)
static

Creates a translation matrix from the given offset, putting it in dst.

Parameters
transThe translation offset.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4 cugl::Mat4::createTranslation ( float  tx,
float  ty,
float  tz 
)
inlinestatic

Returns a translation matrix from the given parameters.

Parameters
txThe translation on the x-axis.
tyThe translation on the y-axis.
tzThe translation on the z-axis.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::createTranslation ( float  tx,
float  ty,
float  tz,
Mat4 dst 
)
static

Creates a translation matrix from the given parameters, putting it in dst.

Parameters
txThe translation on the x-axis.
tyThe translation on the y-axis.
tzThe translation on the z-axis.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static bool cugl::Mat4::decompose ( const Mat4 mat,
Vec3 scale,
Quaternion rot,
Vec3 trans 
)
static

Decomposes the scale, rotation and translation components of the given matrix.

To work properly, the matrix must have been constructed in the following order: scale, then rotate, then translation. While the rotation matrix will always be correct, the scale and translation are not guaranteed to be correct.

If any pointer is null, the method simply does not assign that result. However, it will still continue to compute the component with non-null vectors to store the result.

If the scale component is too small, then it may be impossible to extract the rotation. In that case, if the rotation pointer is not null, this method will return false.

Parameters
matThe matrix to decompose.
scaleThe scale component.
rotThe rotation component.
transThe translation component.
Returns
true if all requested components were properly extracted
bool cugl::Mat4::equals ( const Mat4 mat,
float  variance = CU_MATH_EPSILON 
) const

Returns true if the matrices are within tolerance of each other.

The tolerance is applied to each element of the matrix individually.

Parameters
matThe matrix to compare against.
varianceThe comparison tolerance.
Returns
true if the matrices are within tolerance of each other.
Vec3 cugl::Mat4::getBackVector ( ) const

Returns the backward vector of this matrix, when treated as a camera.

Returns
the backward vector of this matrix, when treated as a camera.
float cugl::Mat4::getDeterminant ( ) const

Returns the determinant of this matrix.

Returns
the determinant of this matrix.
Vec3 cugl::Mat4::getDownVector ( ) const

Returns the down vector of this matrix, when treated as a camera.

Returns
the down vector of this matrix, when treated as a camera.
Vec3 cugl::Mat4::getForwardVector ( ) const

Returns the forward vector of this matrix, when treated as a camera.

Returns
the forward vector of this matrix, when treated as a camera.
Mat4 cugl::Mat4::getInverse ( ) const
inline

Returns a copy of the inverse of this matrix.

If the matrix cannot be inverted, this method returns the zero matrix.

Note: This does not modify the matrix.

Returns
a copy of the inverse of this matrix.
Vec3 cugl::Mat4::getLeftVector ( ) const

Returns the left vector of this matrix, when treated as a camera.

Returns
the left vector of this matrix, when treated as a camera.
Mat4 cugl::Mat4::getNegation ( ) const
inline

Returns a copy of this matrix with all elements negated.

Note: This does not modify the matrix.

Returns
a copy of this matrix with all elements negated.
Vec3 cugl::Mat4::getRightVector ( ) const

Returns the right vector of this matrix, when treated as a camera.

Returns
the right vector of this matrix, when treated as a camera.
Quaternion cugl::Mat4::getRotation ( ) const

Returns the rotational component of this matrix.

If the scale component is too close to zero, we cannot extract the rotation. In that case, we return the zero quaternion. (

Returns
the rotational component of this matrix.
Vec3 cugl::Mat4::getScale ( ) const

Returns the scale component of this matrix.

If the scale component of this matrix has negative parts, it is not possible to always extract the exact scale component. In that case, a scale vector that is mathematically equivalent to the original scale vector is extracted and returned.

To work properly, the matrix must have been constructed in the following order: scale, then rotate, then translation. In any other order, the scale is not guaranteed to be correct.

Returns
the scale component of this matrix.
Vec3 cugl::Mat4::getTranslation ( ) const

Returns the translational component of this matrix.

To work properly, the matrix must have been constructed in the following order: scale, then rotate, then translation. In any other order, the translation is not guaranteed to be correct.

Returns
the translational component of this matrix.
Mat4 cugl::Mat4::getTranspose ( ) const
inline

Returns a copy of the transpose of this matrix.

Transposing a matrix swaps columns and rows. This allows to transform a vector by multiplying it on the left. If the matrix is orthonormal, this is also the inverse.

Note: This does not modify the matrix.

Returns
a copy of the transpose of this matrix.
Vec3 cugl::Mat4::getUpVector ( ) const

Returns the up vector of this matrix, when treated as a camera.

Returns
the up vector of this matrix, when treated as a camera.
static Mat4* cugl::Mat4::invert ( const Mat4 m1,
Mat4 dst 
)
static

Inverts m1 and stores the result in dst.

If the matrix cannot be inverted, this method stores the zero matrix in dst.

Parameters
m1The matrix to negate.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::invert ( )
inline

Inverts this matrix in place.

If the matrix cannot be inverted, this method sets it to the zero matrix.

Returns
A reference to the Mat4 after the inversion.
bool cugl::Mat4::isExactly ( const Mat4 mat) const

Returns true if the matrices are exactly equal to each other.

This method may be unreliable given that the elements are floats. It should only be used to compared matrices that have not undergone a lot of transformations.

Parameters
matThe matrix to compare against.
Returns
true if the matrices are exactly equal to each other.
bool cugl::Mat4::isIdentity ( float  variance = 0.0f) const

Returns true if this matrix is equal to the identity matrix.

The optional comparison tolerance takes into accout that elements are floats and this may not be exact. The tolerance is applied to each element individually. By default, the match must be exact.

Parameters
varianceThe comparison tolerance
Returns
true if this matrix is equal to the identity matrix.
bool cugl::Mat4::isInvertible ( float  variance = CU_MATH_EPSILON) const
inline

Returns true if this matrix is invertible.

The optional comparison tolerance takes into accout that elements are floats and this may not be exact. The tolerance is applied to the matrix determinant.

Returns
true if this matrix is invertible.
bool cugl::Mat4::isOrthogonal ( float  variance = CU_MATH_EPSILON) const

Returns true if this matrix is orthogonal.

The optional comparison tolerance takes into accout that elements are floats and this may not be exact. The tolerance is applied to BOTH the normality test and the dot-product test for each pair.

Returns
true if this matrix is orthogonal.
static Mat4* cugl::Mat4::multiply ( const Mat4 mat,
float  scalar,
Mat4 dst 
)
static

Multiplies the specified matrix by a scalar and stores the result in dst.

Parameters
matThe matrix.
scalarThe scalar value.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::multiply ( const Mat4 m1,
const Mat4 m2,
Mat4 dst 
)
static

Multiplies m1 by the matrix m2 and stores the result in dst.

The matrix m2 is on the right. This means that it corresponds to an subsequent trasnform, when looking at a sequence of transforms.

Parameters
m1The first matrix to multiply.
m2The second matrix to multiply.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::multiply ( float  scalar)
inline

Multiplies the components of this matrix by the specified scalar.

Parameters
scalarThe scalar value.
Returns
A reference to the Mat4 after multiplication.
Mat4& cugl::Mat4::multiply ( const Mat4 mat)
inline

Multiplies this matrix by the specified one.

The matrix mat is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms.

Parameters
matThe matrix to multiply.
Returns
A reference to the Mat4 after multiplication.
static Mat4* cugl::Mat4::negate ( const Mat4 m1,
Mat4 dst 
)
static

Negates m1 and stores the result in dst.

Parameters
m1The matrix to negate.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::negate ( )
inline

Negates this matrix in place.

Returns
A reference to the Mat4 after negation.
cugl::Mat4::operator Affine2 ( ) const

Cast from Mat4 to a Affine2.

The z values are all uniformly ignored. However, it the final element of the matrix is not 1 (e.g. the translation has a w value of 1), then it divides the entire matrix before creating the affine transform.

cugl::Mat4::operator std::string ( ) const
inline

Cast from Vec4 to a string.

bool cugl::Mat4::operator!= ( const Mat4 mat) const
inline

Returns true if this matrix is not equal to the given matrix.

Comparison is exact, which may be unreliable given that the elements are floats.

Parameters
matThe matrix to compare against.
Returns
true if this matrix is not equal to the given matrix.
const Mat4 cugl::Mat4::operator* ( const Mat4 mat) const
inline

Returns the matrix product of this matrix with the given matrix.

The matrix mat is on the right. This means that it corresponds to an subsequent transform, when looking at a sequence of transforms.

Note: This does not modify the matrix.

Parameters
matThe matrix to multiply by.
Returns
the matrix product of this matrix with the given matrix.
const Mat4 cugl::Mat4::operator* ( float  scalar) const
inline

Returns a copy of this matrix with all elements multiplied by the scalar.

Note: This does not modify the matrix.

Parameters
scalarThe scalar value.
Returns
the matrix product of this matrix with the given matrix.
Mat4& cugl::Mat4::operator*= ( const Mat4 mat)
inline

Right-multiplies this matrix by the given matrix.

The matrix mat is on the right. This means that it corresponds to a subsequent transform, when looking at the order of transforms.

Parameters
matThe matrix to multiply by.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::operator*= ( float  scalar)
inline

Multiplies the components of this matrix by the specified scalar.

Parameters
scalarThe scalar value.
Returns
A reference to this (modified) Mat4 for chaining.
const Mat4 cugl::Mat4::operator+ ( const Mat4 mat) const
inline

Returns the sum of this matrix with the given matrix.

Note: This does not modify the matrix.

Parameters
matThe matrix to add.
Returns
the sum of this matrix with the given matrix.
Mat4& cugl::Mat4::operator+= ( const Mat4 mat)
inline

Adds the given matrix to this one in place.

Parameters
matThe matrix to add
Returns
A reference to this (modified) Mat4 for chaining.
const Mat4 cugl::Mat4::operator- ( const Mat4 mat) const
inline

Returns the difference of this matrix with the given matrix.

Note: This does not modify the matrix.

Parameters
matThe matrix to subtract.
Returns
the difference of this matrix with the given matrix.
const Mat4 cugl::Mat4::operator- ( ) const
inline

Returns the negation of this matrix.

Note: This does not modify the matrix.

Returns
the negation of this matrix.
Mat4& cugl::Mat4::operator-= ( const Mat4 mat)
inline

Subtracts the given matrix from this one in place.

Parameters
matThe matrix to subtract
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::operator= ( const Mat4 mat)
inline

Sets the elements of this matrix to those in the specified matrix.

Parameters
matThe matrix to copy.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::operator= ( const float *  array)
inline

Sets the values of this matrix to those in the specified column-major array.

The passed-in array is in column-major order, so the memory layout of the array is as follows:

0   4   8   12
1   5   9   13
2   6   10  14
3   7   11  15
Parameters
arrayAn array containing 16 elements in column-major order.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::operator= ( const Quaternion quat)
inline

Sets this matrix as a rotation matrix from the specified quaternion.

Parameters
quatA quaternion describing a 3D orientation.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::operator= ( const Affine2 aff)

Sets the elements of this matrix to those of the given transform.

The z values are set to the identity.

Parameters
affThe transform to convert
Returns
A reference to this (modified) Mat4 for chaining.
bool cugl::Mat4::operator== ( const Mat4 mat) const
inline

Returns true if this matrix is equal to the given matrix.

Comparison is exact, which may be unreliable given that the elements are floats. It should only be used to compared matrices that have not undergone a lot of transformations.

Parameters
matThe matrix to compare against.
Returns
true if this matrix is equal to the given matrix.
static Mat4* cugl::Mat4::rotate ( const Mat4 mat,
const Quaternion quat,
Mat4 dst 
)
inlinestatic

Applies a quaternion rotation to the given matrix and stores the result in dst.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to rotate.
quatThe quaternion to rotate by.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::rotate ( const Mat4 mat,
const Vec3 axis,
float  angle,
Mat4 dst 
)
inlinestatic

Applies an axis rotation to the given matrix and stores the result in dst.

The rotation is in radians, counter-clockwise about the given axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to rotate.
axisThe axis to rotate about.
angleThe angle (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::rotate ( const Quaternion q)
inline

Applies a quaternion rotation to this matrix.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
qThe quaternion to rotate by.
Returns
This matrix, after rotation.
Mat4& cugl::Mat4::rotate ( const Vec3 axis,
float  angle 
)
inline

Applies an axis rotation to the this matrix.

The rotation is in radians, counter-clockwise about the given axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
axisThe axis to rotate about.
angleThe angle (in radians).
Returns
This matrix, after rotation.
static Mat4* cugl::Mat4::rotateX ( const Mat4 mat,
float  angle,
Mat4 dst 
)
inlinestatic

Applies an x-axis rotation to the given matrix and stores the result in dst.

The rotation is in radians, counter-clockwise about the x-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to rotate.
angleThe angle (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::rotateX ( float  angle)
inline

Applies an x-axis rotation to this matrix.

The rotation is in radians, counter-clockwise about the x-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
angleThe angle (in radians).
Returns
This matrix, after rotation.
static Mat4* cugl::Mat4::rotateY ( const Mat4 mat,
float  angle,
Mat4 dst 
)
inlinestatic

Applies an y-axis rotation to the given matrix and stores the result in dst.

The rotation is in radians, counter-clockwise about the y-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to rotate.
angleThe angle (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::rotateY ( float  angle)
inline

Applies a y-axis rotation to this matrix.

The rotation is in radians, counter-clockwise about the y-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
angleThe angle (in radians).
Returns
This matrix, after rotation.
static Mat4* cugl::Mat4::rotateZ ( const Mat4 mat,
float  angle,
Mat4 dst 
)
inlinestatic

Applies an z-axis rotation to the given matrix and stores the result in dst.

The rotation is in radians, counter-clockwise about the z-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to rotate.
angleThe angle (in radians).
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::rotateZ ( float  angle)
inline

Applies a z-axis rotation to this matrix.

The rotation is in radians, counter-clockwise about the z-axis.

The rotation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
angleThe angle (in radians).
Returns
This matrix, after rotation.
static Mat4* cugl::Mat4::scale ( const Mat4 mat,
float  value,
Mat4 dst 
)
inlinestatic

Applies a uniform scale to the given matrix and stores the result in dst.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to scale.
valueThe scalar to multiply by.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::scale ( const Mat4 mat,
const Vec3 s,
Mat4 dst 
)
inlinestatic

Applies a non-uniform scale to the given matrix and stores the result in dst.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to scale.
sThe vector storing the individual scaling factors
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::scale ( const Mat4 mat,
float  sx,
float  sy,
float  sz,
Mat4 dst 
)
inlinestatic

Applies a non-uniform scale to the given matrix and stores the result in dst.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to scale.
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
szThe amount to scale along the z-axis.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::scale ( float  value)
inline

Applies a uniform scale to this matrix.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
valueThe scalar to multiply by.
Returns
This matrix, after scaling.
Mat4& cugl::Mat4::scale ( const Vec3 s)
inline

Applies a non-uniform scale to this matrix.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
sThe vector storing the individual scaling factors
Returns
This matrix, after scaling.
Mat4& cugl::Mat4::scale ( float  sx,
float  sy,
float  sz 
)
inline

Applies a non-uniform scale to this matrix.

The scaling operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
sxThe amount to scale along the x-axis.
syThe amount to scale along the y-axis.
szThe amount to scale along the z-axis.
Returns
This matrix, after scaling.
Mat4& cugl::Mat4::set ( float  m11,
float  m12,
float  m13,
float  m14,
float  m21,
float  m22,
float  m23,
float  m24,
float  m31,
float  m32,
float  m33,
float  m34,
float  m41,
float  m42,
float  m43,
float  m44 
)

Sets the individal values of this matrix.

Parameters
m11The first element of the first row.
m12The second element of the first row.
m13The third element of the first row.
m14The fourth element of the first row.
m21The first element of the second row.
m22The second element of the second row.
m23The third element of the second row.
m24The fourth element of the second row.
m31The first element of the third row.
m32The second element of the third row.
m33The third element of the third row.
m34The fourth element of the third row.
m41The first element of the fourth row.
m42The second element of the fourth row.
m43The third element of the fourth row.
m44The fourth element of the fourth row.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::set ( const float *  mat)

Sets the values of this matrix to those in the specified column-major array.

The passed-in array is in column-major order, so the memory layout of the array is as follows:

0   4   8   12
1   5   9   13
2   6   10  14
3   7   11  15
Parameters
matAn array containing 16 elements in column-major order.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::set ( const Quaternion quat)

Sets this matrix as a rotation matrix from the specified quaternion.

Parameters
quatA quaternion describing a 3D orientation.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::set ( const Mat4 mat)

Sets the elements of this matrix to those in the specified matrix.

Parameters
matThe matrix to copy.
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::set ( const Affine2 aff)

Sets the elements of this matrix to those of the given transform.

The z values are set to the identity.

Parameters
affThe transform to convert
Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::setIdentity ( )

Sets this matrix to the identity matrix.

Returns
A reference to this (modified) Mat4 for chaining.
Mat4& cugl::Mat4::setZero ( )

Sets all elements of the current matrix to zero.

Returns
A reference to this (modified) Mat4 for chaining.
static Mat4* cugl::Mat4::subtract ( const Mat4 mat,
float  scalar,
Mat4 dst 
)
static

Subtracts a scalar from each component of mat and stores the result in dst.

Parameters
matThe matrix to subtract from.
scalarThe scalar value to subtract.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::subtract ( const Mat4 m1,
const Mat4 m2,
Mat4 dst 
)
static

Subtracts the matrix m2 from m1 and stores the result in dst.

Parameters
m1The first matrix.
m2The second matrix.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::subtract ( float  scalar)
inline

Subtracts a scalar value from each component of this matrix.

Parameters
scalarThe scalar to subtract.
Returns
A reference to the Mat4 after subtraction.
Mat4& cugl::Mat4::subtract ( const Mat4 mat)
inline

Subtracts the specified matrix from the current matrix.

Parameters
matThe matrix to subtract.
Returns
A reference to the Mat4 after subtraction.
std::string cugl::Mat4::toString ( bool  verbose = false) const

Returns a string representation of this matrix for debugging purposes.

If verbose is true, the string will include class information. This allows us to unambiguously identify the class.

Parameters
verboseWhether to include class information
Returns
a string representation of this matrix for debugging purposes.
static Vec2* cugl::Mat4::transform ( const Mat4 mat,
const Vec2 point,
Vec2 dst 
)
static

Transforms the point by the given matrix, and stores the result in dst.

The vector is treated as a point, which means that translation is applied to the result.

Parameters
matThe transform matrix.
pointThe point to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
static Rect* cugl::Mat4::transform ( const Mat4 mat,
const Rect rect,
Rect dst 
)
static

Transforms the rectangle by the given matrix, and stores the result in dst.

This method transforms the four defining points of the rectangle. It then computes the minimal bounding box storing these four points.

Parameters
matThe transform matrix.
rectThe rect to transform.
dstA rect to store the transformed rectangle in.
Returns
A reference to dst for chaining
static Vec3* cugl::Mat4::transform ( const Mat4 mat,
const Vec3 point,
Vec3 dst 
)
static

Transforms the point by the given matrix, and stores the result in dst.

The vector is treated as a point, which means that translation is applied to the result.

Parameters
matThe transform matrix.
pointThe point to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
static Vec4* cugl::Mat4::transform ( const Mat4 mat,
const Vec4 vec,
Vec4 dst 
)
static

Transforms the vector by the given matrix, and stores the result in dst.

The vector is treated as is. Hence whether or not translation is applied depends on the value of w.

Parameters
matThe transform matrix.
vecThe vector to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
Vec2 cugl::Mat4::transform ( const Vec2 point) const

Returns a copy of this point transformed by the matrix.

The vector is treated as a point, which means that translation is applied to the result.

Note: This does not modify the original point. To transform a point in place, use the static method (or the appropriate operator).

Parameters
pointThe point to transform.
Returns
a copy of this point transformed by the matrix.
Rect cugl::Mat4::transform ( const Rect rect) const

Returns a copy of the given rectangle transformed.

This method transforms the four defining points of the rectangle. It then computes the minimal bounding box storing these four points

Note: This does not modify the original rectangle. To transform a point in place, use the static method.

Parameters
rectThe rect to transform.
Returns
A reference to dst for chaining
Vec3 cugl::Mat4::transform ( const Vec3 point) const

Returns a copy of this point transformed by the matrix.

The vector is treated as a point, which means that translation is applied to the result.

Note: This does not modify the original point. To transform a point in place, use the static method (or the appropriate operator).

Parameters
pointThe point to transform.
Returns
a copy of this point transformed by the matrix.
Vec4 cugl::Mat4::transform ( const Vec4 vec) const

Returns a copy of this vector transformed by the matrix.

The vector is treated as is. Hence whether or not translation is applied depends on the value of w.

Note: This does not modify the original vector. To transform a vector in place, use the static method (or the appropriate operator).

Parameters
vecThe vector to transform.
Returns
a copy of this point transformed by the matrix.
static Vec2* cugl::Mat4::transformVector ( const Mat4 mat,
const Vec2 vec,
Vec2 dst 
)
static

Transforms the vector by the given matrix, and stores the result in dst.

The vector is treated as a direction, which means that translation is not applied to the result.

Parameters
matThe transform matrix.
vecThe vector to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
static Vec3* cugl::Mat4::transformVector ( const Mat4 mat,
const Vec3 vec,
Vec3 dst 
)
static

Transforms the vector by the given matrix, and stores the result in dst.

The vector is treated as a direction, which means that translation is not applied to the result.

Parameters
matThe transform matrix.
vecThe vector to transform.
dstA vector to store the transformed point in.
Returns
A reference to dst for chaining
Vec2 cugl::Mat4::transformVector ( const Vec2 vec) const

Returns a copy of this vector transformed by the matrix.

The vector is treated as a direction, which means that translation is not applied to the result.

Note: This does not modify the original vector. To transform a vector in place, use the static method (or the appropriate operator).

Parameters
vecThe vector to transform.
Returns
a copy of this point transformed by the matrix.
Vec3 cugl::Mat4::transformVector ( const Vec3 vec) const

Returns a copy of this vector transformed by the matrix.

The vector is treated as a direction, which means that translation is not applied to the result.

Note: This does not modify the original vector. To transform a vector in place, use the static method (or the appropriate operator).

Parameters
vecThe vector to transform.
Returns
a copy of this point transformed by the matrix.
static Mat4* cugl::Mat4::translate ( const Mat4 mat,
const Vec3 t,
Mat4 dst 
)
inlinestatic

Applies a translation to the given matrix and stores the result in dst.

The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to translate.
tThe vector storing the individual translation offsets
dstA matrix to store the result in.
Returns
A reference to dst for chaining
static Mat4* cugl::Mat4::translate ( const Mat4 mat,
float  tx,
float  ty,
float  tz,
Mat4 dst 
)
inlinestatic

Applies a translation to the given matrix and stores the result in dst.

The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
matThe matrix to translate.
txThe translation offset for the x-axis.
tyThe translation offset for the y-axis.
tzThe translation offset for the z-axis.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::translate ( const Vec3 t)
inline

Applies a translation to this matrix.

The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
tThe vector storing the individual translation offsets
Returns
This matrix, after translation.
Mat4& cugl::Mat4::translate ( float  tx,
float  ty,
float  tz 
)
inline

Applies a translation to this matrix.

The translation operation is applied on the right. Given our convention, that means that it takes place AFTER any previously applied transforms.

Parameters
txThe translation offset for the x-axis.
tyThe translation offset for the y-axis.
tzThe translation offset for the z-axis.
Returns
This matrix, after translation.
static Mat4* cugl::Mat4::transpose ( const Mat4 m1,
Mat4 dst 
)
static

Transposes m1 and stores the result in dst.

Transposing a matrix swaps columns and rows. This allows to transform a vector by multiplying it on the left. If the matrix is orthonormal, this is also the inverse.

Parameters
m1The matrix to negate.
dstA matrix to store the result in.
Returns
A reference to dst for chaining
Mat4& cugl::Mat4::transpose ( )
inline

Transposes this matrix in place.

Transposing a matrix swaps columns and rows. This allows to transform a vector by multiplying it on the left. If the matrix is orthonormal, this is also the inverse.

Returns
A reference to the Mat4 after the transposition.

Member Data Documentation

const Mat4 cugl::Mat4::IDENTITY
static

The identity matrix (ones on the diagonal)

const Mat4 cugl::Mat4::ONE
static

The matrix with all ones

const Mat4 cugl::Mat4::ZERO
static

The matrix with all zeroes


The documentation for this class was generated from the following file: