Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

salt::Matrix Class Reference

Matrix provides a 4x4 float Matrix along with methods to set up and manipulate it. More...

#include <matrix.h>

List of all members.

Public Member Functions

f_inline Matrix ()
 do nothing constructor, the matrix values are undefined for performance reasons
f_inline Matrix (float *newMatrix)
 copy constructs the matrix from newMatrix, a pointer to a float array
f_inline Matrix (const Matrix &newMatrix)
 copy constructs the matrix from newMatrix, a reference to another Matrix
f_inline Matrix (Matrix *newMatrix)
 copy constructs the matrix from newMatrix, a pointer to another Matrix
f_inline 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)
 constructs the matrix from 16 float values
f_inline void Identity ()
 sets up the identity matrix
f_inline void RotationX (float inAngle)
 sets up a X-rotation matrix with inAngle degrees
f_inline void RotationY (float inAngle)
 sets up a Y-rotation matrix with inAngle degrees
f_inline void RotationZ (float inAngle)
 sets up a Z-rotation matrix with inAngle degrees
f_inline void Translation (const Vector3f &inVector)
 sets up a translation matrix with inVector
f_inline void Scale (const Vector3f &inVector)
 sets up a scaling matrix with inVector
void LookAt (const Vector3f &inEye, const Vector3f &inDirection, const Vector3f &inUp)
 sets up a rotation matrix, looking from inEye in inDirection, with inUp pointing up
void Dump () const
 print the matrix to stdout for debugging purposes
f_inline void Set (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)
 sets up the matrix from 16 float values
f_inline const MatrixRotateX (float inAngle)
 rotate the matrix around the axis X with inAngle radians
f_inline const MatrixRotateY (float inAngle)
 Rotate the matrix around the axis Y with inAngle radians.
f_inline const MatrixRotateZ (float inAngle)
 Rotate the matrix around the axis Z with inAngle radians.
f_inline const MatrixTranslate (const Vector3f &inVector)
 Translate the matrix by vector inVector.
f_inline const Vector3fRight () const
 returns a const reference to the right vector of the matrix
f_inline Vector3fRight ()
 returns a reference to the right vector of the matrix
f_inline const Vector3fUp () const
 returns a const reference to the up vector of the matrix
f_inline Vector3fUp ()
 returns a reference to the up vector of the matrix
f_inline const Vector3fForward () const
 returns a const reference to the forward vector of the matrix
f_inline Vector3fForward ()
 returns a reference to the forward vector of the matrix
f_inline const Vector3fPos () const
 returns a const reference to the pos vector of the matrix
f_inline Vector3fPos ()
 returns a reference to the pos vector of the matrix
bool IsEqual (const Matrix &matrix) const
 returns true if this matrix is equal to <matrix>
f_inline void InvertRotationMatrix ()
 inverts a matrix, spezialized for rotation matrices only
f_inline Vector3f Transform (const Vector3f &inVector) const
 multiplies the matrix with inVector
f_inline Vector3f Rotate (const Vector3f &inVector) const
 rotates the matrix by inVector
f_inline Vector3f InverseRotate (const Vector3f &inVector) const
 inverse rotates the matrix by inVector
void CalcAttenuationNoRotation (const Vector3f &pos, float radius)
 sets up an attenuation matrix without rotation
void CalcAttenuationWithRotation (const Matrix &lightWorldMatrix, float radius)
 sets up an attenuation matrix with rotation
void CalcInfiniteProjection (float width, float height, float fov, float zNear)
 sets up an infinite projection matrix
void CalcInfiniteFrustum (float left, float right, float bottom, float top, float zNear)
 sets up an infinite frustum
void CalcSpotLight (const Matrix &lightWorldTransform, float fov, float width, float height, float zNear)
 sets up a special lighting matrix for a spotlight
f_inline const Matrix operator * (const Matrix &inRHS) const
 multiplies the matrix with another matrix
f_inline const Matrixoperator *= (const Matrix &inRHS)
 multiplies the matrix with another Matrix
f_inline const Vector3f operator * (const Vector3f &inRHS) const
 Multipies the matrix with a 3 dimensional vector.
f_inline const Vector3f operator * (const Vector2f &inRHS) const
 multiplies the matrix with a 2 dimensional vector
f_inline float & operator() (int inRow, int inColumn)
 returns a reference to a single element of the matrix
f_inline const float & operator() (int inRow, int inColumn) const
 returns a const reference to a single element of the matrix

Static Public Member Functions

static float * GetIdentity ()
 returns a pointer to a float array describing an identity matrix

