#[repr(C)]pub struct Basis<T: Scalar> {
pub x_axis: Vector3<T>,
pub y_axis: Vector3<T>,
pub z_axis: Vector3<T>,
pub center: Vector3<T>,
}Expand description
A 3D coordinate basis (reference frame).
Represents a local coordinate system with three orthogonal axes and an origin point. This is useful for transformations between different coordinate spaces.
Fields§
§x_axis: Vector3<T>Basis X axis.
y_axis: Vector3<T>Basis Y axis.
z_axis: Vector3<T>Basis Z axis.
center: Vector3<T>Basis origin (center).
Implementations§
Source§impl<T: Scalar> Basis<T>
impl<T: Scalar> Basis<T>
Sourcepub fn center_mut(&mut self) -> &mut Vector3<T>
pub fn center_mut(&mut self) -> &mut Vector3<T>
Returns a mutable reference to the center.
Sourcepub fn to_mat4(&self) -> Matrix4<T>
pub fn to_mat4(&self) -> Matrix4<T>
Converts the basis to a 4x4 transformation matrix.
The resulting matrix transforms from local basis space to world space:
- Columns 0-2: The basis axes (rotation/scale)
- Column 3: The center point (translation)
Sourcepub fn of_mat4(mat: &Matrix4<T>) -> Self
pub fn of_mat4(mat: &Matrix4<T>) -> Self
Creates a basis from a 4x4 transformation matrix.
Extracts the axes from columns 0-2 and center from column 3.
Sourcepub fn default_with_center(center: &Vector3<T>) -> Self
pub fn default_with_center(center: &Vector3<T>) -> Self
Returns the default right-handed basis with a custom center.
Sourcepub fn plane_axis(&self, plane: BasisPlane) -> (&Vector3<T>, &Vector3<T>)
pub fn plane_axis(&self, plane: BasisPlane) -> (&Vector3<T>, &Vector3<T>)
Returns the two axes spanning the given plane.
Sourcepub fn plane_axis_mut(
&mut self,
plane: BasisPlane,
) -> (&mut Vector3<T>, &mut Vector3<T>)
pub fn plane_axis_mut( &mut self, plane: BasisPlane, ) -> (&mut Vector3<T>, &mut Vector3<T>)
Returns mutable references to the two axes spanning the given plane.
Sourcepub fn to_mat3(&self) -> Matrix3<T>
pub fn to_mat3(&self) -> Matrix3<T>
Converts the basis axes to a 3x3 rotation matrix.
The matrix contains only the rotation part, without translation.
Sourcepub fn of_center_mat3(center: &Vector3<T>, m: Matrix3<T>) -> Self
pub fn of_center_mat3(center: &Vector3<T>, m: Matrix3<T>) -> Self
Creates a basis from a center point and a 3x3 rotation matrix.
The matrix columns become the basis axes.