panda3d.core.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

Inheritance diagram of LMatrix3d

__init__() → None
__init__(other: LMatrix3d) → None
__init__(param0: LVecBase3d, param1: LVecBase3d, param2: LVecBase3d) → None

Constructs the matrix from three individual rows.

__init__(param0: float, param1: float, param2: float, param3: float, param4: float, param5: float, param6: float, param7: float, param8: float) → None
assign(other: LMatrix3d) → LMatrix3d
Return type

LMatrix3d

assign(fill_value: float) → LMatrix3d
Return type

LMatrix3d

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, e10: float, e11: float, e12: float, e20: float, e21: float, e22: float) → None
static size() → int

Returns 3: the number of rows of a LMatrix3.

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

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

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

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

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

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

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

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

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

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

getRow(row: int) → LVecBase3d

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

Return type

LVecBase3d

getCol(col: int) → LVecBase3d

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

Return type

LVecBase3d

getRow2(row: int) → LVecBase2d

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

Return type

LVecBase2d

getCol2(col: int) → LVecBase2d

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

Return type

LVecBase2d

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, nine.

compareTo(other: LMatrix3d) → int

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

compareTo(other: LMatrix3d, 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: LVecBase3d) → LVecBase3d

3-component vector or point times matrix.

Return type

LVecBase3d

xformPoint(v: LVecBase2d) → LVecBase2d

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

Return type

LVecBase2d

xformVec(v: LVecBase2d) → LVecBase2d

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

Return type

LVecBase2d

xformVec(v: LVecBase3d) → LVecBase3d

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

Return type

LVecBase3d

xformVecGeneral(v: LVecBase3d) → LVecBase3d

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

Return type

LVecBase3d

xformInPlace(v: LVecBase3d) → None

3-component vector or point times matrix.

xformPointInPlace(v: LVecBase2d) → None

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

xformVecInPlace(v: LVecBase2d) → None

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

xformVecInPlace(v: LVecBase3d) → None

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

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

xformVecGeneralInPlace(v: LVecBase3d) → None

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

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

this = other1 * other2

componentwiseMult(other: LMatrix3d) → None
determinant() → float

Returns the determinant of the matrix.

transposeFrom(other: LMatrix3d) → None
transposeInPlace() → None
invertFrom(other: LMatrix3d) → 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 there was a singularity.

invertInPlace() → bool

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

invertTransposeFrom(other: LMatrix3d) → bool

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

invertTransposeFrom(other: LMatrix4d) → bool

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

static identMat() → LMatrix3d

Returns an identity matrix.

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

Return type

LMatrix3d

setTranslateMat(trans: LVecBase2d) → None

Fills mat with a matrix that applies the indicated translation.

setRotateMat(angle: float) → None

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

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

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

setScaleMat(scale: LVecBase2d) → None

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

setScaleMat(scale: LVecBase3d) → None

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

static translateMat(trans: LVecBase2d) → LMatrix3d

Returns a matrix that applies the indicated translation.

Return type

LMatrix3d

static translateMat(tx: float, ty: float) → LMatrix3d

Returns a matrix that applies the indicated translation.

Return type

LMatrix3d

static rotateMat(angle: float) → LMatrix3d

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

Return type

LMatrix3d

static rotateMat(angle: float, axis: LVecBase3d, cs: CoordinateSystem) → LMatrix3d

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

Return type

LMatrix3d

static scaleMat(scale: LVecBase2d) → LMatrix3d

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

Return type

LMatrix3d

static scaleMat(scale: LVecBase3d) → LMatrix3d

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

Return type

LMatrix3d

static scaleMat(sx: float, sy: float) → LMatrix3d

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

Return type

LMatrix3d

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

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

Return type

LMatrix3d

setRotateMatNormaxis(angle: float, axis: LVecBase3d, 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 normalized.

static rotateMatNormaxis(angle: float, axis: LVecBase3d, cs: CoordinateSystem) → LMatrix3d

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

Return type

LMatrix3d

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

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

static shearMat(shear: LVecBase3d, cs: CoordinateSystem) → LMatrix3d

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

Return type

LMatrix3d

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

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

Return type

LMatrix3d

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

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

static scaleShearMat(scale: LVecBase3d, shear: LVecBase3d, cs: CoordinateSystem) → LMatrix3d

Returns a matrix that applies the indicated scale and shear.

Return type

LMatrix3d

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

Returns a matrix that applies the indicated scale and shear.

Return type

LMatrix3d

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

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

Return type

LMatrix3d

almostEqual(other: LMatrix3d) → bool

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

almostEqual(other: LMatrix3d, threshold: float) → bool

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

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, threshold: 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
getCol2s() → list
getRow2s() → list
property rows

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.

Return type

Sequence[LVecBase3d]

property cols

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

Return type

Sequence[LVecBase3d]

class Row

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

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

Returns 3: the number of columns of a LMatrix3.

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

Returns 3: the number of columns of a LMatrix3.