LMatrix4d
from panda3d.core import LMatrix4d
- class LMatrix4d
Bases:
Bases:
MemoryBase
This is a 4-by-4 transform matrix.
Inheritance diagram
- class CRow
Bases:
- class Row
Bases:
These helper classes are used to support two-level operator [].
- __init__()
- __init__(upper3: LMatrix3d)
Construct a 4x4 matrix given a 3x3 rotation matrix and an optional translation component.
- __init__(upper3: LMatrix3d, trans: LVecBase3d)
- __init__(other: LMatrix4d)
- __init__(param0: LVecBase4d, param1: LVecBase4d, param2: LVecBase4d, param3: LVecBase4d)
Constructs the matrix from four individual rows.
- __init__(other: UnalignedLMatrix4d)
- __init__(param0: float, param1: float, param2: float, param3: float, param4: float, param5: float, param6: float, param7: float, param8: float, param9: float, param10: float, param11: float, param12: float, param13: float, param14: float, param15: float)
- almost_equal(other: LMatrix4d) bool
Returns true if two matrices are memberwise equal within a default tolerance based on the numeric type.
- almost_equal(other: LMatrix4d, threshold: float) bool
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.
- assign(other: UnalignedLMatrix4d) LMatrix4d
- begin()
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
- begin()
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
- property cols Sequence[LVecBase4d]
- Getter
Retrieves the indicated column of the matrix as a 4-component vector.
- Setter
Replaces the indicated column of the matrix.
Replaces the indicated column of the matrix with the indicated 3-component vector, ignoring the last row.
- compare_to(other: LMatrix4d) int
This flavor of compare_to uses a default threshold value based on the numeric type.
- compare_to(other: LMatrix4d, threshold: float) int
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 convert_mat(from: CoordinateSystem, to: CoordinateSystem) LMatrix4d
Returns a matrix that transforms from the indicated coordinate system to the indicated coordinate system.
- end()
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
- end()
Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
- fill(fill_value: float)
Sets each element of the matrix to the indicated fill_value. This is of questionable value, but is sometimes useful when initializing to zero.
- generate_hash(hashgen: ChecksumHashGenerator)
Adds the vector to the indicated hash generator.
- generate_hash(hashgen: ChecksumHashGenerator, scale: float)
Adds the vector to the indicated hash generator.
- static get_class_type() TypeHandle
- get_col(col: int) LVecBase4d
Retrieves the indicated column of the matrix as a 4-component vector.
- get_col3(col: int) LVecBase3d
Retrieves the indicated column of the matrix as a 3-component vector, ignoring the last row.
- get_data()
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.
- get_row(result_vec: LVecBase4d, row: int)
Stores the indicated row of the matrix as a 4-component vector.
- get_row(row: int) LVecBase4d
Retrieves the indicated row of the matrix as a 4-component vector.
- get_row3(result_vec: LVecBase3d, row: int)
Stores the row column of the matrix as a 3-component vector, ignoring the last column.
- get_row3(row: int) LVecBase3d
Retrieves the row column of the matrix as a 3-component vector, ignoring the last column.
- static ident_mat() LMatrix4d
Returns an identity matrix.
This function definition must appear first, since some inline functions below take advantage of it.
- invert_affine_from(other: LMatrix4d) bool
bugbug: we could optimize this for rotationscaletranslation matrices (transpose upper 3x3 and take negative of translation component)
- invert_from(other: LMatrix4d) bool
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.
- invert_in_place() bool
Inverts the current matrix. Returns true if the inverse is successful, false if the matrix was singular.
- is_identity() bool
Returns true if this is (close enough to) the identity matrix, false otherwise.
- read_datagram(source: DatagramIterator)
Reads the matrix from the Datagram using get_stdfloat().
- read_datagram_fixed(scan: DatagramIterator)
Reads the matrix from the Datagram using get_float32() or get_float64(). See
write_datagram_fixed()
.
- static rotate_mat(angle: float, axis: LVecBase3d, cs: CoordinateSystem) LMatrix4d
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
- static rotate_mat_normaxis(angle: float, axis: LVecBase3d, cs: CoordinateSystem) LMatrix4d
Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. Assumes axis has been prenormalized.
- property rows Sequence[LVecBase4d]
- Getter
these versions inline better
Retrieves the indicated row of the matrix as a 4-component vector.
Stores the indicated row of the matrix as a 4-component vector.
- Setter
Replaces the indicated row of the matrix.
Replaces the indicated row of the matrix with the indicated 3-component vector, ignoring the last column.
- static scale_mat(scale: LVecBase3d) LMatrix4d
Returns a matrix that applies the indicated scale in each of the three axes.
- static scale_mat(sx: float, sy: float, sz: float) LMatrix4d
Returns a matrix that applies the indicated scale in each of the three axes.
- static scale_shear_mat(scale: LVecBase3d, shear: LVecBase3d, cs: CoordinateSystem) LMatrix4d
Returns a matrix that applies the indicated scale and shear.
- static scale_shear_mat(sx: float, sy: float, sz: float, shxy: float, shxz: float, shyz: float, cs: CoordinateSystem) LMatrix4d
Returns a matrix that applies the indicated scale and shear.
- set(e00: float, e01: float, e02: float, e03: float, e10: float, e11: float, e12: float, e13: float, e20: float, e21: float, e22: float, e23: float, e30: float, e31: float, e32: float, e33: float)
- set_col(col: int, v: LVecBase3d)
Replaces the indicated column of the matrix with the indicated 3-component vector, ignoring the last row.
- set_col(col: int, v: LVecBase4d)
Replaces the indicated column of the matrix.
- set_rotate_mat(angle: float, axis: LVecBase3d, cs: CoordinateSystem)
Sets mat to a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector.
- set_rotate_mat_normaxis(angle: float, axis: LVecBase3d, cs: CoordinateSystem)
Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. Assumes axis has been prenormalized.
- set_row(row: int, v: LVecBase3d)
Replaces the indicated row of the matrix with the indicated 3-component vector, ignoring the last column.
- set_row(row: int, v: LVecBase4d)
Replaces the indicated row of the matrix.
- set_scale_mat(scale: LVecBase3d)
Fills mat with a matrix that applies the indicated scale in each of the three axes.
- set_scale_shear_mat(scale: LVecBase3d, shear: LVecBase3d, cs: CoordinateSystem)
Fills mat with a matrix that applies the indicated scale and shear.
- set_shear_mat(shear: LVecBase3d, cs: CoordinateSystem)
Fills mat with a matrix that applies the indicated shear in each of the three planes.
- set_translate_mat(trans: LVecBase3d)
Fills mat with a matrix that applies the indicated translation.
- static shear_mat(shear: LVecBase3d, cs: CoordinateSystem) LMatrix4d
Returns a matrix that applies the indicated shear in each of the three planes.
- static shear_mat(shxy: float, shxz: float, shyz: float, cs: CoordinateSystem) LMatrix4d
Returns a matrix that applies the indicated shear in each of the three planes.
- static translate_mat(trans: LVecBase3d) LMatrix4d
Returns a matrix that applies the indicated translation.
- static translate_mat(tx: float, ty: float, tz: float) LMatrix4d
Returns a matrix that applies the indicated translation.
- transpose_in_place()
- write_datagram(destination: Datagram)
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.
- write_datagram_fixed(destination: Datagram)
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.
- xform(v: LVecBase4d) LVecBase4d
4-component vector or point times matrix. This is a fully general operation.
- xform_in_place(v: LVecBase4d)
4-component vector or point times matrix. This is a fully general operation.
- xform_point(v: LVecBase3d) LVecBase3d
The matrix transforms a 3-component point (including translation component) and returns the result. This assumes the matrix is an affine transform.
- xform_point_general(v: LVecBase3d) LVecBase3d
The matrix transforms a 3-component point (including translation component) and returns the result, as a fully general operation.
- xform_point_general_in_place(v: LVecBase3d)
The matrix transforms a 3-component point (including translation component), as a fully general operation.
- xform_point_in_place(v: LVecBase3d)
The matrix transforms a 3-component point (including translation component). This assumes the matrix is an affine transform.
- xform_vec(v: LVecBase3d) LVecBase3d
The matrix transforms a 3-component vector (without translation component) and returns the result. This assumes the matrix is an orthonormal transform.
- xform_vec_general(v: LVecBase3d) LVecBase3d
The matrix transforms a 3-component vector (without translation component) and returns the result, as a fully general operation.
- xform_vec_general_in_place(v: LVecBase3d)
The matrix transforms a 3-component vector (without translation component), as a fully general operation.
- xform_vec_in_place(v: LVecBase3d)
The matrix transforms a 3-component vector (without translation component). This assumes the matrix is an orthonormal transform.
- static y_to_z_up_mat() LMatrix4d
Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system.