fluidvis
Public Member Functions | Public Attributes | Friends | List of all members
sx::DMatrix Class Reference

#include <SXMath.h>

Inheritance diagram for sx::DMatrix:
sx::UniformDMatrix

Public Member Functions

EXPA DMatrix ()
 
EXPA DMatrix (double m)
 
EXPA DMatrix (double m00, double m01, double m10, double m11)
 
EXPA DMatrix (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 
EXPA DMatrix (double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33)
 
EXPA DMatrix (const DVector &m0, const DVector &m1, const DVector &m2, const DVector &m3)
 
EXPA DMatrix (const double *m)
 
EXPA DMatrix (const Matrix &m)
 
EXPA DMatrix (const DMatrix &m)
 
EXPA DMatrixoperator= (const DMatrix &m)
 
virtual EXPA ~DMatrix ()
 
EXPA double & operator[] (unsigned int index)
 
EXPA double operator[] (unsigned int index) const
 
EXPA DMatrixoperator<< (const DMatrix &m)
 
EXPA DMatrixoperator<< (const double *m)
 
EXPA const DMatrixoperator>> (DMatrix &m) const
 
EXPA const DMatrixoperator>> (double *m) const
 
EXPA DMatrixadd (const DMatrix &m)
 
EXPA DMatrixadd (double m)
 
EXPA DMatrixleftmult (const DMatrix &m)
 
EXPA DMatrixrightmult (const DMatrix &m)
 
EXPA DMatrixscalarmult (double s)
 
EXPA DMatrixtranspose ()
 
EXPA DMatrixidentity ()
 
EXPA DMatrixinverse ()
 
EXPA double determinant () const
 
EXPA double cofactor (unsigned int row, unsigned int column) const
 
EXPA DMatrixrandom ()
 
EXPA DMatrixrotate (const DVector &m, double angle)
 
EXPA DMatrixtranslate (const DVector &v)
 
EXPA DMatrixscale (const DVector &v)
 
EXPA DMatrixshear (const DVector &v)
 
EXPA DMatrixsubmatrix ()
 
EXPA DMatrixnormalMatrix ()
 
EXPA DMatrixviewMatrix (const DVector &position, const DVector &view, const DVector &up)
 
EXPA DMatrixperspectiveMatrix (double angle, double width, double height, double znear, double zfar)
 
EXPA DMatrixorthographicPerspeciveMatrix (double left, double right, double bottom, double top, double znear, double zfar)
 
EXPA bool equals (const DMatrix &m) const
 
EXPA bool equals (const DMatrix &m, double epsilon) const
 

Public Attributes

double * elements
 

Friends

EXPA friend DMatrix operator+ (const DMatrix &m1, const DMatrix &m2)
 
EXPA friend DMatrix operator+ (const DMatrix &m, double x)
 
EXPA friend DMatrix operator+ (double x, const DMatrix &m)
 
EXPA friend DMatrix operator* (const DMatrix &m1, const DMatrix &m2)
 
EXPA friend DMatrix operator* (const DMatrix &m, double s)
 
EXPA friend DMatrix operator* (double s, const DMatrix &m)
 
EXPA friend DMatrix operator- (const DMatrix &m)
 
EXPA friend DMatrix operator! (const DMatrix &m)
 
EXPA friend DMatrix operator^ (const DMatrix &m, int power)
 

Detailed Description

A double precision 4 x 4 matrix

Constructor & Destructor Documentation

EXPA sx::DMatrix::DMatrix ( )

default constructor, initializes the matrix with the identity matrix

EXPA sx::DMatrix::DMatrix ( double  m)

constructor, initializes the matrix with all values set to m

EXPA sx::DMatrix::DMatrix ( double  m00,
double  m01,
double  m10,
double  m11 
)

Constructor. Initializes the matrix with the unit matrix, overwritten in its above left by the 2x2 matrix m00 m01 m10 m11

EXPA sx::DMatrix::DMatrix ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12,
double  m20,
double  m21,
double  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::DMatrix::DMatrix ( double  m00,
double  m01,
double  m02,
double  m03,
double  m10,
double  m11,
double  m12,
double  m13,
double  m20,
double  m21,
double  m22,
double  m23,
double  m30,
double  m31,
double  m32,
double  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::DMatrix::DMatrix ( const DVector m0,
const DVector m1,
const DVector m2,
const DVector m3 
)

constructor, initializes the matrix with the columns m0, m1, m2, m3

EXPA sx::DMatrix::DMatrix ( const double *  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::DMatrix::DMatrix ( const Matrix m)

constructor for casting

EXPA sx::DMatrix::DMatrix ( const DMatrix m)

copy constructor

virtual EXPA sx::DMatrix::~DMatrix ( )
virtual

deconstructor

Member Function Documentation

EXPA DMatrix& sx::DMatrix::add ( const DMatrix m)

adds matrix m to this vector, and returns a reference to this

EXPA DMatrix& sx::DMatrix::add ( double  m)

adds a matrix with all components equal to m to this, and returns a reference to this

EXPA double sx::DMatrix::cofactor ( unsigned int  row,
unsigned int  column 
) const

returns the cofactor a_(row,column) of the matrix

EXPA double sx::DMatrix::determinant ( ) const

returns the determinant of the matrix

EXPA bool sx::DMatrix::equals ( const DMatrix m) const

returns true iff all components of this and m are equal

EXPA bool sx::DMatrix::equals ( const DMatrix m,
double  epsilon 
) const

returns true iff the difference of each component of this and m is not larger than epsilon

EXPA DMatrix& sx::DMatrix::identity ( )

sets this to the identity matrix, and returns a reference to this

EXPA DMatrix& sx::DMatrix::inverse ( )

Replaces itself with its inverse matrix. Leaves this untouched, if the matrix is not regular. Returns a reference to this.

EXPA DMatrix& sx::DMatrix::leftmult ( const DMatrix m)

stores m * this[0] in this, and returns a reference to this

EXPA DMatrix& sx::DMatrix::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.

EXPA DMatrix& sx::DMatrix::operator<< ( const DMatrix m)

copies matrix m, and returns a reference to this

EXPA DMatrix& sx::DMatrix::operator<< ( const double *  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.

EXPA DMatrix& sx::DMatrix::operator= ( const DMatrix m)

assignment operator

EXPA const DMatrix& sx::DMatrix::operator>> ( DMatrix m) const

copies itself to matrix m, returns a reference to this

EXPA const DMatrix& sx::DMatrix::operator>> ( double *  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 double& sx::DMatrix::operator[] ( unsigned int  index)

Returns a reference to the index. component. If index is out of bounds, an exception is thrown.

Parameters
indexnumber of the component
returnreference to the index. component
exceptionthrows an exception Exception of type EX_BOUNDS, if index is equal to 16 or above
EXPA double sx::DMatrix::operator[] ( unsigned int  index) const

Returns a reference to the index. component. If index is out of bounds, an exception is thrown.

Parameters
indexnumber of the component
returnreference to the index. component
exceptionthrows an exception Exception of type EX_BOUNDS, if index is equal to 16 or above
EXPA DMatrix& sx::DMatrix::orthographicPerspeciveMatrix ( double  left,
double  right,
double  bottom,
double  top,
double  znear,
double  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 DMatrix& sx::DMatrix::perspectiveMatrix ( double  angle,
double  width,
double  height,
double  znear,
double  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 DMatrix& sx::DMatrix::random ( )

assigns this with a random matrix in [0,1]^4x4, and returns a reference to this

EXPA DMatrix& sx::DMatrix::rightmult ( const DMatrix m)

stores this[0] * m in this, and returns a reference to this

EXPA DMatrix& sx::DMatrix::rotate ( const DVector m,
double  angle 
)

assigns this with the rotation matrix representing a rotation around m by angle in radians counterclockwise, and returns a reference to this

EXPA DMatrix& sx::DMatrix::scalarmult ( double  s)

returns the scalar product of this and s

EXPA DMatrix& sx::DMatrix::scale ( const DVector v)

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.

EXPA DMatrix& sx::DMatrix::shear ( const DVector v)

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 DMatrix& sx::DMatrix::submatrix ( )

assigns this with its 3x3 submatrix in the left above corner, and returns a reference to this

EXPA DMatrix& sx::DMatrix::translate ( const DVector v)

assigns this with the translation matrix representing a translation by vector v, and returns a reference to this

EXPA DMatrix& sx::DMatrix::transpose ( )

transposes this, and returns a reference to this

EXPA DMatrix& sx::DMatrix::viewMatrix ( const DVector position,
const DVector view,
const DVector 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.

Friends And Related Function Documentation

EXPA friend DMatrix operator! ( const DMatrix m)
friend

returns a transposed copy of m

EXPA friend DMatrix operator* ( const DMatrix m1,
const DMatrix m2 
)
friend

returns the product m1 * m2

EXPA friend DMatrix operator* ( const DMatrix m,
double  s 
)
friend

returns the scalar product m * s

EXPA friend DMatrix operator* ( double  s,
const DMatrix m 
)
friend

returns the scalar product m * s

EXPA friend DMatrix operator+ ( const DMatrix m1,
const DMatrix m2 
)
friend

returns the sum of m1 and m2

EXPA friend DMatrix operator+ ( const DMatrix m,
double  x 
)
friend

returns the sum of m and a matrix with all components equal to x

EXPA friend DMatrix operator+ ( double  x,
const DMatrix m 
)
friend

returns the sum of m and a matrix with all components equal to x

EXPA friend DMatrix operator- ( const DMatrix m)
friend

returns the product -1 * m

EXPA friend DMatrix operator^ ( const DMatrix m,
int  power 
)
friend

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.

Member Data Documentation

double* sx::DMatrix::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).


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