Panda3D
Classes | Public Member Functions | Static Public Member Functions

Mat3 Class Reference

This is a 3-by-3 transform matrix. More...

List of all members.

Classes

class  CRow
class  Row

Public Member Functions

 Mat3 ()
 Mat3 (Mat3 const other)
 Mat3 (float e00, float e01, float e02, float e10, float e11, float e12, float e20, float e21, float e22)
unsigned int addHash (unsigned int hash)
 Adds the vector into the running hash.
unsigned int addHash (unsigned int hash, float threshold)
 Adds the vector into the running hash.
bool almostEqual (Mat3 const other)
 Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type.
bool almostEqual (Mat3 const other, float threshold)
 Returns true if two matrices are memberwise equal within a specified tolerance.
int compareTo (Mat3 const other, float threshold)
 Sorts matrices lexicographically, componentwise.
int compareTo (Mat3 const other)
 This flavor of compare_to uses a default threshold value based on the numeric type.
float determinant ()
 Returns the determinant of the matrix.
 fill (float fill_value)
 Sets each element of the matrix to the indicated fill_value.
float getCell (int row, int col)
 Returns a particular element of the matrix.
VBase3 getCol (int col)
 Returns the indicated column of the matrix as a three-component vector.
VBase2 getCol2 (int col)
 Returns the indicated column of the matrix as a two-component vector, ignoring the last row.
list getCol2s ()
list getCols ()
 getData ()
 Returns the address of the first of the nine data elements in the matrix.
unsigned int getHash ()
 Returns a suitable hash for phash_map.
unsigned int getHash (float threshold)
 Returns a suitable hash for phash_map.
int getNumComponents ()
 Returns the number of elements in the matrix, nine.
 getRow (VBase3 result_vec, int row)
VBase3 getRow (int row)
 Returns the indicated row of the matrix as a three-component vector.
VBase2 getRow2 (int row)
 Returns the indicated row of the matrix as a two-component vector, ignoring the last column.
list getRow2s ()
list getRows ()
bool invertFrom (Mat3 const other)
 Computes the inverse of the other matrix, and stores the result in this matrix.
bool invertInPlace ()
 Inverts the current matrix.
bool invertTransposeFrom (Mat3 const other)
 Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.
bool invertTransposeFrom (Mat4 const other)
 Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.
bool isNan ()
 Returns true if any component of the matrix is not-a-number, false otherwise.
 multiply (Mat3 const other1, Mat3 const other2)
 operator new (unsigned int size)
bool operator!= (Mat3 const other)
 operator() (int row, int col)
float operator() (int row, int col)
Mat3 operator* (Mat3 const other)
Mat3 operator* (float scalar)
Mat3 operator*= (Mat3 const other)
Mat3 operator*= (float scalar)
 Performs a memberwise scale.
Mat3 operator+= (Mat3 const other)
 Performs a memberwise addition between two matrices.
Mat3 operator-= (Mat3 const other)
 Performs a memberwise subtraction between two matrices.
Mat3 operator/ (float scalar)
Mat3 operator/= (float scalar)
 Performs a memberwise scale.
bool operator< (Mat3 const other)
 This performs a lexicographical comparison.
Mat3 operator= (Mat3 const other)
Mat3 operator= (float fill_value)
bool operator== (Mat3 const other)
Row operator[] (int i)
CRow operator[] (int i)
 output (ostream out)
 pythonRepr (ostream out, string class_name)
PyObject reduce (PyObject self)
 This special Python method is implement to provide support for the pickle module.
 set (float e00, float e01, float e02, float e10, float e11, float e12, float e20, float e21, float e22)
 setCell (int row, int col, float value)
 Changes a particular element of the matrix.
 setCol (int col, VBase2 const v)
 Replaces the indicated column of the matrix from a two-component vector, ignoring the last row.
 setCol (int col, VBase3 const v)
 Replaces the indicated column of the matrix from a three-component vector.
 setRotateMat (float angle, VBase3 axis, CoordinateSystem cs)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMat (float angle)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise.
 setRotateMat (float angle, VBase3 axis)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMatNormaxis (float angle, VBase3 const axis)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMatNormaxis (float angle, VBase3 const axis, CoordinateSystem cs)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRow (int row, VBase2 const v)
 Replaces the indicated row of the matrix from a two-component vector, ignoring the last column.
 setRow (int row, VBase3 const v)
 Replaces the indicated row of the matrix from a three-component vector.
 setScaleMat (VBase3 const scale)
 Fills mat with a matrix that applies the indicated scale in each of the three axes.
 setScaleMat (VBase2 const scale)
 Fills mat with a matrix that applies the indicated scale in each of the two axes.
 setScaleShearMat (VBase3 const scale, VBase3 const shear)
 Fills mat with a matrix that applies the indicated scale and shear.
 setScaleShearMat (VBase3 const scale, VBase3 const shear, CoordinateSystem cs)
 Fills mat with a matrix that applies the indicated scale and shear.
 setShearMat (VBase3 const shear, CoordinateSystem cs)
 Fills mat with a matrix that applies the indicated shear in each of the three planes.
 setShearMat (VBase3 const shear)
 Fills mat with a matrix that applies the indicated shear in each of the three planes.
 setTranslateMat (VBase2 const trans)
 Fills mat with a matrix that applies the indicated translation.
 transposeFrom (Mat3 const other)
 transposeInPlace ()
 write (ostream out)
 write (ostream out, int indent_level)
