fluidvis
|
#include <SXMath.h>
Public Member Functions | |
EXPA | Matrix () |
EXPA | Matrix (float m) |
EXPA | Matrix (float m00, float m01, float m10, float m11) |
EXPA | Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) |
EXPA | Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) |
EXPA | Matrix (const Vector &m0, const Vector &m1, const Vector &m2, const Vector &m3) |
EXPA | Matrix (const float *m) |
EXPA | Matrix (const DMatrix &m) |
EXPA | Matrix (const Matrix &m) |
EXPA Matrix & | operator= (const Matrix &m) |
virtual EXPA | ~Matrix () |
EXPA float & | operator[] (unsigned int index) |
EXPA float | operator[] (unsigned int index) const |
EXPA Matrix & | operator<< (const Matrix &m) |
EXPA Matrix & | operator<< (const float *m) |
EXPA const Matrix & | operator>> (Matrix &m) const |
EXPA const Matrix & | operator>> (float *m) const |
EXPA Matrix & | add (const Matrix &m) |
EXPA Matrix & | add (float m) |
EXPA Matrix & | leftmult (const Matrix &m) |
EXPA Matrix & | rightmult (const Matrix &m) |
EXPA Matrix & | scalarmult (float s) |
EXPA Matrix & | transpose () |
EXPA Matrix & | identity () |
EXPA Matrix & | inverse () |
EXPA float | determinant () const |
EXPA float | cofactor (unsigned int row, unsigned int column) const |
EXPA Matrix & | random () |
EXPA Matrix & | rotate (const Vector &m, float angle) |
EXPA Matrix & | translate (const Vector &v) |
EXPA Matrix & | scale (const Vector &v) |
EXPA Matrix & | shear (const Vector &v) |
EXPA Matrix & | submatrix () |
EXPA Matrix & | normalMatrix () |
EXPA Matrix & | viewMatrix (const Vector &position, const Vector &view, const Vector &up) |
EXPA Matrix & | perspectiveMatrix (float angle, float width, float height, float znear, float zfar) |
EXPA Matrix & | orthographicPerspeciveMatrix (float left, float right, float bottom, float top, float znear, float zfar) |
EXPA bool | equals (const Matrix &m) const |
EXPA bool | equals (const Matrix &m, float epsilon) const |
Public Attributes | |
float * | elements |
Friends | |
EXPA friend Matrix | operator+ (const Matrix &m1, const Matrix &m2) |
EXPA friend Matrix | operator+ (const Matrix &m, float x) |
EXPA friend Matrix | operator+ (float x, const Matrix &m) |
EXPA friend Matrix | operator* (const Matrix &m1, const Matrix &m2) |
EXPA friend Matrix | operator* (const Matrix &m, float s) |
EXPA friend Matrix | operator* (float s, const Matrix &m) |
EXPA friend Matrix | operator- (const Matrix &m) |
EXPA friend Matrix | operator! (const Matrix &m) |
EXPA friend Matrix | operator^ (const Matrix &m, int power) |
A 4 x 4 matrix
EXPA sx::Matrix::Matrix | ( | ) |
default constructor, initializes the matrix with the identity matrix
EXPA sx::Matrix::Matrix | ( | float | m | ) |
constructor, initializes the matrix with all values set to m
EXPA sx::Matrix::Matrix | ( | float | m00, |
float | m01, | ||
float | m10, | ||
float | m11 | ||
) |
Constructor. Initializes the matrix with the unit matrix, overwritten in its above left by the 2x2 matrix m00 m01 m10 m11
EXPA sx::Matrix::Matrix | ( | float | m00, |
float | m01, | ||
float | m02, | ||
float | m10, | ||
float | m11, | ||
float | m12, | ||
float | m20, | ||
float | m21, | ||
float | m22 | ||
) |
Constructor. Initializes the matrix with the unit matrix, overwritten in its above left by the 3x3 matrix m00 m01 m02 m10 m11 m12 m20 m21 m22
EXPA sx::Matrix::Matrix | ( | float | m00, |
float | m01, | ||
float | m02, | ||
float | m03, | ||
float | m10, | ||
float | m11, | ||
float | m12, | ||
float | m13, | ||
float | m20, | ||
float | m21, | ||
float | m22, | ||
float | m23, | ||
float | m30, | ||
float | m31, | ||
float | m32, | ||
float | m33 | ||
) |
Constructor. Initializes the matrix with the matrix m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33
EXPA sx::Matrix::Matrix | ( | const Vector & | m0, |
const Vector & | m1, | ||
const Vector & | m2, | ||
const Vector & | m3 | ||
) |
constructor, initializes the matrix with the columns m0, m1, m2, m3
EXPA sx::Matrix::Matrix | ( | const float * | m | ) |
Constructor, initializes the matrix with the entries of array m. m is required to be at least of length 16, and the matrix elements in m should be given in column-major order.
EXPA sx::Matrix::Matrix | ( | const DMatrix & | m | ) |
constructor for casting
EXPA sx::Matrix::Matrix | ( | const Matrix & | m | ) |
copy constructor
|
virtual |
deconstructor
adds matrix m to this vector, and returns a reference to this
EXPA Matrix& sx::Matrix::add | ( | float | m | ) |
adds a matrix with all components equal to m to this, and returns a reference to this
EXPA float sx::Matrix::cofactor | ( | unsigned int | row, |
unsigned int | column | ||
) | const |
returns the cofactor a_(row,column) of the matrix
EXPA float sx::Matrix::determinant | ( | ) | const |
returns the determinant of the matrix
EXPA bool sx::Matrix::equals | ( | const Matrix & | m | ) | const |
returns true iff all components of this and m are equal
EXPA bool sx::Matrix::equals | ( | const Matrix & | m, |
float | epsilon | ||
) | const |
returns true iff the difference of each component of this and m is not larger than epsilon
EXPA Matrix& sx::Matrix::identity | ( | ) |
sets this to the identity matrix, and returns a reference to this
EXPA Matrix& sx::Matrix::inverse | ( | ) |
Replaces itself with its inverse matrix. Leaves this untouched, if the matrix is not regular. Returns a reference to this.
stores m * this[0] in this, and returns a reference to this
EXPA Matrix& sx::Matrix::normalMatrix | ( | ) |
Assigns this with its normal matrix. A normal matrix of a 4x4 matrix m is defined as the transposed inverted matrix of the 3x3 submatrix in the left above corner of m. Let's the invertion of the 3x3 submatrix being undone, if it's not a regular matrix. Returns a reference to this.
copies matrix m, and returns a reference to this
EXPA Matrix& sx::Matrix::operator<< | ( | const float * | m | ) |
Copies array m, and returns a reference to this. The length of array m must be at least 16. The elements of the matrix in m should be given in column-major order. Returns a reference to this.
copies itself to matrix m, returns a reference to this
EXPA const Matrix& sx::Matrix::operator>> | ( | float * | m | ) | const |
Copies itself to array m. The content of this is copied into m in column-major order. The length of array v must be at least 16. Returns a reference to this.
EXPA float& sx::Matrix::operator[] | ( | unsigned int | index | ) |
Returns a reference to the index. component. If index is out of bounds, an exception is thrown.
index | number of the component |
return | reference to the index. component |
exception | throws an exception Exception of type EX_BOUNDS, if index is equal to 16 or above |
EXPA float sx::Matrix::operator[] | ( | unsigned int | index | ) | const |
Returns a reference to the index. component. If index is out of bounds, an exception is thrown.
index | number of the component |
return | reference to the index. component |
exception | throws an exception Exception of type EX_BOUNDS, if index is equal to 16 or above |
EXPA Matrix& sx::Matrix::orthographicPerspeciveMatrix | ( | float | left, |
float | right, | ||
float | bottom, | ||
float | top, | ||
float | znear, | ||
float | zfar | ||
) |
Assigns this with a transformation performing an orthogonal transform from viewspace into projection space. The view frustrum is bounded by left, right along the x-axis, bottom, top along the y-axis, and along the z-axis it starts znear behind the x-y-plane, and ends zfar behind the x-y-plane. In projection space the viewing frustrum is the unit cube, with -1 on the front, and 1 on the back. Hence along the z-axis -znear in viewing space equals -1 in projection space, and -zfar in viewing space equals 1 in projection space. The specified viewing frustrum must be nonempty, otherwise this method does not change this matrix.
EXPA Matrix& sx::Matrix::perspectiveMatrix | ( | float | angle, |
float | width, | ||
float | height, | ||
float | znear, | ||
float | zfar | ||
) |
Assigns this with a transformation performing a perspective transform from viewspace into projection space. The viewing direcion in view space is the negative z-axis, which remains to be the viewing direction in projection space after the transform. Parameter angle specifies the viewing angle of the viewing frustrum in the y-z-plane in radians. width and height are the width and height of the projection plane. Along the viewing direction the viewing frustrum starts at -znear, and ends at -zfar. In projection space the viewing frustrum is the unit cube, with -1 on the front, and 1 on the back. Hence along the z-axis -znear in viewing space equals -1 in projection space, and -zfar in viewing space equals 1 in projection space. The specified viewing frustrum must be nonempty, otherwise this method does not change this matrix.
EXPA Matrix& sx::Matrix::random | ( | ) |
assigns this with a random matrix in [0,1]^4x4, and returns a reference to this
stores this[0] * m in this, and returns a reference to this
assigns this with the rotation matrix representing a rotation around m by angle in radians counterclockwise, and returns a reference to this
EXPA Matrix& sx::Matrix::scalarmult | ( | float | s | ) |
returns the scalar product of this and s
Assigns this with the scaling matrix representing a scaling by v[0] along the x-axis, by v[1] along the y-axis and by v[2] along the z-axis. Returns a reference to this.
Assigns this with the shear matrix representing a shear with the x-y plane being a plane of fixed points, and v being the shearvector of the shear mapping. Vectors parallel to the shear vector are transformed such that they are parallel to the z-axis. The third component of v must me different from zero, otherwise the method does not change this. Returns a reference to this.
EXPA Matrix& sx::Matrix::submatrix | ( | ) |
assigns this with its 3x3 submatrix in the left above corner, and returns a reference to this
assigns this with the translation matrix representing a translation by vector v, and returns a reference to this
EXPA Matrix& sx::Matrix::transpose | ( | ) |
transposes this, and returns a reference to this
EXPA Matrix& sx::Matrix::viewMatrix | ( | const Vector & | position, |
const Vector & | view, | ||
const Vector & | up | ||
) |
Assigns this with a transformation into the viewspace having its origin at position, its z-axis pointing in negative view direction, and its y-axis pointing in up direction. Vectors view and up are required to span a plane, otherwise the method will have no effect. Returns a reference to this.
returns the product m1 * m2
returns the sum of m1 and m2
returns the sum of m and a matrix with all components equal to x
returns the sum of m and a matrix with all components equal to x
Returns the power of a matrix. If matrix m is regular, and power is negative, the |power|. power of the inverse of m is computed. If m is singular, instead the |power|. power of m is computed.
float* sx::Matrix::elements |
Elements of the matrix, has always 16 of them. The elements are ordered in column-major order: Let s0, s1, s2, s3 be the column vectors of the matrix, then the elements of the matrix in the array elements are in the same order as the elements of the tuple (s0,s1,s2,s3).