Public Attributes

float m [16]
 the values of the matrix

Protected Member Functions

f_inline float & El (int inRow, int inColumn)
 returns a reference to a single element of the matrix
f_inline const float & El (int inRow, int inColumn) const
 returns a const reference to a single element of the matrix

Static Private Attributes

static float mIdentity [16]
 the identity matrix


Detailed Description

Matrix provides a 4x4 float Matrix along with methods to set up and manipulate it.

Definition at line 42 of file matrix.h.


Constructor & Destructor Documentation

f_inline salt::Matrix::Matrix  )  [inline]
 

do nothing constructor, the matrix values are undefined for performance reasons

Definition at line 49 of file matrix.h.

f_inline salt::Matrix::Matrix float *  newMatrix  )  [inline]
 

copy constructs the matrix from newMatrix, a pointer to a float array

Definition at line 52 of file matrix.h.

f_inline salt::Matrix::Matrix const Matrix newMatrix  )  [inline]
 

copy constructs the matrix from newMatrix, a reference to another Matrix

Definition at line 55 of file matrix.h.

References m.

f_inline salt::Matrix::Matrix Matrix newMatrix  )  [inline]
 

copy constructs the matrix from newMatrix, a pointer to another Matrix

Definition at line 58 of file matrix.h.

References m.

f_inline salt::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
 

constructs the matrix from 16 float values

Definition at line 202 of file matrix.h.

References m.


Member Function Documentation

void Matrix::CalcAttenuationNoRotation const Vector3f pos,
float  radius
 

sets up an attenuation matrix without rotation

Calculate an attenuation matrix. pos = world space position of light radius = radius of light (used for distance attenuation)

Definition at line 66 of file matrix.cpp.

References Identity(), and Translation().

Here is the call graph for this function:

void Matrix::CalcAttenuationWithRotation const Matrix lightWorldMatrix,
float  radius
 

sets up an attenuation matrix with rotation

Definition at line 87 of file matrix.cpp.

References Identity(), InvertRotationMatrix(), and Translation().

Here is the call graph for this function:

void Matrix::CalcInfiniteFrustum float  left,
float  right,
float  bottom,
float  top,
float  zNear
 

sets up an infinite frustum

Definition at line 117 of file matrix.cpp.

References El(), and Identity().

Referenced by oxygen::Camera::Bind(), and CalcInfiniteProjection().

Here is the call graph for this function:

void Matrix::CalcInfiniteProjection float  width,
float  height,
float  fov,
float  zNear
 

sets up an infinite projection matrix

Definition at line 109 of file matrix.cpp.

References CalcInfiniteFrustum(), and salt::gDegToRad().

Referenced by CalcSpotLight().

Here is the call graph for this function:

void Matrix::CalcSpotLight const Matrix lightWorldTransform,
float  fov,
float  width,
float  height,
float  zNear
 

sets up a special lighting matrix for a spotlight

Definition at line 137 of file matrix.cpp.

References CalcInfiniteProjection(), Identity(), InvertRotationMatrix(), Scale(), scale(), and Translation().

Here is the call graph for this function:

void Matrix::Dump  )  const
 

print the matrix to stdout for debugging purposes

Definition at line 35 of file matrix.cpp.

References m.

f_inline const float& salt::Matrix::El int  inRow,
int  inColumn
const [inline, protected]
 

returns a const reference to a single element of the matrix

Definition at line 195 of file matrix.h.

f_inline float& salt::Matrix::El int  inRow,
int  inColumn
[inline, protected]
 

returns a reference to a single element of the matrix

Definition at line 192 of file matrix.h.

Referenced by CalcInfiniteFrustum(), InvertRotationMatrix(), operator *(), RotateX(), RotateY(), RotateZ(), RotationX(), RotationY(), RotationZ(), Scale(), Translate(), and Translation().

f_inline Vector3f& salt::Matrix::Forward  )  [inline]
 

returns a reference to the forward vector of the matrix

Definition at line 129 of file matrix.h.

f_inline const Vector3f& salt::Matrix::Forward  )  const [inline]
 

returns a const reference to the forward vector of the matrix

Definition at line 126 of file matrix.h.

static float* salt::Matrix::GetIdentity  )  [inline, static]
 

returns a pointer to a float array describing an identity matrix

Definition at line 70 of file matrix.h.

f_inline void salt::Matrix::Identity  )  [inline]
 

sets up the identity matrix

Definition at line 67 of file matrix.h.

