# panda3d.core.LMatrix4f¶

class LMatrix4f

This is a 4-by-4 transform matrix.

Inheritance diagram

__init__() → None
__init__(upper3: LMatrix3f) → None

Construct a 4x4 matrix given a 3x3 rotation matrix and an optional translation component.

__init__(upper3: LMatrix3f, trans: LVecBase3f) → None
__init__(other: LMatrix4f) → None
__init__(param0: LVecBase4f, param1: LVecBase4f, param2: LVecBase4f, param3: LVecBase4f) → None

Constructs the matrix from four individual rows.

__init__(other: UnalignedLMatrix4f) → None
__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) → None
assign(other: LMatrix4f) → LMatrix4f
Return type

LMatrix4f

assign(other: UnalignedLMatrix4f) → LMatrix4f
Return type

LMatrix4f

assign(fill_value: float) → LMatrix4f
Return type

LMatrix4f

operatorNew(size: size_t) → None
fill(fill_value: float) → None

Sets each element of the matrix to the indicated fill_value. This is of questionable value, but is sometimes useful when initializing to zero.

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) → None
setUpper3(upper3: LMatrix3f) → None

Get and set the upper 3x3 rotation matrix.

getUpper3() → LMatrix3f

Retrieves the upper 3x3 submatrix.

Return type

LMatrix3f

static size() → int

Returns 4: the number of rows of a LMatrix4.

setRow(row: int, v: LVecBase3f) → None

Replaces the indicated row of the matrix with the indicated 3-component vector, ignoring the last column.

setRow(row: int, v: LVecBase4f) → None

Replaces the indicated row of the matrix.

setCol(col: int, v: LVecBase3f) → None

Replaces the indicated column of the matrix with the indicated 3-component vector, ignoring the last row.

setCol(col: int, v: LVecBase4f) → None

Replaces the indicated column of the matrix.

getRow(result_vec: LVecBase4f, row: int) → None

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

getRow(row: int) → LVecBase4f

Retrieves the indicated row of the matrix as a 4-component vector.

Return type

LVecBase4f

getCol(col: int) → LVecBase4f

Retrieves the indicated column of the matrix as a 4-component vector.

Return type

LVecBase4f

getRow3(result_vec: LVecBase3f, row: int) → None

Stores the row column of the matrix as a 3-component vector, ignoring the last column.

getRow3(row: int) → LVecBase3f

Retrieves the row column of the matrix as a 3-component vector, ignoring the last column.

Return type

LVecBase3f

getCol3(col: int) → LVecBase3f

Retrieves the indicated column of the matrix as a 3-component vector, ignoring the last row.

Return type

LVecBase3f

isNan() → bool

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

isIdentity() → bool

Returns true if this is (close enough to) the identity matrix, false otherwise.

getCell(row: int, col: int) → float

Returns a particular element of the matrix.

setCell(row: int, col: int, value: float) → None

Changes a particular element of the matrix.

getData() → None

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.

getNumComponents() → int

Returns the number of elements in the matrix, 16.

begin() → None

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

begin() → None

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

end() → None

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

end() → None

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

compareTo(other: LMatrix4f) → int

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

compareTo(other: LMatrix4f, 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).

getHash() → size_t

Returns a suitable hash for phash_map.

Return type

size_t

getHash(threshold: float) → size_t

Returns a suitable hash for phash_map.

Return type

size_t

addHash(hash: size_t) → size_t

Adds the vector into the running hash.

Return type

size_t

addHash(hash: size_t, threshold: float) → size_t

Adds the vector into the running hash.

Return type

size_t

xform(v: LVecBase4f) → LVecBase4f

4-component vector or point times matrix. This is a fully general operation.

Return type

LVecBase4f

xformPoint(v: LVecBase3f) → LVecBase3f

The matrix transforms a 3-component point (including translation component) and returns the result. This assumes the matrix is an affine transform.

Return type

LVecBase3f

xformPointGeneral(v: LVecBase3f) → LVecBase3f

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

Return type

LVecBase3f

xformVec(v: LVecBase3f) → LVecBase3f

The matrix transforms a 3-component vector (without translation component) and returns the result. This assumes the matrix is an orthonormal transform.

Return type

LVecBase3f

xformVecGeneral(v: LVecBase3f) → LVecBase3f

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

Return type

LVecBase3f

xformInPlace(v: LVecBase4f) → None

4-component vector or point times matrix. This is a fully general operation.

xformPointInPlace(v: LVecBase3f) → None

The matrix transforms a 3-component point (including translation component). This assumes the matrix is an affine transform.

xformPointGeneralInPlace(v: LVecBase3f) → None

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

xformVecInPlace(v: LVecBase3f) → None

The matrix transforms a 3-component vector (without translation component). This assumes the matrix is an orthonormal transform.

xformVecGeneralInPlace(v: LVecBase3f) → None

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

