LMatrix3d
-
class LMatrix3d
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.
Inheritance diagram
-
class CRow
-
class Row
These helper classes are used to support two-level operator [].
-
LMatrix3d(void)
-
LMatrix3d(double, double, double, double, double, double, double, double, double)
-
LMatrix3d(LVecBase3d const&, LVecBase3d const&, LVecBase3d const&)
Constructs the matrix from three individual rows.
-
std::size_t add_hash(std::size_t hash) const
-
std::size_t add_hash(std::size_t hash, double threshold) const
Adds the vector into the running hash.
-
bool almost_equal(LMatrix3d const &other) const
Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type.
Returns true if two matrices are memberwise equal within a specified tolerance.
-
int compare_to(LMatrix3d const &other, double threshold) const
This flavor of compare_to uses a default threshold value based on the numeric type.
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 LMatrix3d const &convert_mat(CoordinateSystem from, CoordinateSystem to)
Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system.
-
double determinant(void) const
Returns the determinant of the matrix.
-
void 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.
-
void generate_hash(ChecksumHashGenerator &hashgen) const
-
void generate_hash(ChecksumHashGenerator &hashgen, double threshold) const
Adds the vector to the indicated hash generator.
-
double get_cell(int row, int col) const
Returns a particular element of the matrix.
-
static TypeHandle get_class_type(void)
-
LVecBase3d get_col(int col) const
Returns the indicated column of the matrix as a three-component vector.
-
LVecBase2d get_col2(int col) const
Returns the indicated column of the matrix as a two-component vector, ignoring the last row.
-
double const *get_data(void) const
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.
-
std::size_t get_hash(void) const
-
std::size_t get_hash(double threshold) const
Returns a suitable hash for phash_map.
-
int get_num_components(void) const
Returns the number of elements in the matrix, nine.
-
LVecBase3d get_row(int row) const
-
void get_row(LVecBase3d &result_vec, int row) const
these versions inline better
Returns the indicated row of the matrix as a three-component vector.
Stores the indicated row of the matrix as a three-component vector.
-
LVecBase2d get_row2(int row) const
Returns the indicated row of the matrix as a two-component vector, ignoring the last column.
-
LMatrix3d const &ident_mat(void)
Returns an identity matrix.
This function definition must appear first, since some inline functions below take advantage of it.
-
bool invert_from(LMatrix3d 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 invert_in_place(void)
Inverts the current matrix. Returns true if the inverse is successful, false if the matrix was singular.
-
bool invert_transpose_from(LMatrix4d const &other)
Simultaneously computes the inverse of the indicated matrix, and then the transpose of that inverse.
-
bool is_identity(void) const
Returns true if this is (close enough to) the identity matrix, false otherwise.
-
bool is_nan(void) const
Returns true if any component of the matrix is not-a-number, false otherwise.
-
void output(std::ostream &out) const
-
void read_datagram(DatagramIterator &source)
Reads the matrix from the Datagram using get_stdfloat().
-
void read_datagram_fixed(DatagramIterator &scan)
Reads the matrix from the Datagram using get_float32() or get_float64(). See
write_datagram_fixed()
.
-
LMatrix3d rotate_mat(double angle, LVecBase3d const &axis, CoordinateSystem cs = ::CS_default)
Returns a matrix that rotates by the given angle in degrees counterclockwise.
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
-
LMatrix3d rotate_mat_normaxis(double angle, LVecBase3d const &axis, CoordinateSystem cs = ::CS_default)
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. Assumes axis has been normalized.
-
LMatrix3d scale_mat(LVecBase2d const &scale)
-
LMatrix3d scale_mat(LVecBase3d const &scale)
-
LMatrix3d scale_mat(double sx, double sy, double sz)
Returns a matrix that applies the indicated scale in each of the two axes.
Returns a matrix that applies the indicated scale in each of the two axes.
Returns a matrix that applies the indicated scale in each of the three axes.
Returns a matrix that applies the indicated scale in each of the three axes.
-
LMatrix3d scale_shear_mat(LVecBase3d const &scale, LVecBase3d const &shear, CoordinateSystem cs = ::CS_default)
-
LMatrix3d 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.
-
void set(double e00, double e01, double e02, double e10, double e11, double e12, double e20, double e21, double e22)
-
void set_cell(int row, int col, double value)
Changes a particular element of the matrix.
-
void set_col(int col, LVecBase3d const &v)
-
void set_col(int col, LVecBase2d const &v)
Replaces the indicated column of the matrix from a three-component vector.
Replaces the indicated column of the matrix from a two-component vector, ignoring the last row.
-
void set_rotate_mat(double angle)
-
void set_rotate_mat(double angle, LVecBase3d const &axis, CoordinateSystem cs = ::CS_default)
Fills mat with a matrix that rotates by the given angle in degrees counterclockwise.
Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
-
void set_rotate_mat_normaxis(double angle, LVecBase3d const &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 normalized.
-
void set_row(int row, LVecBase3d const &v)
-
void set_row(int row, LVecBase2d const &v)
Replaces the indicated row of the matrix from a three-component vector.
Replaces the indicated row of the matrix from a two-component vector, ignoring the last column.
-
void set_scale_mat(LVecBase2d const &scale)
-
void set_scale_mat(LVecBase3d const &scale)
Fills mat with a matrix that applies the indicated scale in each of the two axes.
Fills mat with a matrix that applies the indicated scale in each of the three axes.
-
void set_scale_shear_mat(LVecBase3d const &scale, LVecBase3d const &shear, CoordinateSystem cs = ::CS_default)
Fills mat with a matrix that applies the indicated scale and shear.
-
void set_shear_mat(LVecBase3d const &shear, CoordinateSystem cs = ::CS_default)
Fills mat with a matrix that applies the indicated shear in each of the three planes.
-
void set_translate_mat(LVecBase2d const &trans)
Fills mat with a matrix that applies the indicated translation.
-
LMatrix3d shear_mat(LVecBase3d const &shear, CoordinateSystem cs = ::CS_default)
-
LMatrix3d 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.
-
LMatrix3d translate_mat(LVecBase2d const &trans)
-
LMatrix3d translate_mat(double tx, double ty)
Returns a matrix that applies the indicated translation.
-
void transpose_in_place(void)
-
bool validate_ptr(void const *ptr)
-
void write(std::ostream &out, int indent_level = 0) const
-
void 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.
-
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()
. This is appropriate when you want to write a fixed-width value to the datagram, especially when you are not writing a bam file.
-
LVecBase3d xform(LVecBase3d const &v) const
3-component vector or point times matrix.
-
void xform_in_place(LVecBase3d &v) const
3-component vector or point times matrix.
-
LVecBase2d xform_point(LVecBase2d const &v) const
The matrix transforms a 2-component point (including translation component) and returns the result. This assumes the matrix is an affine transform.
-
void xform_point_in_place(LVecBase2d &v) const
The matrix transforms a 2-component point (including translation component). This assumes the matrix is an affine transform.
-
LVecBase2d xform_vec(LVecBase2d const &v) const
-
LVecBase3d xform_vec(LVecBase3d const &v) const
The matrix transforms a 2-component vector (without translation component) and returns the result. This assumes the matrix is an affine transform.
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()
.
-
LVecBase3d xform_vec_general(LVecBase3d const &v) const
The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation.
-
void xform_vec_general_in_place(LVecBase3d &v) const
The matrix transforms a 3-component vector (without translation component), as a fully general operation.
-
void xform_vec_in_place(LVecBase2d &v) const
-
void xform_vec_in_place(LVecBase3d &v) const
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()
.
-
class CRow