Panda3D
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Classes | Public Member Functions | Static Public Member Functions
Mat3D Class Reference

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

List of all members.

Classes

class  CRow
class  Row

Public Member Functions

 Mat3D ()
 Mat3D (Mat3D const other)
 Mat3D (double e00, double e01, double e02, double e10, double e11, double e12, double e20, double e21, double e22)
unsigned int addHash (unsigned int hash)
 Adds the vector into the running hash.
unsigned int addHash (unsigned int hash, double threshold)
 Adds the vector into the running hash.
bool almostEqual (Mat3D const other)
 Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type.
bool almostEqual (Mat3D const other, double threshold)
 Returns true if two matrices are memberwise equal within a specified tolerance.
int compareTo (Mat3D const other)
 This flavor of compare_to uses a default threshold value based on the numeric type.
int compareTo (Mat3D const other, double threshold)
 Sorts matrices lexicographically, componentwise.
double determinant ()
 Returns the determinant of the matrix.
 fill (double fill_value)
 Sets each element of the matrix to the indicated fill_value.
 generateHash (ChecksumHashGenerator hashgen)
 Adds the vector to the indicated hash generator.
 generateHash (ChecksumHashGenerator hashgen, double threshold)
 Adds the vector to the indicated hash generator.
double getCell (int row, int col)
 Returns a particular element of the matrix.
VBase3D getCol (int col)
 Returns the indicated column of the matrix as a three-component vector.
VBase2D 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 (double threshold)
 Returns a suitable hash for phash_map.
int getNumComponents ()
 Returns the number of elements in the matrix, nine.
 getRow (VBase3D result_vec, int row)
 Stores the indicated row of the matrix as a three-component vector.
VBase3D getRow (int row)
 Returns the indicated row of the matrix as a three-component vector.
VBase2D 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 (Mat3D const other)
 Computes the inverse of the other matrix, and stores the result in this matrix.
bool invertInPlace ()
 Inverts the current matrix.
bool invertTransposeFrom (Mat3D const other)
 Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.