multiply(other1: LMatrix4f, other2: LMatrix4f) → None

this = other1 * other2

componentwiseMult(other: LMatrix4f) → None
transposeFrom(other: LMatrix4f) → None
transposeInPlace() → None
invertFrom(other: LMatrix4f) → 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.

invertAffineFrom(other: LMatrix4f) → bool

bugbug: we could optimize this for rotationscaletranslation matrices (transpose upper 3x3 and take negative of translation component)

invertInPlace() → bool

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

accumulate(other: LMatrix4f, weight: float) → None

Computes (*this) += other * weight.

static identMat() → LMatrix4f

Returns an identity matrix.

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

Return type

LMatrix4f

static onesMat() → LMatrix4f

Returns an matrix filled with ones.

Return type

LMatrix4f

static zerosMat() → LMatrix4f

Returns an matrix filled with zeros.

Return type

LMatrix4f

setTranslateMat(trans: LVecBase3f) → None

Fills mat with a matrix that applies the indicated translation.

setRotateMat(angle: float, axis: LVecBase3f, cs: CoordinateSystem) → None

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

setRotateMatNormaxis(angle: float, axis: LVecBase3f, cs: CoordinateSystem) → None

Fills mat with a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. Assumes axis has been prenormalized.

setScaleMat(scale: LVecBase3f) → None

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

setShearMat(shear: LVecBase3f, cs: CoordinateSystem) → None

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

setScaleShearMat(scale: LVecBase3f, shear: LVecBase3f, cs: CoordinateSystem) → None

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

static translateMat(trans: LVecBase3f) → LMatrix4f

Returns a matrix that applies the indicated translation.

Return type

LMatrix4f

static translateMat(tx: float, ty: float, tz: float) → LMatrix4f

Returns a matrix that applies the indicated translation.

Return type

LMatrix4f

static rotateMat(angle: float, axis: LVecBase3f, cs: CoordinateSystem) → LMatrix4f

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

Return type

LMatrix4f

static rotateMatNormaxis(angle: float, axis: LVecBase3f, cs: CoordinateSystem) → LMatrix4f

Returns a matrix that rotates by the given angle in degrees counterclockwise about the indicated vector. Assumes axis has been prenormalized.

Return type

LMatrix4f

static scaleMat(scale: LVecBase3f) → LMatrix4f

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

Return type

LMatrix4f

static scaleMat(scale: float) → LMatrix4f

Returns a matrix that applies the indicated uniform scale.

Return type

LMatrix4f

static scaleMat(sx: float, sy: float, sz: float) → LMatrix4f

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

Return type

LMatrix4f

static shearMat(shear: LVecBase3f, cs: CoordinateSystem) → LMatrix4f

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

Return type

LMatrix4f

static shearMat(shxy: float, shxz: float, shyz: float, cs: CoordinateSystem) → LMatrix4f

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

Return type

LMatrix4f

static scaleShearMat(scale: LVecBase3f, shear: LVecBase3f, cs: CoordinateSystem) → LMatrix4f

Returns a matrix that applies the indicated scale and shear.

Return type

LMatrix4f

static scaleShearMat(sx: float, sy: float, sz: float, shxy: float, shxz: float, shyz: float, cs: CoordinateSystem) → LMatrix4f

Returns a matrix that applies the indicated scale and shear.

Return type

LMatrix4f

static yToZUpMat() → LMatrix4f

Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system.

Return type

LMatrix4f

static zToYUpMat() → LMatrix4f

Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system.

Return type

LMatrix4f

static convertMat(from: CoordinateSystem, to: CoordinateSystem) → LMatrix4f

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

Return type

LMatrix4f

almostEqual(other: LMatrix4f) → bool

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

almostEqual(other: LMatrix4f, 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.

output(out: ostream) → None
write(out: ostream, indent_level: int) → None
generateHash(hashgen: ChecksumHashGenerator) → None

Adds the vector to the indicated hash generator.

generateHash(hashgen: ChecksumHashGenerator, scale: float) → None

Adds the vector to the indicated hash generator.

writeDatagramFixed(destination: Datagram) → None

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.setStdfloatDouble(). This is appropriate when you want to write a fixed-width value to the datagram, especially when you are not writing a bam file.

readDatagramFixed(scan: DatagramIterator) → None

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

writeDatagram(destination: Datagram) → None

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.

readDatagram(source: DatagramIterator) → None

Reads the matrix from the Datagram using get_stdfloat().

static getClassType() → TypeHandle
Return type

TypeHandle

getRows() → list
getCols() → list
getRow3s() → list
property rows

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.

Return type
property cols

Retrieves the indicated column of the matrix as a 4-component vector.

Return type
class Row

These helper classes are used to support two-level operator [].

__init__(param0: Row) → None
static size() → int

Returns 4: the number of columns of a LMatrix4.

class CRow
__init__(param0: CRow) → None
static size() → int

Returns 4: the number of columns of a LMatrix4.