VBase3 xform (VBase3 const v)
 3-component vector or point times matrix.
VBase2 xformPoint (VBase2 const v)
 The matrix transforms a 2-component point (including translation component) and returns the result.
VBase2 xformVec (VBase2 const v)
 The matrix transforms a 2-component vector (without translation component) and returns the result.
VBase3 xformVec (VBase3 const v)
 The matrix transforms a 3-component vector and returns the result.
VBase3 xformVecGeneral (VBase3 const v)
 The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation.

Static Public Member Functions

static Mat3 const convertMat (CoordinateSystem from, CoordinateSystem to)
 Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system.
static TypeHandle getClassType ()
static Mat3 const identMat ()
 Returns an identity matrix.
static Mat3 rotateMat (float angle)
 Returns a matrix that rotates by the given angle in degrees counterclockwise.
static Mat3 rotateMat (float angle, VBase3 axis, CoordinateSystem cs)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3 rotateMat (float angle, VBase3 axis)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3 rotateMatNormaxis (float angle, VBase3 const axis, CoordinateSystem cs)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3 rotateMatNormaxis (float angle, VBase3 const axis)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3 scaleMat (VBase2 const scale)
 Returns a matrix that applies the indicated scale in each of the two axes.
static Mat3 scaleMat (VBase3 const scale)
 Returns a matrix that applies the indicated scale in each of the three axes.
static Mat3 scaleMat (float sx, float sy, float sz)
 Returns a matrix that applies the indicated scale in each of the three axes.
static Mat3 scaleMat (float sx, float sy)
 Returns a matrix that applies the indicated scale in each of the two axes.
static Mat3 scaleShearMat (float sx, float sy, float sz, float shxy, float shxz, float shyz)
 Returns a matrix that applies the indicated scale and shear.
static Mat3 scaleShearMat (float sx, float sy, float sz, float shxy, float shxz, float shyz, CoordinateSystem cs)
 Returns a matrix that applies the indicated scale and shear.
static Mat3 scaleShearMat (VBase3 const scale, VBase3 const shear, CoordinateSystem cs)
 Returns a matrix that applies the indicated scale and shear.
static Mat3 scaleShearMat (VBase3 const scale, VBase3 const shear)
 Returns a matrix that applies the indicated scale and shear.
static Mat3 shearMat (float shxy, float shxz, float shyz)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3 shearMat (float shxy, float shxz, float shyz, CoordinateSystem cs)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3 shearMat (VBase3 const shear)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3 shearMat (VBase3 const shear, CoordinateSystem cs)
 Returns a matrix that applies the indicated shear in each of the three planes.
static int size ()
 Returns 3: the number of rows of a LMatrix3.
static Mat3 translateMat (float tx, float ty)
 Returns a matrix that applies the indicated translation.
static Mat3 translateMat (VBase2 const trans)
 Returns a matrix that applies the indicated translation.

Detailed Description

This is a 3-by-3 transform matrix.

It typically will represent either a rotation-and-scale (no translation) matrix in 3-d, or a full affine matrix (rotation, scale, translation) in 2-d, e.g. for a texture matrix.


Constructor & Destructor Documentation

Mat3 ( )
Mat3 ( Mat3 const  other)
Mat3 ( float  e00,
float  e01,
float  e02,
float  e10,
float  e11,
float  e12,
float  e20,
float  e21,
float  e22 
)

Member Function Documentation

unsigned int addHash ( unsigned int  hash)

Adds the vector into the running hash.

unsigned int addHash ( unsigned int  hash,
float  threshold 
)

Adds the vector into the running hash.

bool almostEqual ( Mat3 const  other)

Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type.

bool almostEqual ( Mat3 const  other,
float  threshold 
)

Returns true if two matrices are memberwise equal within a specified tolerance.

int compareTo ( Mat3 const  other)