bool invertTransposeFrom (Mat4D 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 (Mat3D const other1, Mat3D const other2)
 operator new (unsigned int size)
bool operator!= (Mat3D const other)
 operator() (int row, int col)
double operator() (int row, int col)
Mat3D operator* (Mat3D const other)
Mat3D operator* (double scalar)
Mat3D operator*= (Mat3D const other)
Mat3D operator*= (double scalar)
 Performs a memberwise scale.
Mat3D operator+= (Mat3D const other)
 Performs a memberwise addition between two matrices.
Mat3D operator-= (Mat3D const other)
 Performs a memberwise subtraction between two matrices.
Mat3D operator/ (double scalar)
Mat3D operator/= (double scalar)
 Performs a memberwise scale.
bool operator< (Mat3D const other)
 This performs a lexicographical comparison.
Mat3D operator= (Mat3D const other)
Mat3D operator= (double fill_value)
bool operator== (Mat3D const other)
Row operator[] (int i)
CRow operator[] (int i)
 output (ostream out)
 pythonRepr (ostream out, string class_name)
 readDatagram (DatagramIterator source)
 Reads the matrix from the Datagram using get_stdfloat().
 readDatagramFixed (DatagramIterator scan)
 Reads the matrix from the Datagram using get_float32() or get_float64().
PyObject reduce (PyObject self)
 set (double e00, double e01, double e02, double e10, double e11, double e12, double e20, double e21, double e22)
 setCell (int row, int col, double value)
 Changes a particular element of the matrix.
 setCol (int col, VBase2D const v)
 Replaces the indicated column of the matrix from a two-component vector, ignoring the last row.
 setCol (int col, VBase3D const v)
 Replaces the indicated column of the matrix from a three-component vector.
 setRotateMat (double angle)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise.
 setRotateMat (double angle, VBase3D const axis, CoordinateSystem cs)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMat (double angle, VBase3D const axis)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMatNormaxis (double angle, VBase3D const axis, CoordinateSystem cs)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRotateMatNormaxis (double angle, VBase3D const axis)
 Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
 setRow (int row, VBase2D const v)
 Replaces the indicated row of the matrix from a two-component vector, ignoring the last column.
 setRow (int row, VBase3D const v)
 Replaces the indicated row of the matrix from a three-component vector.
 setScaleMat (VBase2D const scale)
 Fills mat with a matrix that applies the indicated scale in each of the two axes.
 setScaleMat (VBase3D const scale)
 Fills mat with a matrix that applies the indicated scale in each of the three axes.
 setScaleShearMat (VBase3D const scale, VBase3D const shear, CoordinateSystem cs)
 Fills mat with a matrix that applies the indicated scale and shear.
 setScaleShearMat (VBase3D const scale, VBase3D const shear)
 Fills mat with a matrix that applies the indicated scale and shear.
 setShearMat (VBase3D const shear, CoordinateSystem cs)
 Fills mat with a matrix that applies the indicated shear in each of the three planes.
 setShearMat (VBase3D const shear)
 Fills mat with a matrix that applies the indicated shear in each of the three planes.
 setTranslateMat (VBase2D const trans)
 Fills mat with a matrix that applies the indicated translation.
 transposeFrom (Mat3D const other)
 transposeInPlace ()
 write (ostream out, int indent_level)
 write (ostream out)
 writeDatagram (Datagram destination)
 Writes the matrix to the Datagram using add_stdfloat().
 writeDatagramFixed (Datagram destination)
 Writes the matrix to the Datagram using add_float32() or add_float64(), depending on the type of floats in the matrix, regardless of the setting of Datagram::set_stdfloat_double().
VBase3D xform (VBase3D const v)
 3-component vector or point times matrix.
 xformInPlace (VBase3D v)
 3-component vector or point times matrix.
VBase2D xformPoint (VBase2D const v)
 The matrix transforms a 2-component point (including translation component) and returns the result.
 xformPointInPlace (VBase2D v)
 The matrix transforms a 2-component point (including translation component).
VBase2D xformVec (VBase2D const v)
 The matrix transforms a 2-component vector (without translation component) and returns the result.
VBase3D xformVec (VBase3D const v)
 The matrix transforms a 3-component vector and returns the result.
VBase3D xformVecGeneral (VBase3D const v)
 The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation.
 xformVecGeneralInPlace (VBase3D v)
 The matrix transforms a 3-component vector (without translation component), as a fully general operation.
 xformVecInPlace (VBase2D v)
 The matrix transforms a 2-component vector (without translation component).
 xformVecInPlace (VBase3D v)
 The matrix transforms a 3-component vector.

Static Public Member Functions

static Mat3D 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 Mat3D const identMat ()
 Returns an identity matrix.
static Mat3D rotateMat (double angle)
 Returns a matrix that rotates by the given angle in degrees counterclockwise.
static Mat3D rotateMat (double angle, VBase3D const axis, CoordinateSystem cs)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3D rotateMat (double angle, VBase3D const axis)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3D rotateMatNormaxis (double angle, VBase3D const axis, CoordinateSystem cs)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3D rotateMatNormaxis (double angle, VBase3D const axis)
 Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
static Mat3D scaleMat (VBase2D const scale)
 Returns a matrix that applies the indicated scale in each of the two axes.
static Mat3D scaleMat (VBase3D const scale)
 Returns a matrix that applies the indicated scale in each of the three axes.
static Mat3D scaleMat (double sx, double sy)
 Returns a matrix that applies the indicated scale in each of the two axes.
static Mat3D scaleMat (double sx, double sy, double sz)
 Returns a matrix that applies the indicated scale in each of the three axes.
static Mat3D scaleShearMat (VBase3D const scale, VBase3D const shear, CoordinateSystem cs)
 Returns a matrix that applies the indicated scale and shear.
static Mat3D scaleShearMat (VBase3D const scale, VBase3D const shear)
 Returns a matrix that applies the indicated scale and shear.
static Mat3D scaleShearMat (double sx, double sy, double sz, double shxy, double shxz, double shyz, CoordinateSystem cs)
 Returns a matrix that applies the indicated scale and shear.
static Mat3D scaleShearMat (double sx, double sy, double sz, double shxy, double shxz, double shyz)
 Returns a matrix that applies the indicated scale and shear.
static Mat3D shearMat (VBase3D const shear, CoordinateSystem cs)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3D shearMat (VBase3D const shear)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3D shearMat (double shxy, double shxz, double shyz, CoordinateSystem cs)
 Returns a matrix that applies the indicated shear in each of the three planes.
static Mat3D shearMat (double shxy, double shxz, double shyz)
 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 Mat3D translateMat (VBase2D const trans)
 Returns a matrix that applies the indicated translation.
static Mat3D translateMat (double tx, double ty)
 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

Mat3D ( )
Mat3D ( Mat3D const  other)
Mat3D ( double  e00,
double  e01,
double  e02,
double  e10,
double  e11,
double  e12,
double  e20,
double  e21,
double  e22 
)

Member Function Documentation

unsigned int addHash ( unsigned int  hash)

Adds the vector into the running hash.

unsigned int addHash ( unsigned int  hash,
double  threshold 
)

Adds the vector into the running hash.

bool almostEqual ( Mat3D const  other)

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

bool almostEqual ( Mat3D const  other,
double  threshold 
)

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

int compareTo ( Mat3D const  other)

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

int compareTo ( Mat3D const  other,
double  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 Mat3D const convertMat ( CoordinateSystem  from,
CoordinateSystem  to 
) [static]

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

double determinant ( )

Returns the determinant of the matrix.

fill ( double  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.

generateHash ( ChecksumHashGenerator  hashgen)

Adds the vector to the indicated hash generator.

generateHash ( ChecksumHashGenerator  hashgen,
double  threshold 
)

Adds the vector to the indicated hash generator.

double getCell ( int  row,
int  col 
)

Returns a particular element of the matrix.

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

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

VBase2D 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 ( )

Returns a suitable hash for phash_map.

unsigned int getHash ( double  threshold)

Returns a suitable hash for phash_map.

Returns the number of elements in the matrix, nine.

getRow ( VBase3D  result_vec,
int  row 
)

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

VBase3D getRow ( int  row)

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

VBase2D getRow2 ( int  row)

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

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

Returns an identity matrix.

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

bool invertFrom ( Mat3D 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 there was a singularity.

bool invertInPlace ( )

Inverts the current matrix.

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

bool invertTransposeFrom ( Mat3D const  other)

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

bool invertTransposeFrom ( Mat4D 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 ( Mat3D const  other1,
Mat3D const  other2 
)
operator new ( unsigned int  size)
bool operator!= ( Mat3D const  other)
operator() ( int  row,
int  col 
)
double operator() ( int  row,
int  col 
)
Mat3D operator* ( Mat3D const  other)
Mat3D operator* ( double  scalar)
Mat3D operator*= ( Mat3D const  other)
Mat3D operator*= ( double  scalar)

Performs a memberwise scale.

Mat3D operator+= ( Mat3D const  other)

Performs a memberwise addition between two matrices.

Mat3D operator-= ( Mat3D const  other)

Performs a memberwise subtraction between two matrices.

Mat3D operator/ ( double  scalar)
Mat3D operator/= ( double  scalar)

Performs a memberwise scale.

bool operator< ( Mat3D 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().

Mat3D operator= ( Mat3D const  other)
Mat3D operator= ( double  fill_value)
bool operator== ( Mat3D const  other)
Row operator[] ( int  i)
CRow operator[] ( int  i)
output ( ostream  out)
pythonRepr ( ostream  out,
string  class_name 
)

Reads the matrix from the Datagram using get_stdfloat().

Reads the matrix from the Datagram using get_float32() or get_float64().

See write_datagram_fixed().

PyObject reduce ( PyObject  self)
static Mat3D rotateMat ( double  angle) [static]

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

static Mat3D rotateMat ( double  angle,
VBase3D const  axis,
CoordinateSystem  cs 
) [static]

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

static Mat3D rotateMat ( double  angle,
VBase3D const  axis 
) [static]

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

static Mat3D rotateMatNormaxis ( double  angle,
VBase3D 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 Mat3D rotateMatNormaxis ( double  angle,
VBase3D 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 Mat3D scaleMat ( VBase2D const  scale) [static]

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

static Mat3D scaleMat ( VBase3D const  scale) [static]

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

static Mat3D scaleMat ( double  sx,
double  sy 
) [static]

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

static Mat3D scaleMat ( double  sx,
double  sy,
double  sz 
) [static]

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

static Mat3D scaleShearMat ( VBase3D const  scale,
VBase3D const  shear,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3D scaleShearMat ( VBase3D const  scale,
VBase3D const  shear 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3D scaleShearMat ( double  sx,
double  sy,
double  sz,
double  shxy,
double  shxz,
double  shyz,
CoordinateSystem  cs 
) [static]

Returns a matrix that applies the indicated scale and shear.

static Mat3D scaleShearMat ( double  sx,
double  sy,
double  sz,
double  shxy,
double  shxz,
double  shyz 
) [static]

Returns a matrix that applies the indicated scale and shear.

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

Changes a particular element of the matrix.

setCol ( int  col,
VBase2D const  v 
)

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

setCol ( int  col,
VBase3D const  v 
)

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

setRotateMat ( double  angle)

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

setRotateMat ( double  angle,
VBase3D const  axis,
CoordinateSystem  cs 
)

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

setRotateMat ( double  angle,
VBase3D const  axis 
)

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

setRotateMatNormaxis ( double  angle,
VBase3D 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 ( double  angle,
VBase3D 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,
VBase2D const  v 
)

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

setRow ( int  row,
VBase3D const  v 
)

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

setScaleMat ( VBase2D const  scale)

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

setScaleMat ( VBase3D const  scale)

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

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

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

setScaleShearMat ( VBase3D const  scale,
VBase3D const  shear 
)

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

setShearMat ( VBase3D const  shear,
CoordinateSystem  cs 
)

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

setShearMat ( VBase3D const  shear)

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

setTranslateMat ( VBase2D const  trans)

Fills mat with a matrix that applies the indicated translation.

static Mat3D shearMat ( VBase3D const  shear,
CoordinateSystem  cs 
) [static]

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

static Mat3D shearMat ( VBase3D const  shear) [static]

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

static Mat3D shearMat ( double  shxy,
double  shxz,
double  shyz,
CoordinateSystem  cs 
) [static]

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

static Mat3D shearMat ( double  shxy,
double  shxz,
double  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 Mat3D translateMat ( VBase2D const  trans) [static]

Returns a matrix that applies the indicated translation.

static Mat3D translateMat ( double  tx,
double  ty 
) [static]

Returns a matrix that applies the indicated translation.

transposeFrom ( Mat3D const  other)
write ( ostream  out,
int  indent_level 
)
write ( ostream  out)
writeDatagram ( Datagram  destination)

Writes the matrix to the Datagram using add_stdfloat().

This is appropriate when you want to write the matrix using the standard width setting, especially when you are writing a bam file.

writeDatagramFixed ( Datagram  destination)

Writes the matrix to the Datagram using add_float32() or add_float64(), depending on the type of floats in the matrix, regardless of the setting of Datagram::set_stdfloat_double().

This is appropriate when you want to write a fixed-width value to the datagram, especially when you are not writing a bam file.

VBase3D xform ( VBase3D const  v)

3-component vector or point times matrix.

3-component vector or point times matrix.

VBase2D xformPoint ( VBase2D const  v)

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

This assumes the matrix is an affine transform.

The matrix transforms a 2-component point (including translation component).

This assumes the matrix is an affine transform.

VBase2D xformVec ( VBase2D const  v)

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

This assumes the matrix is an affine transform.

VBase3D xformVec ( VBase3D 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().

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

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

The matrix transforms a 2-component vector (without translation component).

This assumes the matrix is an affine transform.

The matrix transforms a 3-component vector.

This assumes the matrix is an orthonormal transform.

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

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties