Matrix33_tpl

#include

Inherits INumberArray< F, 9 >.

Public Types

typedef INumberArray< F, 9 > NA

Public Member Functions

ILINE Matrix33_tpl (type_zero)
template
ILINE Matrix33_tpl (const Matrix33_tpl< F1 > &m)
ILINE Matrix33_tpl (type_identity)
Set matrix to Identity.
ILINE Matrix33_tpl (F x00, F x01, F x02, F x10, F x11, F x12, F x20, F x21, F x22)
implementation of the constructors More...
template
ILINE Matrix33_tpl (const Vec3_tpl< F1 > &vx, const Vec3_tpl< F1 > &vy, const Vec3_tpl< F1 > &vz)
template
ILINE Matrix33_tpl (const Diag33_tpl< F1 > &d)
template
ILINE Matrix33_tpl (const Matrix34_tpl< F1 > &m)
template
ILINE Matrix33_tpl (const Matrix44_tpl< F1 > &m)
template
ILINE Matrix33_tpl (const Quat_tpl< F1 > &q)
template
ILINE Matrix33_tpl (const Ang3_tpl< F1 > &ang)
ILINE void operator() (F x00, F x01, F x02, F x10, F x11, F x12, F x20, F x21, F x22)
ILINE void SetIdentity (void)
ILINE void SetRotationAA (F angle, const Vec3_tpl< F > axis)
ILINE void SetRotationAA (F c, F s, const Vec3_tpl< F > &axis)
ILINE void SetRotationAA (const Vec3_tpl< F > axis)
ILINE void SetRotationX (const F rad)
ILINE void SetRotationY (const F rad)
ILINE void SetRotationZ (const F rad)
ILINE void SetRotationXYZ (const Ang3_tpl< F > &rad)
ILINE void SetRotationV0V1 (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1)
ILINE void SetRotationVDir (const Vec3_tpl< F > &vdir)
ILINE void SetRotationVDir (const Vec3_tpl< F > &vdir, F roll)
Look-at matrix with roll.
ILINE void SetSlerp (const Matrix33_tpl< F > &m, const Matrix33_tpl< F > &n, F t)
ILINE void SetScale (const Vec3_tpl< F > &s)
ILINE void SetFromVectors (const Vec3_tpl< F > &vx, const Vec3_tpl< F > &vy, const Vec3_tpl< F > &vz)
ILINE void Transpose ()
In-place transposition.
ILINE Matrix33_tpl< F > GetTransposed () const
ILINE Matrix33_tpl< F > T () const
ILINE Matrix33_tpl & Fabs ()
ILINE Matrix33_tpl< F > GetFabs () const
ILINE void Adjoint (void)
ILINE Matrix33_tpl< F > GetAdjoint () const
ILINE bool Invert (void)
ILINE Matrix33_tpl< F > GetInverted () const
ILINE Vec3_tpl< F > TransformVector (const Vec3_tpl< F > &v) const
ILINE void OrthonormalizeFast ()
make a right-handed orthonormal matrix.
ILINE void orthonormalizeFastLH ()
make a left-handed orthonormal matrix.
ILINE F Determinant () const
F * GetData ()
const F * GetData () const
ILINE F operator() (uint32 i, uint32 j) const
ILINE F & operator() (uint32 i, uint32 j)
ILINE void SetRow (int i, const Vec3_tpl< F > &v)
ILINE Vec3_tpl< F > GetRow (int i) const
ILINE void SetColumn (int i, const Vec3_tpl< F > &v)
ILINE Vec3_tpl< F > GetColumn (int i) const
ILINE Vec3_tpl< F > GetColumn0 () const
ILINE Vec3_tpl< F > GetColumn1 () const
ILINE Vec3_tpl< F > GetColumn2 () const
ILINE void SetColumn0 (const Vec3_tpl< F > &v)
ILINE void SetColumn1 (const Vec3_tpl< F > &v)
ILINE void SetColumn2 (const Vec3_tpl< F > &v)
ILINE Matrix33_tpl< F > & operator*= (F op)
ILINE Matrix33_tpl< F > & operator/= (F op)
ILINE bool IsIdentity (F e) const
ILINE bool IsIdentity () const
ILINE int IsOrthonormal (F threshold=0.001) const
Check if we have an orthonormal-base (general case, works even with reflection matrices).
ILINE int IsOrthonormalRH (F threshold=0.002) const
Check if we have an orthonormal-base (assuming we are using a right-handed coordinate system).
ILINE void NoScale ()
Remove uniform scale from matrix.

Static Public Member Functions