This flavor of compare_to uses a default threshold value based on the numeric type.

int compareTo ( Mat3 const  other,
float  threshold 
)

Sorts matrices lexicographically, componentwise.

Returns a number less than 0 if this matrix sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent (within the indicated tolerance).

static Mat3 const convertMat ( CoordinateSystem  from,
CoordinateSystem  to 
) [static]

Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system.

float determinant ( )

Returns the determinant of the matrix.

fill ( float  fill_value)

Sets each element of the matrix to the indicated fill_value.

This is of questionable value, but is sometimes useful when initializing to zero.

float getCell ( int  row,
int  col 
)

Returns a particular element of the matrix.

static TypeHandle getClassType ( ) [static]
VBase3 getCol ( int  col)

Returns the indicated column of the matrix as a three-component vector.

VBase2 getCol2 ( int  col)

Returns the indicated column of the matrix as a two-component vector, ignoring the last row.

list getCol2s ( )
list getCols ( )
getData ( )

Returns the address of the first of the nine data elements in the matrix.

The remaining elements occupy the next eight positions in row-major order.

unsigned int getHash ( float  threshold)

Returns a suitable hash for phash_map.

unsigned int getHash ( )

Returns a suitable hash for phash_map.

int getNumComponents ( )

Returns the number of elements in the matrix, nine.

getRow ( VBase3  result_vec,
int  row 
)
VBase3 getRow ( int  row)

Returns the indicated row of the matrix as a three-component vector.

VBase2 getRow2 ( int  row)

Returns the indicated row of the matrix as a two-component vector, ignoring the last column.

list getRow2s ( )
list getRows ( )
static Mat3 const identMat ( ) [static]

Returns an identity matrix.

This function definition must appear first, since some inline functions below take advantage of it.

bool invertFrom ( Mat3 const  other)

Computes the inverse of the other matrix, and stores the result in this matrix.

This is a fully general operation and makes no assumptions about the type of transform represented by the matrix.

The other matrix must be a different object than this matrix. However, if you need to invert a matrix in place, see invert_in_place.

The return value is true if the matrix was successfully inverted, false if the was a singularity.

bool invertInPlace ( )

Inverts the current matrix.

Returns true if the inverse is successful, false if the matrix was singular.

bool invertTransposeFrom ( Mat3 const  other)

Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.

bool invertTransposeFrom ( Mat4 const  other)

Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.

bool isNan ( )

Returns true if any component of the matrix is not-a-number, false otherwise.

multiply ( Mat3 const  other1,
Mat3 const  other2 
)
operator new ( unsigned int  size)
bool operator!= ( Mat3 const  other)
operator() ( int  row,
int  col 
)
float operator() ( int  row,
int  col 
)
Mat3 operator* ( Mat3 const  other)
Mat3 operator* ( float  scalar)
Mat3 operator*= ( Mat3 const  other)
Mat3 operator*= ( float  scalar)

Performs a memberwise scale.

Mat3 operator+= ( Mat3 const  other)

Performs a memberwise addition between two matrices.

Mat3 operator-= ( Mat3 const  other)

Performs a memberwise subtraction between two matrices.

Mat3 operator/ ( float  scalar)
Mat3 operator/= ( float  scalar)

Performs a memberwise scale.

bool operator< ( Mat3 const  other)

This performs a lexicographical comparison.

It's of questionable mathematical meaning, but sometimes has a practical purpose for sorting unique vectors, especially in an STL container. Also see compare_to().

Mat3 operator= ( float  fill_value)
Mat3 operator= ( Mat3 const  other)
bool operator== ( Mat3 const  other)
Row operator[] ( int  i)
CRow operator[] ( int  i)
output ( ostream  out)
pythonRepr ( ostream  out,
string  class_name 
)
PyObject reduce ( PyObject  self)

This special Python method is implement to provide support for the pickle module.

static Mat3 rotateMat ( float  angle) [static]

Returns a matrix that rotates by the given angle in degrees counterclockwise.

static Mat3 rotateMat ( float  angle,
VBase3  axis,
CoordinateSystem  cs 
) [static]

Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

static Mat3 rotateMat ( float  angle,
VBase3  axis 
) [static]

Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

static Mat3 rotateMatNormaxis ( float  angle,
VBase3 const  axis,
CoordinateSystem  cs 
) [static]

Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

Assumes axis has been normalized.

static Mat3 rotateMatNormaxis ( float  angle,
VBase3 const  axis 
) [static]

Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

Assumes axis has been normalized.

static Mat3 scaleMat ( VBase3 const  scale) [static]

Returns a matrix that applies the indicated scale in each of the three axes.

static Mat3 scaleMat ( float  sx,
float  sy 
) [static]

