#[repr(C)]
pub struct Basis { pub elements: [Vector3; 3], }
Expand description

A 3x3 matrix, typically used as an orthogonal basis for Transform.

The basis vectors are the column vectors of the matrix, while the elements field represents the row vectors.

See also Basis in the Godot API doc.

Fields

elements: [Vector3; 3]

Matrix rows. These are not the basis vectors!

This is a transposed view for performance.
To read basis vectors, see a(), b(), c().
To write them, see set_a(), set_b(), set_c().

Implementations

The identity basis. Basis vectors are unit vectors along each axis X, Y and Z.

Equivalent to calling Basis::default().

The basis that will flip something along the X axis when used in a transformation.

The basis that will flip something along the Y axis when used in a transformation.

The basis that will flip something along the Z axis when used in a transformation.

Constructs a basis matrix from 3 linearly independent basis vectors (matrix columns).

This is the typical way to construct a basis. If you want to fill in the elements one-by-one, consider using Self::from_rows().

Creates a basis from 3 row vectors. These are not basis vectors.

This constructor is mostly useful if you want to write matrix elements in matrix syntax:

let basis = Basis::from_rows(
    Vector3::new(a.x, b.x, c.x),
    Vector3::new(a.y, b.y, c.y),
    Vector3::new(a.z, b.z, c.z),
);

The vectors a, b and c are the basis vectors.
In this particular case, you could also use Self::from_basis_vectors(a, b, c) instead.

Creates a diagonal matrix from the given vector.

Can be used as a basis for a scaling transform. Each component of scale represents the scale factor in the corresponding direction.

Creates a rotation matrix from Euler angles.

The angle vector has XYZ components. However, the angles are applied in YXZ convention: first Z, then X, and Y last.

Constructs a pure rotation basis matrix from the given quaternion.

Rotation matrix from axis and angle.

See https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle

Panics

If axis is not normalized.

Returns the inverse of the matrix.

Panics

If the determinant of self is zero.

Returns the transposed version of the matrix.

Returns the determinant of the matrix.

Returns an orthonormalized version of the matrix: 3 orthogonal basis vectors of unit length.

Returns true if self and other are approximately equal.

Multiplies the matrix from left with the rotation matrix: M -> R·M

The main use of Basis is as a Transform.basis, which is used as the transformation matrix of the 3D object. rotated() here refers to rotation of the object (which is R * self), not the matrix itself.

Returns the scale of the matrix.

Introduce an additional scaling specified by the given 3D scaling factor.

Converts matrix into a quaternion.

Quaternions are frequently used in 3D graphics, because they enable easy and cheap interpolation. However, they are less human-readable. For Euler angles, see Basis::to_euler().

Panics

If self is not normalized.

Returns the Basis’s rotation in the form of Euler angles.

In the YXZ convention: first Z, then X, and Y last.

The returned Vector3 contains the rotation angles in the format (X angle, Y angle, Z angle).

See Basis::to_quat if you need a quaternion instead.

Returns a vector transformed (multiplied) by the matrix.

Returns a vector transformed (multiplied) by the transposed matrix.

Note: This results in a multiplication by the inverse of the matrix only if it represents a rotation-reflection.

Get the 1st basis vector (first column vector of the matrix).

Set the 1st basis vector (first column vector of the matrix).

Get the 2nd basis vector (second column vector of the matrix).

Set the 2nd basis vector (second column vector of the matrix).

Get the 3rd basis vector (third column vector of the matrix).

Set the 3rd basis vector (third column vector of the matrix).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
A type-specific hint type that is valid for the type being exported. Read more
Returns ExportInfo given an optional typed hint.
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.