static ILINE Matrix33_tpl< F > CreateIdentity ()
static ILINE Matrix33_tpl< F > CreateRotationAA (const F rad, const Vec3_tpl< F > &axis)
static ILINE Matrix33_tpl< F > CreateRotationAA (F c, F s, const Vec3_tpl< F > &axis)
static ILINE Matrix33_tpl< F > CreateRotationAA (const Vec3_tpl< F > &axis)
static ILINE Matrix33_tpl< F > CreateRotationX (const F rad)
static ILINE Matrix33_tpl< F > CreateRotationY (const F rad)
static ILINE Matrix33_tpl< F > CreateRotationZ (const F rad)
static ILINE Matrix33_tpl< F > CreateRotationXYZ (const Ang3_tpl< F > &rad)
static ILINE Matrix33_tpl< F > CreateRotationV0V1 (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1)
static ILINE Matrix33_tpl< F > CreateRotationVDir (const Vec3_tpl< F > vdir)
static ILINE Matrix33_tpl< F > CreateRotationVDir (const Vec3_tpl< F > &vdir, F roll)
static ILINE Matrix33_tpl< F > CreateOrthogonalBase (const Vec3 &invDirection)
static ILINE Matrix33_tpl< F > CreateOrientation (const Vec3_tpl< F > &dir, const Vec3_tpl< F > &up, float rollAngle)
static ILINE Matrix33_tpl< F > CreateSlerp (const Matrix33_tpl< F > m, const Matrix33_tpl< F > n, F t)
static ILINE Matrix33_tpl< F > CreateScale (const Vec3_tpl< F > &s)
static ILINE Matrix33_tpl< F > CreateFromVectors (const Vec3_tpl< F > &vx, const Vec3_tpl< F > &vy, const Vec3_tpl< F > &vz)

Public Attributes

F m00
F m01
F m02
F m10
F m11
F m12
F m20
F m21
F m22
AUTO_STRUCT_INFO

Detailed Description

template struct Matrix33_tpl< F >

Represents a 3x3 rotational matrix

See also
Matrix33

Constructor & Destructor Documentation

◆ Matrix33_tpl() [1/7]

template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( F x00,
F x01,
F x02,
F x10,
F x11,
F x12,
F x20,
F x21,
F x22
)
inline
explicit

implementation of the constructors

CONSTRUCTOR for identical float-types. It initializes a Matrix33 with 9 floats. Matrix33(0,1,2, 3,4,5, 6,7,8);

◆ Matrix33_tpl() [2/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Vec3_tpl< F1 > & vx,
const Vec3_tpl< F1 > & vy,
const Vec3_tpl< F1 > & vz
)
inline
explicit

CONSTRUCTOR for different float-types. It initializes a Matrix33 with 3 vectors stored in the columns and converts between floats/doubles. Matrix33r(v0,v1,v2);

◆ Matrix33_tpl() [3/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Diag33_tpl< F1 > & d)
inline

CONSTRUCTOR for different float-types. It converts a Diag33 into a Matrix33 and also converts between double/float. Matrix33(diag33);

◆ Matrix33_tpl() [4/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Matrix34_tpl< F1 > & m)
inline
explicit

CONSTRUCTOR for different float-types. It converts a Matrix34 into a Matrix33 and converts between double/float. Needs to be 'explicit' because we loose the translation vector in the conversion process. Matrix33(m34r);

◆ Matrix33_tpl() [5/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Matrix44_tpl< F1 > & m)
inline
explicit

CONSTRUCTOR for different float-types. It converts a Matrix44 into a Matrix33 and converts between double/float. Needs to be 'explicit' because we loose the translation vector and the 3rd row in the conversion process. Matrix33(m44r);

◆ Matrix33_tpl() [6/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Quat_tpl< F1 > & q)
inline
explicit

CONSTRUCTOR for different float-types. It converts a Quat into a Matrix33 and converts between double/float. Needs to be 'explicit' because we loose fp-precision in the conversion process. Matrix33(quatr);

◆ Matrix33_tpl() [7/7]

template
template
ILINE Matrix33_tpl< F >::Matrix33_tpl ( const Ang3_tpl< F1 > & ang)
inline
explicit

CONSTRUCTOR for different float-types. It converts a Euler Angle into a Matrix33 and converts between double/float. Needs to be 'explicit' because we loose fp-precision in the conversion process. Matrix33(Ang3r(1,2,3));

Member Function Documentation

◆ CreateOrthogonalBase()

template
static ILINE Matrix33_tpl Matrix33_tpl< F >::CreateOrthogonalBase ( const Vec3 & invDirection)
inline
static

Calculate 2 vector that form a orthogonal base with a given input vector (by M.M.).

Parameters
invDirectioninput direction (has to be normalized)
outvAfirst output vector that is perpendicular to the input direction
outvBsecond output vector that is perpendicular the input vector and the first output vector

◆ Invert()

template
ILINE bool Matrix33_tpl< F >::Invert ( void )
inline