Returns a matrix that applies the indicated scale in each of the two axes.

static Mat3 scaleMat ( float  sx,
float  sy,
float  sz 
) [static]

Returns a matrix that applies the indicated scale in each of the three axes.

static Mat3 scaleMat ( VBase2 const  scale) [static]

Returns a matrix that applies the indicated scale in each of the two axes.

static Mat3 scaleShearMat ( VBase3 const  scale,
VBase3 const  shear,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3 scaleShearMat ( float  sx,
float  sy,
float  sz,
float  shxy,
float  shxz,
float  shyz 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3 scaleShearMat ( float  sx,
float  sy,
float  sz,
float  shxy,
float  shxz,
float  shyz,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3 scaleShearMat ( VBase3 const  scale,
VBase3 const  shear 
) [static]

Returns a matrix that applies the indicated scale and shear.

set ( float  e00,
float  e01,
float  e02,
float  e10,
float  e11,
float  e12,
float  e20,
float  e21,
float  e22 
)
setCell ( int  row,
int  col,
float  value 
)

Changes a particular element of the matrix.

setCol ( int  col,
VBase3 const  v 
)

Replaces the indicated column of the matrix from a three-component vector.

setCol ( int  col,
VBase2 const  v 
)

Replaces the indicated column of the matrix from a two-component vector, ignoring the last row.

setRotateMat ( float  angle)

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise.

setRotateMat ( float  angle,
VBase3  axis,
CoordinateSystem  cs 
)

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

setRotateMat ( float  angle,
VBase3  axis 
)

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

setRotateMatNormaxis ( float  angle,
VBase3 const  axis,
CoordinateSystem  cs 
)

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

Assumes axis has been normalized.

setRotateMatNormaxis ( float  angle,
VBase3 const  axis 
)

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.

Assumes axis has been normalized.

setRow ( int  row,
VBase3 const  v 
)

Replaces the indicated row of the matrix from a three-component vector.

setRow ( int  row,
VBase2 const  v 
)

Replaces the indicated row of the matrix from a two-component vector, ignoring the last column.

setScaleMat ( VBase2 const  scale)

Fills mat with a matrix that applies the indicated scale in each of the two axes.

setScaleMat ( VBase3 const  scale)

Fills mat with a matrix that applies the indicated scale in each of the three axes.

setScaleShearMat ( VBase3 const  scale,
VBase3 const  shear 
)

Fills mat with a matrix that applies the indicated scale and shear.

setScaleShearMat ( VBase3 const  scale,
VBase3 const  shear,
CoordinateSystem  cs 
)

Fills mat with a matrix that applies the indicated scale and shear.

setShearMat ( VBase3 const  shear,
CoordinateSystem  cs 
)

Fills mat with a matrix that applies the indicated shear in each of the three planes.

setShearMat ( VBase3 const  shear)

Fills mat with a matrix that applies the indicated shear in each of the three planes.

setTranslateMat ( VBase2 const  trans)

Fills mat with a matrix that applies the indicated translation.

static Mat3 shearMat ( VBase3 const  shear) [static]

Returns a matrix that applies the indicated shear in each of the three planes.

static Mat3 shearMat ( VBase3 const  shear,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated shear in each of the three planes.

static Mat3 shearMat ( float  shxy,
float  shxz,
float  shyz,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated shear in each of the three planes.

static Mat3 shearMat ( float  shxy,
float  shxz,
float  shyz 
) [static]

Returns a matrix that applies the indicated shear in each of the three planes.

static int size ( ) [static]

Returns 3: the number of rows of a LMatrix3.

static Mat3 translateMat ( VBase2 const  trans) [static]

Returns a matrix that applies the indicated translation.

static Mat3 translateMat ( float  tx,
float  ty 
) [static]

Returns a matrix that applies the indicated translation.

transposeFrom ( Mat3 const  other)
transposeInPlace ( )
write ( ostream  out)
write ( ostream  out,
int  indent_level 
)
VBase3 xform ( VBase3 const  v)

3-component vector or point times matrix.

VBase2 xformPoint ( VBase2 const  v)

The matrix transforms a 2-component point (including translation component) and returns the result.

This assumes the matrix is an affine transform.

VBase2 xformVec ( VBase2 const  v)

The matrix transforms a 2-component vector (without translation component) and returns the result.

This assumes the matrix is an affine transform.

VBase3 xformVec ( VBase3 const  v)

The matrix transforms a 3-component vector and returns the result.

This assumes the matrix is an orthonormal transform.

In practice, this is the same computation as xform().

VBase3 xformVecGeneral ( VBase3 const  v)

The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties