40 #ifndef _matrix4x4_cpp
41 #define _matrix4x4_cpp
43 #include "matrix4x4.h"
44 #include "MathTools/mathtools.h"
48 #include <OgreMatrix3.h>
49 #include <OgreMatrix4.h>
61 { this->
SetValues(XX,XY,XZ,XW,YX,YY,YZ,YW,ZX,ZY,ZZ,ZW,WX,WY,WZ,WW); }
152 this->
Matrix[0][0] = temp[0][0]; this->
Matrix[0][1] = temp[0][1]; this->
Matrix[0][2] = temp[0][2]; this->
Matrix[0][3] = temp[0][3];
153 this->
Matrix[1][0] = temp[1][0]; this->
Matrix[1][1] = temp[1][1]; this->
Matrix[1][2] = temp[1][2]; this->
Matrix[1][3] = temp[1][3];
154 this->
Matrix[2][0] = temp[2][0]; this->
Matrix[2][1] = temp[2][1]; this->
Matrix[2][2] = temp[2][2]; this->
Matrix[2][3] = temp[2][3];
155 this->
Matrix[3][0] = temp[3][0]; this->
Matrix[3][1] = temp[3][1]; this->
Matrix[3][2] = temp[3][2]; this->
Matrix[3][3] = temp[3][3];
171 for(
Whole Row = 0 ; Row < 4 ; ++Row )
173 for(
Whole Col = 0 ; Col < 4 ; ++Col )
184 for(
Whole Row = 0 ; Row < 4 ; ++Row )
186 for(
Whole Col = 0 ; Col < 4 ; ++Col )
332 Scalar * this->
Matrix[0][0], Scalar * this->Matrix[0][1], Scalar * this->Matrix[0][2], Scalar * this->Matrix[0][3],
333 Scalar * this->Matrix[1][0], Scalar * this->Matrix[1][1], Scalar * this->Matrix[1][2], Scalar * this->Matrix[1][3],
334 Scalar * this->Matrix[2][0], Scalar * this->Matrix[2][1], Scalar * this->Matrix[2][2], Scalar * this->Matrix[2][3],
335 Scalar * this->Matrix[3][0], Scalar * this->Matrix[3][1], Scalar * this->Matrix[3][2], Scalar * this->Matrix[3][3]);
340 this->
Matrix[0][0] *= Scalar; this->
Matrix[0][1] *= Scalar; this->
Matrix[0][2] *= Scalar; this->
Matrix[0][3] *= Scalar;
341 this->
Matrix[1][0] *= Scalar; this->
Matrix[1][1] *= Scalar; this->
Matrix[1][2] *= Scalar; this->
Matrix[1][3] *= Scalar;
342 this->
Matrix[2][0] *= Scalar; this->
Matrix[2][1] *= Scalar; this->
Matrix[2][2] *= Scalar; this->
Matrix[2][3] *= Scalar;
343 this->
Matrix[3][0] *= Scalar; this->
Matrix[3][1] *= Scalar; this->
Matrix[3][2] *= Scalar; this->
Matrix[3][3] *= Scalar;
352 for(
Whole Row = 0 ; Row < 4 ; ++Row )
354 for(
Whole Col = 0 ; Col < 4 ; ++Col )
381 return Matrix4x4(
Minor(1,2,3,1,2,3),-
Minor(0,2,3,1,2,3),
Minor(0,1,3,1,2,3),-
Minor(0,1,2,1,2,3),
382 -
Minor(1,2,3,0,2,3),
Minor(0,2,3,0,2,3),-
Minor(0,1,3,0,2,3),
Minor(0,1,2,0,2,3),
383 Minor(1,2,3,0,1,3),-
Minor(0,2,3,0,1,3),
Minor(0,1,3,0,1,3),-
Minor(0,1,2,0,1,3),
384 -
Minor(1,2,3,0,1,2),
Minor(0,2,3,0,1,2),-
Minor(0,1,3,0,1,2),
Minor(0,1,2,0,1,2));
394 Real v0 = m20 * m31 - m21 * m30;
395 Real v1 = m20 * m32 - m22 * m30;
396 Real v2 = m20 * m33 - m23 * m30;
397 Real v3 = m21 * m32 - m22 * m31;
398 Real v4 = m21 * m33 - m23 * m31;
399 Real v5 = m22 * m33 - m23 * m32;
401 Real t00 = + (v5 * m11 - v4 * m12 + v3 * m13);
402 Real t10 = - (v5 * m10 - v2 * m12 + v1 * m13);
403 Real t20 = + (v4 * m10 - v2 * m11 + v0 * m13);
404 Real t30 = - (v3 * m10 - v1 * m11 + v0 * m12);
406 Real invDet = 1 / (t00 * m00 + t10 * m01 + t20 * m02 + t30 * m03);
408 Real d00 = t00 * invDet;
409 Real d10 = t10 * invDet;
410 Real d20 = t20 * invDet;
411 Real d30 = t30 * invDet;
413 Real d01 = - (v5 * m01 - v4 * m02 + v3 * m03) * invDet;
414 Real d11 = + (v5 * m00 - v2 * m02 + v1 * m03) * invDet;
415 Real d21 = - (v4 * m00 - v2 * m01 + v0 * m03) * invDet;
416 Real d31 = + (v3 * m00 - v1 * m01 + v0 * m02) * invDet;
418 v0 = m10 * m31 - m11 * m30;
419 v1 = m10 * m32 - m12 * m30;
420 v2 = m10 * m33 - m13 * m30;
421 v3 = m11 * m32 - m12 * m31;
422 v4 = m11 * m33 - m13 * m31;
423 v5 = m12 * m33 - m13 * m32;
425 Real d02 = + (v5 * m01 - v4 * m02 + v3 * m03) * invDet;
426 Real d12 = - (v5 * m00 - v2 * m02 + v1 * m03) * invDet;
427 Real d22 = + (v4 * m00 - v2 * m01 + v0 * m03) * invDet;
428 Real d32 = - (v3 * m00 - v1 * m01 + v0 * m02) * invDet;
430 v0 = m21 * m10 - m20 * m11;
431 v1 = m22 * m10 - m20 * m12;
432 v2 = m23 * m10 - m20 * m13;
433 v3 = m22 * m11 - m21 * m12;
434 v4 = m23 * m11 - m21 * m13;
435 v5 = m23 * m12 - m22 * m13;
437 Real d03 = - (v5 * m01 - v4 * m02 + v3 * m03) * invDet;
438 Real d13 = + (v5 * m00 - v2 * m02 + v1 * m03) * invDet;
439 Real d23 = - (v4 * m00 - v2 * m01 + v0 * m03) * invDet;
440 Real d33 = + (v3 * m00 - v1 * m01 + v0 * m02) * invDet;
519 if( !CurrAttrib.
Empty() )
523 if( !CurrAttrib.
Empty() )
527 if( !CurrAttrib.
Empty() )
531 if( !CurrAttrib.
Empty() )
535 if( !CurrAttrib.
Empty() )
539 if( !CurrAttrib.
Empty() )
543 if( !CurrAttrib.
Empty() )
547 if( !CurrAttrib.
Empty() )
551 if( !CurrAttrib.
Empty() )
555 if( !CurrAttrib.
Empty() )
559 if( !CurrAttrib.
Empty() )
563 if( !CurrAttrib.
Empty() )
567 if( !CurrAttrib.
Empty() )
571 if( !CurrAttrib.
Empty() )
575 if( !CurrAttrib.
Empty() )
579 if( !CurrAttrib.
Empty() )
Ogre::Matrix4 GetOgreMatrix4x4() const
Gets an Ogre copy of this Matrix4x4.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
void SetValues(const Real &XX, const Real &XY, const Real &XZ, const Real &XW, const Real &YX, const Real &YY, const Real &YZ, const Real &YW, const Real &ZX, const Real &ZY, const Real &ZZ, const Real &ZW, const Real &WX, const Real &WY, const Real &WZ, const Real &WW)
Sets the values for every number in the matrix.
This is a 3x3 Matrix class used for representing rotations and scaling in an object.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
bool Boole
Generally acts a single bit, true or false.
void SetIdentity()
Sets all values in this Matrix to Identity values.
Real X
Coordinate on the X vector.
Matrix4x4 Transpose() const
Gets the Transpose of this Matrix.
Real Z
Coordinate on the Z vector.
Quaternion GetRotationAsQuaternion() const
Gets the rotation portion of this Matrix as a Quaternion.
Matrix3x3 GetRotationAsMatrix3x3() const
Gets the rotation portion of this Matrix as a Matrix3x3.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Matrix4x4()
Non-Initialization constructor.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
A 4x4 matrix math class for the representation of full transforms.
Real GetDeterminant() const
Gets the Determinant of this Matrix.
Quaternion GetAsQuaternion() const
Gets this Matrix as a Quaternion.
Boole operator!=(const Matrix4x4 &Other) const
Inequality comparison operator.
Boole operator==(const Matrix4x4 &Other) const
Equality comparison operator.
Matrix4x4 Concatenate(const Matrix4x4 &Mat) const
Combines the translation/rotation of two Matricies.
Matrix4x4 & operator+=(const Matrix4x4 &Other)
Addition Assignment operator.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
Matrix4x4 & operator-=(const Matrix4x4 &Other)
Subtraction Assignment operator.
void operator=(const Matrix4x4 &Other)
Assignment operator.
Matrix4x4 operator-(const Matrix4x4 &Other) const
Subtraction operator.
A light-weight handle for manipulating nodes in DOM tree.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
Real Minor(const Whole &Row1, const Whole &Row2, const Whole &Row3, const Whole &Col1, const Whole &Col2, const Whole &Col3) const
Gets the Minor of the specified rows/columns of this Matrix.
bool Empty() const
Is this storing anything at all?
~Matrix4x4()
Class destructor.
Real Matrix[3][3]
The Matrix. Fo' Reals.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
Real Y
Coordinate on the Y vector.
Matrix4x4 & operator*=(const Matrix4x4 &Other)
Multiplication Assignment operator.
Real Matrix[4][4]
The bigger Matrix. Fo' Reals.
Matrix4x4 operator*(const Matrix4x4 &Other) const
Multiplication operator.
Thrown when the identity string wasn't valid at all.
This is used to represent a point in space, or a vector through space.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Matrix4x4 operator+(const Matrix4x4 &Other) const
Addition operator.
void SetZero()
Sets all values in this Matrix to zero.
Matrix4x4 Inverse() const
Gets the Inverse of this Matrix.
Matrix4x4 Adjoint() const
Gets the Adjoint of this Matrix.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
This is used to store information about rotation in 3d space.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
void SetTransform(const Vector3 &Position, const Vector3 &Scale, const Quaternion &Rotation)
Sets the Matrix based on a provided position, scale, and rotation.
void ExtractOgreMatrix4x4(const Ogre::Matrix4 &temp)
Gets the data from an Ogre Matrix4x4 and applies it to this.