/ich/Programmieren/KazadeEngine/NeHeKazmath/kazmath/src/mat4.c File Reference

#include <memory.h>
#include <assert.h>
#include <stdlib.h>
#include "utility.h"
#include "vec3.h"
#include "mat4.h"
#include "quaternion.h"

Go to the source code of this file.

Functions

kmMat4kmMat4Fill (kmMat4 *pOut, const kmScalar *pMat)
kmMat4kmMat4Identity (kmMat4 *pOut)
kmMat4kmMat4Inverse (kmMat4 *pOut, const kmMat4 *pM)
int kmMat4IsIdentity (const kmMat4 *pIn)
kmMat4kmMat4Transpose (kmMat4 *pOut, const kmMat4 *pIn)
kmMat4kmMat4Multiply (kmMat4 *pOut, const kmMat4 *pM1, const kmMat4 *pM2)
kmMat4kmMat4Assign (kmMat4 *pOut, const kmMat4 *pIn)
int kmMat4AreEqual (const kmMat4 *pMat1, const kmMat4 *pMat2)
kmMat4kmMat4RotationAxis (kmMat4 *pOut, const kmVec3 *axis, kmScalar radians)
kmMat4kmMat4RotationX (kmMat4 *pOut, const float radians)
kmMat4kmMat4RotationY (kmMat4 *pOut, const float radians)
kmMat4kmMat4RotationZ (kmMat4 *pOut, const float radians)
kmMat4kmMat4RotationPitchYawRoll (kmMat4 *pOut, const kmScalar pitch, const kmScalar yaw, const kmScalar roll)
kmMat4kmMat4RotationQuaternion (kmMat4 *pOut, const kmQuaternion *pQ)
kmMat4kmMat4Scaling (kmMat4 *pOut, const kmScalar x, const kmScalar y, const kmScalar z)
kmMat4kmMat4Translation (kmMat4 *pOut, const kmScalar x, const kmScalar y, const kmScalar z)
kmVec3kmMat4GetUpVec3 (kmVec3 *pOut, const kmMat4 *pIn)
kmVec3kmMat4GetRightVec3 (kmVec3 *pOut, const kmMat4 *pIn)
kmVec3kmMat4GetForwardVec3 (kmVec3 *pOut, const kmMat4 *pIn)
kmMat4kmMat4PerspectiveProjection (kmMat4 *pOut, kmScalar fovY, kmScalar aspect, kmScalar zNear, kmScalar zFar)
kmMat4kmMat4OrthographicProjection (kmMat4 *pOut, kmScalar left, kmScalar right, kmScalar bottom, kmScalar top, kmScalar nearVal, kmScalar farVal)
kmMat4kmMat4LookAt (kmMat4 *pOut, const kmVec3 *pEye, const kmVec3 *pCenter, const kmVec3 *pUp)


Detailed Description

Definition in file mat4.c.


Function Documentation

int kmMat4AreEqual ( const kmMat4 pMat1,
const kmMat4 pMat2 
)

Returns KM_TRUE if the 2 matrices are equal (approximately)

Definition at line 225 of file mat4.c.

References KM_FALSE, KM_TRUE, kmEpsilon, and kmMat4::mat.

kmMat4* kmMat4Assign ( kmMat4 pOut,
const kmMat4 pIn 
)

Assigns the value of pIn to pOut

Definition at line 213 of file mat4.c.

References kmMat4::mat.

Referenced by kmGLGetMatrix().

kmMat4* kmMat4Fill ( kmMat4 pOut,
const kmScalar *  pMat 
)

Fills a kmMat4 structure with the values from a 16 element array of floats pOut - A pointer to the destination matrix pMat - A 16 element array of floats Returns pOut so that the call can be nested

Definition at line 45 of file mat4.c.

References kmScalar, and kmMat4::mat.

kmVec3* kmMat4GetForwardVec3 ( kmVec3 pOut,
const kmMat4 pIn 
) [read]

Extract the forward vector from a 4x4 matrix. The result is stored in pOut. Returns pOut.

Definition at line 515 of file mat4.c.

References kmVec3Normalize(), kmMat4::mat, kmVec3::x, kmVec3::y, and kmVec3::z.

kmVec3* kmMat4GetRightVec3 ( kmVec3 pOut,
const kmMat4 pIn 
) [read]

Extract the right vector from a 4x4 matrix. The result is stored in pOut. Returns pOut.

Definition at line 500 of file mat4.c.

References kmVec3Normalize(), kmMat4::mat, kmVec3::x, kmVec3::y, and kmVec3::z.

kmVec3* kmMat4GetUpVec3 ( kmVec3 pOut,
const kmMat4 pIn 
) [read]

Get the up vector from a matrix. pIn is the matrix you wish to extract the vector from. pOut is a pointer to the kmVec3 structure that should hold the resulting vector

Definition at line 486 of file mat4.c.

References kmVec3Normalize(), kmMat4::mat, kmVec3::x, kmVec3::y, and kmVec3::z.

kmMat4* kmMat4Identity ( kmMat4 pOut  ) 

Sets pOut to an identity matrix returns pOut pOut - A pointer to the matrix to set to identity Returns pOut so that the call can be nested

Definition at line 56 of file mat4.c.

References kmMat4::mat.

