LightsprintSDK 2021.08.08
rr::RRMatrix3x4 Struct Reference

#include <RRMath.h>

Inheritance diagram for rr::RRMatrix3x4:
rr::RRMatrix3x4Ex

Public Member Functions

 RRMatrix3x4 ()
 
 RRMatrix3x4 (const float *m3x4, bool transposed)
 
 RRMatrix3x4 (const double *m3x4, bool transposed)
 
 RRMatrix3x4 (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23)
 
 RRMatrix3x4 (double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23)
 
void transformPosition (RRVec3 &a) const
 
RRVec3 getTransformedPosition (const RRVec3 &a) const
 
void transformDirection (RRVec3 &a) const
 
RRVec3 getTransformedDirection (const RRVec3 &a) const
 
bool operator== (const RRMatrix3x4 &a) const
 
bool operator!= (const RRMatrix3x4 &a) const
 
RRMatrix3x4 operator* (const RRMatrix3x4 &a) const
 
RRMatrix3x4operator*= (const RRMatrix3x4 &a)
 
bool isIdentity () const
 
RRVec3 getTranslation () const
 
void setTranslation (const RRVec3 &a)
 
void postTranslate (const RRVec3 &a)
 
RRMatrix3x4 centeredAround (const RRVec3 &center) const
 
RRVec3 getScale () const
 
void preScale (const RRVec3 &a)
 
RRVec3 getYawPitchRoll () const
 
RRVec4 getAxisAngle () const
 
RRVec4 getQuaternion () const
 
RRVec3 getColumn (unsigned i) const
 
RRVec4 getRow (unsigned i) const
 
void setColumn (unsigned i, const RRVec3 &column)
 
void setRow (unsigned i, const RRVec4 &row)
 
RRReal determinant3x3 () const
 
bool invertedTo (RRMatrix3x4 &destination) const
 
void blendLinear (const RRMatrix3x4 &sample0, const RRMatrix3x4 &sample1, RRReal blend)
 
void blendAkima (unsigned numSamples, const RRMatrix3x4 **samples, const RRReal *times, RRReal time)
 

Static Public Member Functions

static RRMatrix3x4 identity ()
 
static RRMatrix3x4 scale (const RRVec3 &scale)
 
static RRMatrix3x4 translation (const RRVec3 &translation)
 
static RRMatrix3x4 rotationByYawPitchRoll (const RRVec3 &yawPitchRollRad)
 
static RRMatrix3x4 rotationByAxisAngle (const RRVec3 &rotationAxis, RRReal rotationAngleRad)
 
static RRMatrix3x4 rotationByQuaternion (const RRVec4 &quaternion)
 
static RRMatrix3x4 mirror (const RRVec4 &plane)
 

Public Attributes

RRReal m [3][4]
 

Detailed Description

Matrix of 3x4 real numbers in row-major order.

Translation is stored in m[x][3]. Rotation and scale in the rest.

We have chosen this format because it contains only what we need, is smaller than 4x4 and its shape makes no room for row or column major ambiguity.

Decomposition functions assume that matrix was composed from (in this order): scale, rotation and translation; so when composing matrices for later decomposition, use either m = translation() * rotationByYawPitchRoll() * scale(); or slightly faster but otherwise identical m = rotationByYawPitchRoll(); m.preScale(); m.postTranslate();

Constructor & Destructor Documentation

◆ RRMatrix3x4() [1/5]

rr::RRMatrix3x4::RRMatrix3x4 ( )

◆ RRMatrix3x4() [2/5]

rr::RRMatrix3x4::RRMatrix3x4 ( const float *  m3x4,
bool  transposed 
)

◆ RRMatrix3x4() [3/5]

rr::RRMatrix3x4::RRMatrix3x4 ( const double *  m3x4,
bool  transposed 
)

◆ RRMatrix3x4() [4/5]

rr::RRMatrix3x4::RRMatrix3x4 ( float  m00,
float  m01,
float  m02,
float  m03,
float  m10,
float  m11,
float  m12,
float  m13,
float  m20,
float  m21,
float  m22,
float  m23 
)

◆ RRMatrix3x4() [5/5]

rr::RRMatrix3x4::RRMatrix3x4 ( double  m00,
double  m01,
double  m02,
double  m03,
double  m10,
double  m11,
double  m12,
double  m13,
double  m20,
double  m21,
double  m22,
double  m23 
)

Member Function Documentation

◆ identity()

static RRMatrix3x4 rr::RRMatrix3x4::identity ( )
static

◆ scale()

static RRMatrix3x4 rr::RRMatrix3x4::scale ( const RRVec3 scale)
static

◆ translation()

static RRMatrix3x4 rr::RRMatrix3x4::translation ( const RRVec3 translation)
static

◆ rotationByYawPitchRoll()

static RRMatrix3x4 rr::RRMatrix3x4::rotationByYawPitchRoll ( const RRVec3 yawPitchRollRad)
static

Yaw + Pitch + Roll = YXZ Euler angles as defined at http://en.wikipedia.org/wiki/Euler_angles.

◆ rotationByAxisAngle()

static RRMatrix3x4 rr::RRMatrix3x4::rotationByAxisAngle ( const RRVec3 rotationAxis,
RRReal  rotationAngleRad 
)
static

◆ rotationByQuaternion()

static RRMatrix3x4 rr::RRMatrix3x4::rotationByQuaternion ( const RRVec4 quaternion)
static