Calculate a real inversion of a Matrix33. An inverse-matrix is an UnDo-matrix for all kind of transformations.

Note
If the return value of Invert33() is zero, then the inversion failed! Example 1: Matrix33 im33; bool st=i33.Invert(); assert(st); Example 2: matrix33 im33=Matrix33::GetInverted(m33);

◆ operator()()

template
ILINE void Matrix33_tpl< F >::operator() ( F x00,
F x01,
F x02,
F x10,
F x11,
F x12,
F x20,
F x21,
F x22
)
inline

Bracket OPERATOR: initializes a Matrix33 with 9 floats. Matrix33 m; m(0,1,2, 3,4,5, 6,7,8);

◆ SetFromVectors()

template
ILINE void Matrix33_tpl< F >::SetFromVectors ( const Vec3_tpl< F > & vx,
const Vec3_tpl< F > & vy,
const Vec3_tpl< F > & vz
)
inline
Note
All vectors are stored in columns.

◆ SetRotationAA()

template
ILINE void Matrix33_tpl< F >::SetRotationAA ( F angle,
const Vec3_tpl< F > axis
)
inline

Create a rotation matrix around an arbitrary axis (Eulers Theorem). The axis is specified as a normalized Vec3. The angle is assumed to be in radians. Example: Matrix34 m34; Vec3 axis=GetNormalized( Vec3(-1.0f,-0.3f,0.0f) ); m34.SetRotationAA( rad, axis );

◆ SetRotationV0V1()

template
ILINE void Matrix33_tpl< F >::SetRotationV0V1 ( const Vec3_tpl< F > & v0,
const Vec3_tpl< F > & v1
)
inline

Creates a rotation matrix that rotates the vector "v0" into "v1". If both vectors are exactly parallel it returns an identity-matrix. CAUTION: If both vectors are exactly diametrical it returns a matrix that rotates pi-radians about a "random" axis that is orthogonal to v0. CAUTION: If both vectors are almost diametrical we have to normalize a very small vector and the result is inaccurate. It is recommended to use this function with 64-bit precision.

◆ SetRotationVDir()

template
ILINE void Matrix33_tpl< F >::SetRotationVDir ( const Vec3_tpl< F > & vdir)
inline

Given a view-direction and a radiant to rotate about Y-axis, this function builds a 3x3 look-at matrix using only simple vector arithmetic. This function is always using the implicit up-vector Vec3(0,0,1). The view-direction is always stored in column(1). IMPORTANT: The view-vector is assumed to be normalized, because all trig-values for the orientation are being extracted directly out of the vector. This function must NOT be called with a view-direction that is close to Vec3(0,0,1) or Vec3(0,0,-1). If one of these rules is broken, the function returns a matrix with an undefined rotation about the Z-axis.

Rotation order for the look-at-matrix is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL) Example: Matrix33 orientation=Matrix33::CreateRotationVDir( Vec3(0,1,0), 0 );

COORDINATE-SYSTEM

z-axis ^ | | y-axis | / | / |/ +------------—> x-axis

Parameters
vdirnormalized view direction.
rollradiant to rotate about Y-axis.

◆ SetRotationX()

template
ILINE void Matrix33_tpl< F >::SetRotationX ( const F rad)
inline

Create rotation-matrix about X axis using an angle. The angle is assumed to be in radians. Example: Matrix m33; m33.SetRotationX(0.5f);

◆ SetSlerp()

template
ILINE void Matrix33_tpl< F >::SetSlerp ( const Matrix33_tpl< F > & m,
const Matrix33_tpl< F > & n,
F t
)
inline

Direct-Matrix-Slerp: for the sake of completeness, I have included the following expression for Spherical-Linear-Interpolation without using quaternions. This is much faster then converting both matrices into quaternions in order to do a quaternion slerp and then converting the slerped quaternion back into a matrix. This is a high-precision calculation. Given two orthonormal 3x3 matrices this function calculates the shortest possible interpolation-path between the two rotations. The interpolation curve forms a great arc on the rotation sphere (geodesic). Not only does Slerp follow a great arc it follows the shortest great arc. Furthermore Slerp has constant angular velocity. All in all Slerp is the optimal interpolation curve between two rotations.

STABILITY PROBLEM: There are two singularities at angle=0 and angle=PI. At 0 the interpolation-axis is arbitrary, which means any axis will produce the same result because we have no rotation. Thats why I'm using (1,0,0). At PI the rotations point away from each other and the interpolation-axis is unpredictable. In this case I'm also using the axis (1,0,0). If the angle is ~0 or ~PI, then we have to normalize a very small vector and this can cause numerical instability. The quaternion-slerp has exactly the same problems. Example: Matrix33 slerp=Matrix33::CreateSlerp( m,n,0.333f );