Referenced by kmGLLoadIdentity(), kmMat4Inverse(), kmMat4LookAt(), kmMat4OrthographicProjection(), kmMat4PerspectiveProjection(), and lazyInitialize().

kmMat4* kmMat4Inverse ( kmMat4 pOut,
const kmMat4 pM 
)

Calculates the inverse of pM and stores the result in pOut. Returns pOut

Definition at line 68 of file mat4.c.

References kmMat4Identity(), and kmMat4::mat.

int kmMat4IsIdentity ( const kmMat4 pIn  ) 

Returns KM_TRUE if pIn is an identity matrix KM_FALSE otherwise

Definition at line 148 of file mat4.c.

References kmMat4::mat.

kmMat4* kmMat4LookAt ( kmMat4 pOut,
const kmVec3 pEye,
const kmVec3 pCenter,
const kmVec3 pUp 
)

Builds a translation matrix in the same way as gluLookAt() the resulting matrix is stored in pOut. pOut is returned.

Definition at line 582 of file mat4.c.

References kmMat4Identity(), kmMat4Multiply(), kmMat4Translation(), kmVec3Assign(), kmVec3Cross(), kmVec3Normalize(), kmVec3Subtract(), kmMat4::mat, kmVec3::x, kmVec3::y, and kmVec3::z.

kmMat4* kmMat4Multiply ( kmMat4 pOut,
const kmMat4 pM1,
const kmMat4 pM2 
)

Multiplies pM1 with pM2, stores the result in pOut, returns pOut

Definition at line 178 of file mat4.c.

References kmMat4::mat.

Referenced by kmGLMultMatrix(), kmGLRotatef(), kmGLScalef(), and kmMat4LookAt().

kmMat4* kmMat4OrthographicProjection ( kmMat4 pOut,
kmScalar  left,
kmScalar  right,
kmScalar  bottom,
kmScalar  top,
kmScalar  nearVal,
kmScalar  farVal 
)

Creates an orthographic projection matrix like glOrtho

Definition at line 558 of file mat4.c.

References kmMat4Identity(), kmScalar, and kmMat4::mat.

kmMat4* kmMat4PerspectiveProjection ( kmMat4 pOut,
kmScalar  fovY,
kmScalar  aspect,
kmScalar  zNear,
kmScalar  zFar 
)

Creates a perspective projection matrix in the same way as gluPerspective

Definition at line 530 of file mat4.c.

References kmDegreesToRadians(), kmMat4Identity(), kmScalar, and kmMat4::mat.

kmMat4* kmMat4RotationAxis ( kmMat4 pOut,
const kmVec3 axis,
kmScalar  radians 
)

Build a rotation matrix from an axis and an angle. Result is stored in pOut. pOut is returned.

Definition at line 246 of file mat4.c.

References kmMat4::mat, kmVec3::x, kmVec3::y, and kmVec3::z.

Referenced by kmGLRotatef().

kmMat4* kmMat4RotationPitchYawRoll ( kmMat4 pOut,
const kmScalar  pitch,
const kmScalar  yaw,
const kmScalar  roll 
)

Builds a rotation matrix from pitch, yaw and roll. The resulting matrix is stored in pOut and pOut is returned

Definition at line 386 of file mat4.c.

References kmScalar, and kmMat4::mat.

kmMat4* kmMat4RotationQuaternion ( kmMat4 pOut,
const kmQuaternion pQ 
)

Converts a quaternion to a rotation matrix, the result is stored in pOut, returns pOut

Definition at line 418 of file mat4.c.

References kmMat4::mat, kmQuaternion::w, kmQuaternion::x, kmQuaternion::y, and kmQuaternion::z.

kmMat4* kmMat4RotationX ( kmMat4 pOut,
const float  radians 
)

Builds an X-axis rotation matrix and stores it in pOut, returns pOut

Definition at line 277 of file mat4.c.

References kmMat4::mat.

kmMat4* kmMat4RotationY ( kmMat4 pOut,
const float  radians 
)

Builds a rotation matrix using the rotation around the Y-axis The result is stored in pOut, pOut is returned.

Definition at line 314 of file mat4.c.

References kmMat4::mat.

kmMat4* kmMat4RotationZ ( kmMat4 pOut,
const float  radians 
)

Builds a rotation matrix around the Z-axis. The resulting matrix is stored in pOut. pOut is returned.

Definition at line 350 of file mat4.c.

References kmMat4::mat.

kmMat4* kmMat4Scaling ( kmMat4 pOut,
const kmScalar  x,
const kmScalar  y,
const kmScalar  z 
)

Builds a scaling matrix

Definition at line 447 of file mat4.c.

References kmMat4::mat.

Referenced by kmGLScalef().

kmMat4* kmMat4Translation ( kmMat4 pOut,
const kmScalar  x,
const kmScalar  y,
const kmScalar  z 
)

Builds a translation matrix. All other elements in the matrix will be set to zero except for the diagonal which is set to 1.0

Definition at line 463 of file mat4.c.

References kmMat4::mat.

Referenced by kmMat4LookAt().

kmMat4* kmMat4Transpose ( kmMat4 pOut,
const kmMat4 pIn 
)

Sets pOut to the transpose of pIn, returns pOut

Definition at line 162 of file mat4.c.

References kmMat4::mat.


Generated on Mon Dec 29 18:40:11 2008 for Kazmath by  doxygen 1.5.6