Referenced by CalcAttenuationNoRotation(), CalcAttenuationWithRotation(), CalcInfiniteFrustum(), CalcSpotLight(), oxygen::Camera::Camera(), RotationX(), RotationY(), RotationZ(), Scale(), salt::Frustum::Set(), oxygen::Transform::Transform(), and Translation().

f_inline Vector3f salt::Matrix::InverseRotate const Vector3f inVector  )  const
 

inverse rotates the matrix by inVector

Definition at line 407 of file matrix.h.

References m, salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Here is the call graph for this function:

f_inline void salt::Matrix::InvertRotationMatrix  ) 
 

inverts a matrix, spezialized for rotation matrices only

Definition at line 376 of file matrix.h.

References El(), salt::gSwap(), Pos(), and Rotate().

Referenced by oxygen::Camera::Bind(), CalcAttenuationWithRotation(), CalcSpotLight(), oxygen::BaseNode::GetLocalPos(), and salt::Frustum::Set().

Here is the call graph for this function:

bool Matrix::IsEqual const Matrix matrix  )  const
 

returns true if this matrix is equal to <matrix>

Definition at line 159 of file matrix.cpp.

References m.

void Matrix::LookAt const Vector3f inEye,
const Vector3f inDirection,
const Vector3f inUp
 

sets up a rotation matrix, looking from inEye in inDirection, with inUp pointing up

Definition at line 44 of file matrix.cpp.

References salt::TVector3< DATATYPE, TYPE >::Cross(), salt::TVector< DATATYPE, ELEMENTS, TYPE >::Normalize(), salt::TVector< DATATYPE, ELEMENTS, TYPE >::Normalized(), Pos(), Rotate(), Set(), salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Here is the call graph for this function:

f_inline const Vector3f salt::Matrix::operator * const Vector2f inRHS  )  const
 

multiplies the matrix with a 2 dimensional vector

Definition at line 438 of file matrix.h.

References m, salt::TVector2< DATATYPE, TYPE >::x(), and salt::TVector2< DATATYPE, TYPE >::y().

Here is the call graph for this function:

f_inline const Vector3f salt::Matrix::operator * const Vector3f inRHS  )  const
 

Multipies the matrix with a 3 dimensional vector.

Definition at line 428 of file matrix.h.

References m, salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Here is the call graph for this function:

f_inline const Matrix salt::Matrix::operator * const Matrix inRHS  )  const
 

multiplies the matrix with another matrix

Definition at line 416 of file matrix.h.

References El().

Here is the call graph for this function:

f_inline const Matrix & salt::Matrix::operator *= const Matrix inRHS  ) 
 

multiplies the matrix with another Matrix

Definition at line 447 of file matrix.h.

f_inline const float& salt::Matrix::operator() int  inRow,
int  inColumn
const [inline]
 

returns a const reference to a single element of the matrix

Definition at line 188 of file matrix.h.

f_inline float& salt::Matrix::operator() int  inRow,
int  inColumn
[inline]
 

returns a reference to a single element of the matrix

Definition at line 185 of file matrix.h.

f_inline Vector3f& salt::Matrix::Pos  )  [inline]
 

returns a reference to the pos vector of the matrix

Definition at line 135 of file matrix.h.

f_inline const Vector3f& salt::Matrix::Pos  )  const [inline]
 

returns a const reference to the pos vector of the matrix

Definition at line 132 of file matrix.h.

Referenced by oxygen::Camera::DescribeFrustum(), InvertRotationMatrix(), LookAt(), oxygen::Body::OnLink(), kerosin::Light::Prepare(), oxygen::Transform::SetLocalPos(), and oxygen::Transform::SetLocalRotation().

f_inline Vector3f& salt::Matrix::Right  )  [inline]
 

returns a reference to the right vector of the matrix

Definition at line 117 of file matrix.h.

f_inline const Vector3f& salt::Matrix::Right  )  const [inline]
 

returns a const reference to the right vector of the matrix

Definition at line 114 of file matrix.h.

Referenced by oxygen::FPSController::PrePhysicsUpdateInternal().

f_inline Vector3f salt::Matrix::Rotate const Vector3f inVector  )  const
 

rotates the matrix by inVector

Definition at line 398 of file matrix.h.

References m, salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Referenced by InvertRotationMatrix(), and LookAt().

Here is the call graph for this function:

f_inline const Matrix & salt::Matrix::RotateX float  inAngle  ) 
 

rotate the matrix around the axis X with inAngle radians

Definition at line 280 of file matrix.h.

References El(), salt::gCos(), and salt::gSin().