Expects normalized quaternion.

◆ mirror()

static RRMatrix3x4 rr::RRMatrix3x4::mirror ( const RRVec4 plane)
static

◆ transformPosition()

void rr::RRMatrix3x4::transformPosition ( RRVec3 a) const

Transforms position in 3d space by matrix.

◆ getTransformedPosition()

RRVec3 rr::RRMatrix3x4::getTransformedPosition ( const RRVec3 a) const

Returns position in 3d space transformed by matrix.

◆ transformDirection()

void rr::RRMatrix3x4::transformDirection ( RRVec3 a) const

Transforms direction in 3d space by matrix.

◆ getTransformedDirection()

RRVec3 rr::RRMatrix3x4::getTransformedDirection ( const RRVec3 a) const

Returns direction in 3d space transformed by matrix.

◆ operator==()

bool rr::RRMatrix3x4::operator== ( const RRMatrix3x4 a) const

◆ operator!=()

bool rr::RRMatrix3x4::operator!= ( const RRMatrix3x4 a) const

◆ operator*()

RRMatrix3x4 rr::RRMatrix3x4::operator* ( const RRMatrix3x4 a) const

A*B returns matrix that performs transformation B, then A.

◆ operator*=()

RRMatrix3x4 & rr::RRMatrix3x4::operator*= ( const RRMatrix3x4 a)

A*=B adds transformation B at the beginning of transformations defined by A. If you want B at the end, do A=B*A;.

◆ isIdentity()

bool rr::RRMatrix3x4::isIdentity ( ) const

Tests whether matrix is identity.

◆ getTranslation()

RRVec3 rr::RRMatrix3x4::getTranslation ( ) const

Returns translation component of matrix.

◆ setTranslation()

void rr::RRMatrix3x4::setTranslation ( const RRVec3 a)

Sets translation component of matrix.

◆ postTranslate()

void rr::RRMatrix3x4::postTranslate ( const RRVec3 a)

Applies translation on top of other transformations defined by this matrix, optimized *this=translation(a)**this;.

◆ centeredAround()

RRMatrix3x4 rr::RRMatrix3x4::centeredAround ( const RRVec3 center) const

Returns the same transformation with pretranslation -center and posttranslation +center.

◆ getScale()

RRVec3 rr::RRMatrix3x4::getScale ( ) const

Returns scale component of matrix. Negative scale is supported. Use getScale().abs().avg() for absolute uniform scale.

◆ preScale()

void rr::RRMatrix3x4::preScale ( const RRVec3 a)

Applies scale before other transformations defined by this matrix; optimized this=scale(a);.

◆ getYawPitchRoll()

RRVec3 rr::RRMatrix3x4::getYawPitchRoll ( ) const

Returns rotation component of matrix as Yaw, Pitch and Roll = YXZ Euler angles as defined at http://en.wikipedia.org/wiki/Euler_angles.

Works for matrices that represent scale, rotation and translation (in this order) of rigid body, result is undefined for non-orthogonal matrices.

Yaw and roll are in -pi..pi range, pitch is in -pi/2..pi/2 range.

◆ getAxisAngle()

RRVec4 rr::RRMatrix3x4::getAxisAngle ( ) const

Returns rotation component of matrix as rotation axis (xyz) and rotation angle in radians (w) .

◆ getQuaternion()

RRVec4 rr::RRMatrix3x4::getQuaternion ( ) const

Returns rotation component of matrix as normalized quaternion.

◆ getColumn()

RRVec3 rr::RRMatrix3x4::getColumn ( unsigned  i) const

Returns i-th matrix column, for i=0,1,2,3.

◆ getRow()

RRVec4 rr::RRMatrix3x4::getRow ( unsigned  i) const

Returns i-th matrix row, for i=0,1,2.

◆ setColumn()

void rr::RRMatrix3x4::setColumn ( unsigned  i,
const RRVec3 column 
)

Sets i-th matrix column, for i=0,1,2,3.

◆ setRow()

void rr::RRMatrix3x4::setRow ( unsigned  i,
const RRVec4 row 
)

Sets i-th matrix row, for i=0,1,2.

◆ determinant3x3()

RRReal rr::RRMatrix3x4::determinant3x3 ( ) const

Returns determinant of first 3x3 elements.

◆ invertedTo()

bool rr::RRMatrix3x4::invertedTo ( RRMatrix3x4 destination) const

Inverts matrix. Returns false in case of failure, not changing destination.

◆ blendLinear()

void rr::RRMatrix3x4::blendLinear ( const RRMatrix3x4 sample0,
const RRMatrix3x4 sample1,
RRReal  blend 
)

Fills this with linear interpolation of two samples; sample0 if blend=0, sample1 if blend=1.

◆ blendAkima()

void rr::RRMatrix3x4::blendAkima ( unsigned  numSamples,
const RRMatrix3x4 **  samples,
const RRReal times,
RRReal  time 
)

Fills this with Akima interpolation of samples, non uniformly scattered on time scale.

Parameters
numSamplesNumber of elements in samples and times arrays. Interpolations uses at most 3 preceding and 3 following samples, providing more does not increase quality.
samplesPointers to numSamples samples.
timesArray of times assigned to samples.
timeTime assigned to sample generated by this function.

Member Data Documentation

◆ m

RRReal rr::RRMatrix3x4::m[3][4]

Direct access to matrix data.