Panda3D
|
This is a 4-by-4 transform matrix. More...
#include "lmatrix.h"
Classes | |
class | CRow |
class | Row |
Public Types | |
enum | { num_components = 16, is_int = 0 } |
typedef const double * | const_iterator |
typedef LSimpleMatrix< double, 4, 4 > | EMatrix4 |
typedef const double * | iterator |
typedef double | numeric_type |
Public Member Functions | |
LMatrix4d (const LMatrix4d &other) | |
LMatrix4d (const UnalignedLMatrix4d &other) | |
LMatrix4d (double e00, double e01, double e02, double e03, double e10, double e11, double e12, double e13, double e20, double e21, double e22, double e23, double e30, double e31, double e32, double e33) | |
LMatrix4d (const LMatrix3d &upper3) | |
LMatrix4d (const LMatrix3d &upper3, const LVecBase3d &trans) | |
LMatrix4d (const EMatrix4 &m) | |
void | accumulate (const LMatrix4d &other, double weight) |
Computes (*this) += other * weight. More... | |
size_t | add_hash (size_t hash) const |
Adds the vector into the running hash. More... | |
size_t | add_hash (size_t hash, double threshold) const |
Adds the vector into the running hash. More... | |
bool | almost_equal (const LMatrix4d &other, double threshold) const |
Returns true if two matrices are memberwise equal within a specified tolerance. More... | |
bool | almost_equal (const LMatrix4d &other) const |
Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type. More... | |
iterator | begin () |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
const_iterator | begin () const |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
int | compare_to (const LMatrix4d &other) const |
This flavor of compare_to uses a default threshold value based on the numeric type. More... | |
int | compare_to (const LMatrix4d &other, double threshold) const |
Sorts matrices lexicographically, componentwise. More... | |
void | componentwise_mult (const LMatrix4d &other) |
iterator | end () |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
const_iterator | end () const |
Returns an iterator that may be used to traverse the elements of the matrix, STL-style. More... | |
void | fill (double fill_value) |
Sets each element of the matrix to the indicated fill_value. More... | |
void | generate_hash (ChecksumHashGenerator &hashgen) const |
Adds the vector to the indicated hash generator. More... | |
void | generate_hash (ChecksumHashGenerator &hashgen, double scale) const |
Adds the vector to the indicated hash generator. More... | |
double | get_cell (int row, int col) const |
Returns a particular element of the matrix. More... | |
LVecBase4d | get_col (int col) const |
Retrieves the indicated column of the matrix as a 4-component vector. More... | |
LVecBase3d | get_col3 (int col) const |
Retrieves the indicated column of the matrix as a 3-component vector, ignoring the last row. More... | |
const double * | get_data () const |
Returns the address of the first of the nine data elements in the matrix. More... | |
size_t | get_hash () const |
Returns a suitable hash for phash_map. More... | |
size_t | get_hash (double threshold) const |
Returns a suitable hash for phash_map. More... | |
int | get_num_components () const |
Returns the number of elements in the matrix, 16. More... | |
LVecBase4d | get_row (int row) const |
Retrieves the indicated row of the matrix as a 4-component vector. More... | |
void | get_row (LVecBase4d &result_vec, int row) const |
Stores the indicated row of the matrix as a 4-component vector. More... | |
LVecBase3d | get_row3 (int row) const |
Retrieves the row column of the matrix as a 3-component vector, ignoring the last column. More... | |
void | get_row3 (LVecBase3d &result_vec, int row) const |
Stores the row column of the matrix as a 3-component vector, ignoring the last column. More... | |
LMatrix3d | get_upper_3 () const |
Retrieves the upper 3x3 submatrix. More... | |
bool | invert_affine_from (const LMatrix4d &other) |
Performs an invert of the indicated matrix, storing the result in this matrix. More... | |
bool | invert_from (const LMatrix4d &other) |
Computes the inverse of the other matrix, and stores the result in this matrix. More... | |
bool | invert_in_place () |
Inverts the current matrix. More... | |
bool | is_identity () const |
Returns true if this is (close enough to) the identity matrix, false otherwise. More... | |
bool | is_nan () const |
Returns true if any component of the matrix is not-a-number, false otherwise. More... | |
MAKE_SEQ (get_rows, size, get_row) | |
MAKE_SEQ (get_cols, size, get_col) | |
MAKE_SEQ (get_row3s, size, get_row3) | |
void | multiply (const LMatrix4d &other1, const LMatrix4d &other2) |
bool | operator!= (const LMatrix4d &other) const |
double & | operator() (int row, int col) |
double | operator() (int row, int col) const |
LMatrix4d | operator* (const LMatrix4d &other) const |
LMatrix4d | operator* (double scalar) const |
LMatrix4d & | operator*= (const LMatrix4d &other) |
LMatrix4d & | operator*= (double scalar) |
LMatrix4d & | operator+= (const LMatrix4d &other) |
Performs a memberwise addition between two matrices. More... | |
LMatrix4d & | operator-= (const LMatrix4d &other) |
Performs a memberwise addition between two matrices. More... | |
LMatrix4d | operator/ (double scalar) const |
LMatrix4d & | operator/= (double scalar) |
bool | operator< (const LMatrix4d &other) const |
This performs a lexicographical comparison. More... | |
LMatrix4d & | operator= (const LMatrix4d &other) |
LMatrix4d & | operator= (const UnalignedLMatrix4d &other) |
LMatrix4d & | operator= (double fill_value) |
bool | operator== (const LMatrix4d &other) const |
CRow | operator[] (int i) const |
Row | operator[] (int i) |
void | output (ostream &out) const |
void | read_datagram (DatagramIterator &source) |
Reads the matrix from the Datagram using get_stdfloat(). More... | |
void | read_datagram_fixed (DatagramIterator &scan) |
Reads the matrix from the Datagram using get_float32() or get_float64(). More... | |
void | set (double e00, double e01, double e02, double e03, double e10, double e11, double e12, double e13, double e20, double e21, double e22, double e23, double e30, double e31, double e32, double e33) |
void | set_cell (int row, int col, double value) |
Changes a particular element of the matrix. More... | |
void | set_col (int col, const LVecBase4d &v) |
Replaces the indicated column of the matrix. More... | |
void | set_col (int col, const LVecBase3d &v) |
Replaces the indicated column of the matrix with the indicated 3-component vector, ignoring the last row. More... | |
void | set_rotate_mat (double angle, const LVecBase3d &axis, CoordinateSystem cs=CS_default) |
Sets mat to a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. More... | |
void | set_rotate_mat_normaxis (double angle, const LVecBase3d &axis, CoordinateSystem cs=CS_default) |
Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. More... | |
void | set_row (int row, const LVecBase4d &v) |
Replaces the indicated row of the matrix. More... | |
void | set_row (int row, const LVecBase3d &v) |
Replaces the indicated row of the matrix with the indicated 3-component vector, ignoring the last column. More... | |
void | set_scale_mat (const LVecBase3d &scale) |
Fills mat with a matrix that applies the indicated scale in each of the three axes. More... | |
void | set_scale_shear_mat (const LVecBase3d &scale, const LVecBase3d &shear, CoordinateSystem cs=CS_default) |
Fills mat with a matrix that applies the indicated scale and shear. More... | |
void | set_shear_mat (const LVecBase3d &shear, CoordinateSystem cs=CS_default) |
Fills mat with a matrix that applies the indicated shear in each of the three planes. More... | |
void | set_translate_mat (const LVecBase3d &trans) |
Fills mat with a matrix that applies the indicated translation. More... | |
void | set_upper_3 (const LMatrix3d &upper3) |
Sets the upper 3x3 submatrix. More... | |
void | transpose_from (const LMatrix4d &other) |
void | transpose_in_place () |
void | write (ostream &out, int indent_level=0) const |
void | write_datagram (Datagram &destination) const |
Writes the matrix to the Datagram using add_stdfloat(). More... | |
void | write_datagram_fixed (Datagram &destination) const |
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(). More... | |
LVecBase4d | xform (const LVecBase4d &v) const |
4-component vector or point times matrix. More... | |
void | xform_in_place (LVecBase4d &v) const |
4-component vector or point times matrix. More... | |
LVecBase3d | xform_point (const LVecBase3d &v) const |
The matrix transforms a 3-component point (including translation component) and returns the result. More... | |
LVecBase3d | xform_point_general (const LVecBase3d &v) const |
The matrix transforms a 3-component point (including translation component) and returns the result, as a fully general operation. More... | |
void | xform_point_general_in_place (LVecBase3d &v) const |
The matrix transforms a 3-component point (including translation component), as a fully general operation. More... | |
void | xform_point_in_place (LVecBase3d &v) const |
The matrix transforms a 3-component point (including translation component). More... | |
LVecBase3d | xform_vec (const LVecBase3d &v) const |
The matrix transforms a 3-component vector (without translation component) and returns the result. More... | |
LVecBase3d | xform_vec_general (const LVecBase3d &v) const |
The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation. More... | |
void | xform_vec_general_in_place (LVecBase3d &v) const |
The matrix transforms a 3-component vector (without translation component), as a fully general operation. More... | |
void | xform_vec_in_place (LVecBase3d &v) const |
The matrix transforms a 3-component vector (without translation component). More... | |
Static Public Member Functions | |
static const LMatrix4d & | convert_mat (CoordinateSystem from, CoordinateSystem to) |
Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system. More... | |
static TypeHandle | get_class_type () |
static const LMatrix4d & | ident_mat () |
Returns an identity matrix. More... | |
static void | init_type () |
static const LMatrix4d & | ones_mat () |
Returns an matrix filled with ones. More... | |
static LMatrix4d | rotate_mat (double angle, const LVecBase3d &axis, CoordinateSystem cs=CS_default) |
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. More... | |
static LMatrix4d | rotate_mat_normaxis (double angle, const LVecBase3d &axis, CoordinateSystem cs=CS_default) |
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. More... | |
static LMatrix4d | scale_mat (const LVecBase3d &scale) |
Returns a matrix that applies the indicated scale in each of the three axes. More... | |
static LMatrix4d | scale_mat (double sx, double sy, double sz) |
Returns a matrix that applies the indicated scale in each of the three axes. More... | |
static LMatrix4d | scale_mat (double scale) |
Returns a matrix that applies the indicated uniform scale. More... | |
static LMatrix4d | scale_shear_mat (const LVecBase3d &scale, const LVecBase3d &shear, CoordinateSystem cs=CS_default) |
Returns a matrix that applies the indicated scale and shear. More... | |
static LMatrix4d | scale_shear_mat (double sx, double sy, double sz, double shxy, double shxz, double shyz, CoordinateSystem cs=CS_default) |
Returns a matrix that applies the indicated scale and shear. More... | |
static LMatrix4d | shear_mat (const LVecBase3d &shear, CoordinateSystem cs=CS_default) |
Returns a matrix that applies the indicated shear in each of the three planes. More... | |
static LMatrix4d | shear_mat (double shxy, double shxz, double shyz, CoordinateSystem cs=CS_default) |
Returns a matrix that applies the indicated shear in each of the three planes. More... | |
static int | size () |
Returns 4: the number of rows of a LMatrix4. More... | |
static LMatrix4d | translate_mat (const LVecBase3d &trans) |
Returns a matrix that applies the indicated translation. More... | |
static LMatrix4d | translate_mat (double tx, double ty, double tz) |
Returns a matrix that applies the indicated translation. More... | |
static const LMatrix4d & | y_to_z_up_mat () |
Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system. More... | |
static const LMatrix4d & | z_to_y_up_mat () |
Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system. More... | |
static const LMatrix4d & | zeros_mat () |
Returns an matrix filled with zeros. More... | |
Public Attributes | |
EMatrix4 | _m |
|
inline |
|
inline |
|
inline |
Adds the vector into the running hash.
Definition at line 5872 of file lmatrix.h.
References floating_point_hash< Key >::add_hash().
bool LMatrix4d::almost_equal | ( | const LMatrix4d & | other, |
double | threshold | ||
) | const |
Returns true if two matrices are memberwise equal within a specified tolerance.
This is faster than the equivalence operator as this doesn't have to guarantee that it is transitive.
Definition at line 2058 of file lmatrix.cxx.
Referenced by EggXfmSAnim::add_data(), DaeCharacter::bind_joints(), MayaToEggConverter::clear(), MaxToEggConverter::convert(), FltToEggLevelState::get_synthetic_group(), SoftNodeDesc::get_transform(), EggXfmSAnim::set_value(), and EggTransform::transform_is_identity().
|
inline |
|
inline |
|
inline |
|
inline |
This flavor of compare_to uses a default threshold value based on the numeric type.
int LMatrix4d::compare_to | ( | const LMatrix4d & | other, |
double | threshold | ||
) | const |
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).
Definition at line 1903 of file lmatrix.cxx.
|
static |
Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system.
Definition at line 1835 of file lmatrix.cxx.
Referenced by EggData::set_coordinate_system().
|
inline |
|
inline |
|
inline |
|
inline |
Adds the vector to the indicated hash generator.
Definition at line 6854 of file lmatrix.h.
References LMatrix4f::get_data().
void LMatrix4d::generate_hash | ( | ChecksumHashGenerator & | hashgen, |
double | scale | ||
) | const |
Adds the vector to the indicated hash generator.
Definition at line 2152 of file lmatrix.cxx.
References ChecksumHashGenerator::add_fp().
|
inline |
|
inline |
|
inline |
|
inline |
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.
Definition at line 5733 of file lmatrix.h.
Referenced by Shader::get_language(), and XFileDataObject::set().
|
inline |
|
inline |
|
inline |
Returns the number of elements in the matrix, 16.
Definition at line 5743 of file lmatrix.h.
Referenced by Shader::get_language().
|
inline |
Retrieves the indicated row of the matrix as a 4-component vector.
Definition at line 5523 of file lmatrix.h.
Referenced by GeomVertexWriter::add_matrix4d(), and GeomVertexWriter::set_matrix4d().
|
inline |
|
inline |
Retrieves the row column of the matrix as a 3-component vector, ignoring the last column.
Definition at line 5577 of file lmatrix.h.
Referenced by EggVertexPool::transform().
|
inline |
|
inline |
|
inlinestatic |
Returns an identity matrix.
This function definition must appear first, since some inline functions below take advantage of it.
Definition at line 5168 of file lmatrix.h.
Referenced by EggJointData::add_back_pointer(), MayaToEggConverter::clear(), FltBead::clear_transform(), EggXfmSAnim::compose_with_order(), MaxToEggConverter::convert(), VRMLToEggConverter::convert_file(), DAEToEggConverter::convert_file(), CharacterMaker::egg_to_slider(), EggMatrixTablePointer::extend_to(), FltTransformRotateAboutEdge::get_angle(), FltTransformRotateAboutPoint::get_angle(), EggTransform::get_component_mat4(), EggJointNodePointer::get_frame(), EggMatrixTablePointer::get_frame(), EggJointData::get_frame(), GeomVertexReader::get_matrix4d(), EggJointData::get_net_frame(), EggJointData::get_net_frame_inv(), EggNode::get_node_frame(), EggNode::get_node_frame_inv(), EggNode::get_node_to_vertex(), MayaShaderColorDef::get_panda_uvset_name(), EggJointData::get_rest_frame(), FltToEggLevelState::get_synthetic_group(), FltBead::get_transform(), SoftNodeDesc::get_transform(), EggNode::get_vertex_frame(), EggNode::get_vertex_frame_inv(), EggNode::get_vertex_to_node(), EggMatrixTablePointer::make_new_joint(), EggJointData::score_reparent_to(), EggTransform::transform_is_identity(), and EggTransform::write().
|
inline |
Performs an invert of the indicated matrix, storing the result in this matrix.
The calculation is only correct of the other matrix represents an affine transform.
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.
Definition at line 6514 of file lmatrix.h.
References LMatrix4f::get_upper_3().
|
inline |
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.
Definition at line 6438 of file lmatrix.h.
Referenced by EggJointData::add_back_pointer(), EggGroup::as_transform(), DaeCharacter::bind_joints(), EggLoader::make_polyset(), and DXFFile::ocs_2_wcs().
|
inline |
Inverts the current matrix.
Returns true if the inverse is successful, false if the matrix was singular.
Definition at line 6553 of file lmatrix.h.
Referenced by EggTopstrip::adjust_transform(), MaxToEggConverter::convert(), EggJointData::get_net_frame_inv(), and Triangulator3::triangulate().
|
inline |
|
inline |
|
inlinestatic |
|
inline |
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().
void LMatrix4d::read_datagram | ( | DatagramIterator & | source | ) |
Reads the matrix from the Datagram using get_stdfloat().
Definition at line 2341 of file lmatrix.cxx.
References DatagramIterator::get_stdfloat(), and TypeHandle::none().
void LMatrix4d::read_datagram_fixed | ( | DatagramIterator & | scan | ) |
Reads the matrix from the Datagram using get_float32() or get_float64().
Definition at line 2306 of file lmatrix.cxx.
References DatagramIterator::get_float32(), and DatagramIterator::get_float64().
|
inlinestatic |
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
Definition at line 6690 of file lmatrix.h.
References LMatrix4f::set_rotate_mat().
Referenced by EggTransform::add_rotate3d(), VRMLToEggConverter::convert_file(), EggBase::convert_paths(), FltTransformRotateAboutPoint::get_angle(), FltTransformRotateAboutEdge::get_angle(), and FltTransformRotateScale::get_angle().
|
inlinestatic |
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
Assumes axis has been prenormalized.
Definition at line 6705 of file lmatrix.h.
References LMatrix4f::set_rotate_mat_normaxis().
Referenced by EggTransform::add_rotate2d(), EggTransform::add_rotx(), EggTransform::add_roty(), EggTransform::add_rotz(), and EggXfmSAnim::compose_with_order().
|
inlinestatic |
Returns a matrix that applies the indicated scale in each of the three axes.
Definition at line 6721 of file lmatrix.h.
Referenced by SomethingToEgg::add_merge_externals_options(), EggTransform::add_scale2d(), EggTransform::add_scale3d(), EggTransform::add_uniform_scale(), EggToSomething::add_units_options(), VRMLToEggConverter::convert_file(), EggBase::convert_paths(), MayaPview::creator(), FltTransformRotateScale::get_angle(), XFileAnimationSet::FrameEntry::get_mat(), FltTransformScale::has_center(), LoaderFileTypePandatool::resolve_filename(), and PerlinNoise3::set_scale().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Returns a matrix that applies the indicated scale and shear.
Definition at line 6791 of file lmatrix.h.
References LMatrix4f::set_scale_shear_mat().
Referenced by EggXfmSAnim::compose_with_order().
|
inlinestatic |
Returns a matrix that applies the indicated scale and shear.
Definition at line 6806 of file lmatrix.h.
References LMatrix4f::set_scale_shear_mat().
|
inline |
|
inline |
|
inline |
void LMatrix4d::set_rotate_mat | ( | double | angle, |
const LVecBase3d & | axis, | ||
CoordinateSystem | cs = CS_default |
||
) |
Sets mat to a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
Definition at line 1925 of file lmatrix.cxx.
void LMatrix4d::set_rotate_mat_normaxis | ( | double | angle, |
const LVecBase3d & | axis, | ||
CoordinateSystem | cs = CS_default |
||
) |
Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
Assumes axis has been prenormalized.
Definition at line 1996 of file lmatrix.cxx.
|
inline |
Replaces the indicated row of the matrix.
Definition at line 5452 of file lmatrix.h.
Referenced by EggXfmSAnim::add_component_data(), EggGroup::as_transform(), MayaToEggConverter::clear(), XFileAnimationSet::FrameEntry::get_mat(), GeomVertexReader::get_matrix4d(), EggLoader::make_polyset(), PerlinNoise3::noise(), EggTable::string_table_type(), EggVertexPool::transform(), Triangulator3::triangulate(), and EggXfmAnimData::write().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Returns a matrix that applies the indicated shear in each of the three planes.
Definition at line 6764 of file lmatrix.h.
References LMatrix4f::set_shear_mat().
|
inlinestatic |
Returns a matrix that applies the indicated shear in each of the three planes.
Definition at line 6777 of file lmatrix.h.
References LMatrix4f::set_shear_mat().
|
inlinestatic |
|
inlinestatic |
Returns a matrix that applies the indicated translation.
Definition at line 6662 of file lmatrix.h.
Referenced by EggTransform::add_translate2d(), EggTransform::add_translate3d(), EggXfmSAnim::compose_with_order(), VRMLToEggConverter::convert_file(), EggBase::convert_paths(), FltTransformRotateAboutEdge::get_angle(), FltTransformRotateAboutPoint::get_angle(), FltTransformRotateScale::get_angle(), FltTransformTranslate::get_from(), FltTransformScale::has_center(), CLwoLayer::make_egg(), and FltTransformPut::set().
|
inlinestatic |
void LMatrix4d::write_datagram | ( | Datagram & | destination | ) | const |
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.
Definition at line 2327 of file lmatrix.cxx.
References Datagram::add_stdfloat().
void LMatrix4d::write_datagram_fixed | ( | Datagram & | destination | ) | const |
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.
Definition at line 2287 of file lmatrix.cxx.
References Datagram::add_float32(), and Datagram::add_float64().
|
inline |
|
inline |
|
inline |
The matrix transforms a 3-component point (including translation component) and returns the result.
This assumes the matrix is an affine transform.
Definition at line 5932 of file lmatrix.h.
Referenced by PerlinNoise3::noise().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Returns an matrix filled with zeros.
Definition at line 5188 of file lmatrix.h.
References UnalignedLMatrix4f::get_data().