Referenced by oxygen::Camera::Bind(), and oxygen::FPSController::PrePhysicsUpdateInternal().

Here is the call graph for this function:

f_inline const Matrix & salt::Matrix::RotateY float  inAngle  ) 
 

Rotate the matrix around the axis Y with inAngle radians.

Definition at line 308 of file matrix.h.

References El(), salt::gCos(), and salt::gSin().

Referenced by oxygen::Transform::SetLocalRotation().

Here is the call graph for this function:

f_inline const Matrix & salt::Matrix::RotateZ float  inAngle  ) 
 

Rotate the matrix around the axis Z with inAngle radians.

Definition at line 336 of file matrix.h.

References El(), salt::gCos(), and salt::gSin().

Referenced by oxygen::Transform::SetLocalRotation().

Here is the call graph for this function:

f_inline void salt::Matrix::RotationX float  inAngle  ) 
 

sets up a X-rotation matrix with inAngle degrees

Definition at line 213 of file matrix.h.

References El(), salt::gCos(), salt::gSin(), and Identity().

Referenced by oxygen::FPSController::PrePhysicsUpdateInternal(), and oxygen::Transform::SetLocalRotation().

Here is the call graph for this function:

f_inline void salt::Matrix::RotationY float  inAngle  ) 
 

sets up a Y-rotation matrix with inAngle degrees

Definition at line 225 of file matrix.h.

References El(), salt::gCos(), salt::gSin(), and Identity().

Here is the call graph for this function:

f_inline void salt::Matrix::RotationZ float  inAngle  ) 
 

sets up a Z-rotation matrix with inAngle degrees

Definition at line 237 of file matrix.h.

References El(), salt::gCos(), salt::gSin(), and Identity().

Referenced by oxygen::FPSController::PrePhysicsUpdateInternal().

Here is the call graph for this function:

f_inline void salt::Matrix::Scale const Vector3f inVector  ) 
 

sets up a scaling matrix with inVector

Definition at line 258 of file matrix.h.

References El(), Identity(), salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Referenced by CalcSpotLight().

Here is the call graph for this function:

f_inline void salt::Matrix::Set 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
 

sets up the matrix from 16 float values

Definition at line 267 of file matrix.h.

References m.

Referenced by LookAt().

f_inline Vector3f salt::Matrix::Transform const Vector3f inVector  )  const
 

multiplies the matrix with inVector

Definition at line 388 of file matrix.h.

References m, salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Referenced by oxygen::BaseNode::GetLocalPos(), and salt::AABB3::TransformBy().

Here is the call graph for this function:

f_inline const Matrix & salt::Matrix::Translate const Vector3f inVector  ) 
 

Translate the matrix by vector inVector.

Definition at line 364 of file matrix.h.

References El(), m, salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Here is the call graph for this function:

f_inline void salt::Matrix::Translation const Vector3f inVector  ) 
 

sets up a translation matrix with inVector

Definition at line 249 of file matrix.h.

References El(), Identity(), salt::TVector3< DATATYPE, TYPE >::x(), salt::TVector3< DATATYPE, TYPE >::y(), and salt::TVector3< DATATYPE, TYPE >::z().

Referenced by CalcAttenuationNoRotation(), CalcAttenuationWithRotation(), and CalcSpotLight().

Here is the call graph for this function:

f_inline Vector3f& salt::Matrix::Up  )  [inline]
 

returns a reference to the up vector of the matrix

Definition at line 123 of file matrix.h.

f_inline const Vector3f& salt::Matrix::Up  )  const [inline]
 

returns a const reference to the up vector of the matrix

Definition at line 120 of file matrix.h.

Referenced by oxygen::FPSController::PrePhysicsUpdateInternal().


Member Data Documentation

float salt::Matrix::m[16]
 

the values of the matrix

Definition at line 46 of file matrix.h.

Referenced by oxygen::ODEObject::ConvertRotationMatrix(), oxygen::Camera::DescribeFrustum(), Dump(), InverseRotate(), IsEqual(), Matrix(), operator *(), oxygen::Body::PostPhysicsUpdateInternal(), Rotate(), Set(), salt::Frustum::Set(), Transform(), and Translate().

float Matrix::mIdentity [static, private]
 

Initial value:

{
    1.0, 0.0, 0.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    0.0, 0.0, 1.0, 0.0,
    0.0, 0.0, 0.0, 1.0
}
the identity matrix

Definition at line 199 of file matrix.h.


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:49:12 2006 for rcssserver3d by  doxygen 1.4.4