use core::fmt::Debug;
pub trait SpatialScalar: num_traits::Float + Debug + Send + Sync + 'static {}
impl<T> SpatialScalar for T where T: num_traits::Float + Debug + Send + Sync + 'static {}
pub trait SpatialRepresentation<T: SpatialScalar>:
Copy + Clone + Debug + PartialEq + Send + Sync + 'static
{
type Vector3: Copy + Clone + Debug + PartialEq + Send + Sync + 'static;
type Vector6: Copy + Clone + Debug + PartialEq + Send + Sync + 'static;
type Matrix3: Copy + Clone + Debug + PartialEq + Send + Sync + 'static;
type Matrix6: Copy + Clone + Debug + PartialEq + Send + Sync + 'static;
type Rotation3: Copy + Clone + Debug + PartialEq + Send + Sync + 'static;
fn vector3_from_array(value: [T; 3]) -> Self::Vector3;
fn vector3_to_array(value: &Self::Vector3) -> [T; 3];
fn vector6_from_array(value: [T; 6]) -> Self::Vector6;
fn vector6_to_array(value: &Self::Vector6) -> [T; 6];
fn matrix3_from_array(value: [[T; 3]; 3]) -> Self::Matrix3;
fn matrix3_to_array(value: &Self::Matrix3) -> [[T; 3]; 3];
fn matrix6_from_array(value: [[T; 6]; 6]) -> Self::Matrix6;
fn matrix6_to_array(value: &Self::Matrix6) -> [[T; 6]; 6];
fn rotation3_from_array(value: [[T; 3]; 3]) -> Self::Rotation3;
fn rotation3_to_array(value: &Self::Rotation3) -> [[T; 3]; 3];
fn vector3_zero() -> Self::Vector3 {
Self::vector3_from_array(crate::math::vector_zero())
}
fn vector3_add(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
Self::vector3_from_array(crate::math::vector_add(
Self::vector3_to_array(left),
Self::vector3_to_array(right),
))
}
fn vector3_sub(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
Self::vector3_from_array(crate::math::vector_sub(
Self::vector3_to_array(left),
Self::vector3_to_array(right),
))
}
fn vector3_neg(value: &Self::Vector3) -> Self::Vector3 {
Self::vector3_from_array(crate::math::vector_neg(Self::vector3_to_array(value)))
}
fn vector3_scale(value: &Self::Vector3, scalar: T) -> Self::Vector3 {
Self::vector3_from_array(crate::math::vector_scale(
Self::vector3_to_array(value),
scalar,
))
}
fn vector3_dot(left: &Self::Vector3, right: &Self::Vector3) -> T {
crate::math::dot(Self::vector3_to_array(left), Self::vector3_to_array(right))
}
fn vector3_cross(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
Self::vector3_from_array(crate::math::cross(
Self::vector3_to_array(left),
Self::vector3_to_array(right),
))
}
fn vector3_is_finite(value: &Self::Vector3) -> bool {
crate::math::vector_is_finite(&Self::vector3_to_array(value))
}
fn vector3_cross_matrix(value: &Self::Vector3) -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::skew(Self::vector3_to_array(value)))
}
fn matrix3_zero() -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_zero())
}
fn matrix3_identity() -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_identity())
}
fn matrix3_add(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_add(
Self::matrix3_to_array(left),
Self::matrix3_to_array(right),
))
}
fn matrix3_sub(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_sub(
Self::matrix3_to_array(left),
Self::matrix3_to_array(right),
))
}
fn matrix3_scale(value: &Self::Matrix3, scalar: T) -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_scale(
Self::matrix3_to_array(value),
scalar,
))
}
fn matrix3_mul(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
Self::matrix3_from_array(crate::math::matrix_mul(
Self::matrix3_to_array(left),
Self::matrix3_to_array(right),
))
}
fn matrix3_vector_mul(matrix: &Self::Matrix3, vector: &Self::Vector3) -> Self::Vector3 {
Self::vector3_from_array(crate::math::matrix_vector_mul(
Self::matrix3_to_array(matrix),
Self::vector3_to_array(vector),
))
}
fn matrix3_is_finite(value: &Self::Matrix3) -> bool {
crate::math::matrix_is_finite(&Self::matrix3_to_array(value))
}
fn matrix3_is_positive_definite(value: &Self::Matrix3) -> bool {
crate::math::is_positive_definite(Self::matrix3_to_array(value))
}
fn rotation3_identity() -> Self::Rotation3 {
Self::rotation3_from_array(crate::math::matrix_identity())
}
fn rotation3_inverse(value: &Self::Rotation3) -> Self::Rotation3 {
Self::rotation3_from_array(crate::math::matrix_transpose(Self::rotation3_to_array(
value,
)))
}
fn rotation3_mul(left: &Self::Rotation3, right: &Self::Rotation3) -> Self::Rotation3 {
Self::rotation3_from_array(crate::math::matrix_mul(
Self::rotation3_to_array(left),
Self::rotation3_to_array(right),
))
}
fn rotation3_transform_vector(
rotation: &Self::Rotation3,
vector: &Self::Vector3,
) -> Self::Vector3 {
Self::vector3_from_array(crate::math::matrix_vector_mul(
Self::rotation3_to_array(rotation),
Self::vector3_to_array(vector),
))
}
fn rotation3_to_matrix3(value: &Self::Rotation3) -> Self::Matrix3 {
Self::matrix3_from_array(Self::rotation3_to_array(value))
}
fn matrix6_from_blocks(
upper_left: &Self::Matrix3,
upper_right: &Self::Matrix3,
lower_left: &Self::Matrix3,
lower_right: &Self::Matrix3,
) -> Self::Matrix6 {
let upper_left = Self::matrix3_to_array(upper_left);
let upper_right = Self::matrix3_to_array(upper_right);
let lower_left = Self::matrix3_to_array(lower_left);
let lower_right = Self::matrix3_to_array(lower_right);
let matrix = core::array::from_fn(|row| {
core::array::from_fn(|column| {
let (block, row, column) = if row < 3 && column < 3 {
(&upper_left, row, column)
} else if row < 3 {
(&upper_right, row, column - 3)
} else if column < 3 {
(&lower_left, row - 3, column)
} else {
(&lower_right, row - 3, column - 3)
};
block[row][column]
})
});
Self::matrix6_from_array(matrix)
}
fn matrix6_sub(left: &Self::Matrix6, right: &Self::Matrix6) -> Self::Matrix6 {
Self::matrix6_from_array(crate::math::matrix_sub(
Self::matrix6_to_array(left),
Self::matrix6_to_array(right),
))
}
fn matrix6_neg(value: &Self::Matrix6) -> Self::Matrix6 {
Self::matrix6_from_array(crate::math::matrix_neg(Self::matrix6_to_array(value)))
}
fn matrix6_transpose(value: &Self::Matrix6) -> Self::Matrix6 {
Self::matrix6_from_array(crate::math::matrix_transpose(Self::matrix6_to_array(value)))
}
fn matrix6_mul(left: &Self::Matrix6, right: &Self::Matrix6) -> Self::Matrix6 {
Self::matrix6_from_array(crate::math::matrix_mul(
Self::matrix6_to_array(left),
Self::matrix6_to_array(right),
))
}
fn matrix6_vector_mul(matrix: &Self::Matrix6, vector: &Self::Vector6) -> Self::Vector6 {
Self::vector6_from_array(crate::math::matrix_vector_mul(
Self::matrix6_to_array(matrix),
Self::vector6_to_array(vector),
))
}
fn matrix6_solve_positive_definite(
matrix: &Self::Matrix6,
right: &Self::Vector6,
) -> Option<Self::Vector6> {
let matrix = Self::matrix6_to_array(matrix);
let right = Self::vector6_to_array(right);
crate::math::solve_positive_definite(matrix, right).map(Self::vector6_from_array)
}
}
#[cfg(feature = "builtin")]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Builtin;
#[cfg(feature = "builtin")]
impl<T: SpatialScalar> SpatialRepresentation<T> for Builtin {
type Vector3 = [T; 3];
type Vector6 = [T; 6];
type Matrix3 = [[T; 3]; 3];
type Matrix6 = [[T; 6]; 6];
type Rotation3 = [[T; 3]; 3];
fn vector3_from_array(value: [T; 3]) -> Self::Vector3 {
value
}
fn vector3_to_array(value: &Self::Vector3) -> [T; 3] {
*value
}
fn vector6_from_array(value: [T; 6]) -> Self::Vector6 {
value
}
fn vector6_to_array(value: &Self::Vector6) -> [T; 6] {
*value
}
fn matrix3_from_array(value: [[T; 3]; 3]) -> Self::Matrix3 {
value
}
fn matrix3_to_array(value: &Self::Matrix3) -> [[T; 3]; 3] {
*value
}
fn matrix6_from_array(value: [[T; 6]; 6]) -> Self::Matrix6 {
value
}
fn matrix6_to_array(value: &Self::Matrix6) -> [[T; 6]; 6] {
*value
}
fn rotation3_from_array(value: [[T; 3]; 3]) -> Self::Rotation3 {
value
}
fn rotation3_to_array(value: &Self::Rotation3) -> [[T; 3]; 3] {
*value
}
}
#[cfg(feature = "nalgebra")]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Nalgebra;
#[cfg(feature = "nalgebra")]
impl<T> SpatialRepresentation<T> for Nalgebra
where
T: SpatialScalar + nalgebra::RealField,
{
type Vector3 = nalgebra::Vector3<T>;
type Vector6 = nalgebra::SVector<T, 6>;
type Matrix3 = nalgebra::Matrix3<T>;
type Matrix6 = nalgebra::SMatrix<T, 6, 6>;
type Rotation3 = nalgebra::Rotation3<T>;
fn vector3_from_array(value: [T; 3]) -> Self::Vector3 {
nalgebra::Vector3::from_row_slice(&value)
}
fn vector3_to_array(value: &Self::Vector3) -> [T; 3] {
let values = value.as_slice();
[values[0], values[1], values[2]]
}
fn vector6_from_array(value: [T; 6]) -> Self::Vector6 {
nalgebra::SVector::from_row_slice(&value)
}
fn vector6_to_array(value: &Self::Vector6) -> [T; 6] {
let values = value.as_slice();
[
values[0], values[1], values[2], values[3], values[4], values[5],
]
}
fn matrix3_from_array(value: [[T; 3]; 3]) -> Self::Matrix3 {
let values: [T; 9] = core::array::from_fn(|index| value[index / 3][index % 3]);
nalgebra::Matrix3::from_row_slice(&values)
}
fn matrix3_to_array(value: &Self::Matrix3) -> [[T; 3]; 3] {
core::array::from_fn(|row| core::array::from_fn(|column| value[(row, column)]))
}
fn matrix6_from_array(value: [[T; 6]; 6]) -> Self::Matrix6 {
let values: [T; 36] = core::array::from_fn(|index| value[index / 6][index % 6]);
nalgebra::SMatrix::from_row_slice(&values)
}
fn matrix6_to_array(value: &Self::Matrix6) -> [[T; 6]; 6] {
core::array::from_fn(|row| core::array::from_fn(|column| value[(row, column)]))
}
fn rotation3_from_array(value: [[T; 3]; 3]) -> Self::Rotation3 {
let values: [T; 9] = core::array::from_fn(|index| value[index / 3][index % 3]);
nalgebra::Rotation3::from_matrix_unchecked(nalgebra::Matrix3::from_row_slice(&values))
}
fn rotation3_to_array(value: &Self::Rotation3) -> [[T; 3]; 3] {
let matrix = value.matrix();
core::array::from_fn(|row| core::array::from_fn(|column| matrix[(row, column)]))
}
fn vector3_zero() -> Self::Vector3 {
nalgebra::Vector3::zeros()
}
fn vector3_add(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left + *right
}
fn vector3_sub(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left - *right
}
fn vector3_neg(value: &Self::Vector3) -> Self::Vector3 {
-*value
}
fn vector3_scale(value: &Self::Vector3, scalar: T) -> Self::Vector3 {
*value * scalar
}
fn vector3_dot(left: &Self::Vector3, right: &Self::Vector3) -> T {
left.dot(right)
}
fn vector3_cross(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
left.cross(right)
}
fn vector3_is_finite(value: &Self::Vector3) -> bool {
value.iter().all(|component| component.is_finite())
}
fn vector3_cross_matrix(value: &Self::Vector3) -> Self::Matrix3 {
value.cross_matrix()
}
fn matrix3_zero() -> Self::Matrix3 {
nalgebra::Matrix3::zeros()
}
fn matrix3_identity() -> Self::Matrix3 {
nalgebra::Matrix3::identity()
}
fn matrix3_add(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left + *right
}
fn matrix3_sub(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left - *right
}
fn matrix3_scale(value: &Self::Matrix3, scalar: T) -> Self::Matrix3 {
*value * scalar
}
fn matrix3_mul(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left * *right
}
fn matrix3_vector_mul(matrix: &Self::Matrix3, vector: &Self::Vector3) -> Self::Vector3 {
*matrix * *vector
}
fn matrix3_is_finite(value: &Self::Matrix3) -> bool {
value.iter().all(|component| component.is_finite())
}
fn matrix3_is_positive_definite(value: &Self::Matrix3) -> bool {
Self::matrix3_is_finite(value) && nalgebra::Cholesky::new(*value).is_some()
}
fn rotation3_identity() -> Self::Rotation3 {
nalgebra::Rotation3::identity()
}
fn rotation3_inverse(value: &Self::Rotation3) -> Self::Rotation3 {
value.inverse()
}
fn rotation3_mul(left: &Self::Rotation3, right: &Self::Rotation3) -> Self::Rotation3 {
*left * *right
}
fn rotation3_transform_vector(
rotation: &Self::Rotation3,
vector: &Self::Vector3,
) -> Self::Vector3 {
rotation.transform_vector(vector)
}
fn rotation3_to_matrix3(value: &Self::Rotation3) -> Self::Matrix3 {
*value.matrix()
}
fn matrix6_from_blocks(
upper_left: &Self::Matrix3,
upper_right: &Self::Matrix3,
lower_left: &Self::Matrix3,
lower_right: &Self::Matrix3,
) -> Self::Matrix6 {
nalgebra::SMatrix::from_fn(|row, column| {
if row < 3 && column < 3 {
upper_left[(row, column)]
} else if row < 3 {
upper_right[(row, column - 3)]
} else if column < 3 {
lower_left[(row - 3, column)]
} else {
lower_right[(row - 3, column - 3)]
}
})
}
fn matrix6_sub(left: &Self::Matrix6, right: &Self::Matrix6) -> Self::Matrix6 {
*left - *right
}
fn matrix6_neg(value: &Self::Matrix6) -> Self::Matrix6 {
-*value
}
fn matrix6_transpose(value: &Self::Matrix6) -> Self::Matrix6 {
value.transpose()
}
fn matrix6_mul(left: &Self::Matrix6, right: &Self::Matrix6) -> Self::Matrix6 {
*left * *right
}
fn matrix6_vector_mul(matrix: &Self::Matrix6, vector: &Self::Vector6) -> Self::Vector6 {
*matrix * *vector
}
fn matrix6_solve_positive_definite(
matrix: &Self::Matrix6,
right: &Self::Vector6,
) -> Option<Self::Vector6> {
if !matrix.iter().all(|component| component.is_finite())
|| !right.iter().all(|component| component.is_finite())
{
return None;
}
let decomposition = nalgebra::Cholesky::new(*matrix)?;
let solution = decomposition.solve(right);
solution
.iter()
.all(|component| component.is_finite())
.then_some(solution)
}
}
#[cfg(feature = "glam")]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Glam;
#[cfg(feature = "glam")]
impl SpatialRepresentation<f32> for Glam {
type Vector3 = glam::Vec3;
type Vector6 = [f32; 6];
type Matrix3 = glam::Mat3;
type Matrix6 = [[f32; 6]; 6];
type Rotation3 = glam::Mat3;
fn vector3_from_array(value: [f32; 3]) -> Self::Vector3 {
glam::Vec3::from_array(value)
}
fn vector3_to_array(value: &Self::Vector3) -> [f32; 3] {
value.to_array()
}
fn vector6_from_array(value: [f32; 6]) -> Self::Vector6 {
value
}
fn vector6_to_array(value: &Self::Vector6) -> [f32; 6] {
*value
}
fn matrix3_from_array(value: [[f32; 3]; 3]) -> Self::Matrix3 {
glam::Mat3::from_cols(
glam::Vec3::new(value[0][0], value[1][0], value[2][0]),
glam::Vec3::new(value[0][1], value[1][1], value[2][1]),
glam::Vec3::new(value[0][2], value[1][2], value[2][2]),
)
}
fn matrix3_to_array(value: &Self::Matrix3) -> [[f32; 3]; 3] {
let columns = value.to_cols_array();
[
[columns[0], columns[3], columns[6]],
[columns[1], columns[4], columns[7]],
[columns[2], columns[5], columns[8]],
]
}
fn matrix6_from_array(value: [[f32; 6]; 6]) -> Self::Matrix6 {
value
}
fn matrix6_to_array(value: &Self::Matrix6) -> [[f32; 6]; 6] {
*value
}
fn rotation3_from_array(value: [[f32; 3]; 3]) -> Self::Rotation3 {
<Self as SpatialRepresentation<f32>>::matrix3_from_array(value)
}
fn rotation3_to_array(value: &Self::Rotation3) -> [[f32; 3]; 3] {
<Self as SpatialRepresentation<f32>>::matrix3_to_array(value)
}
fn vector3_zero() -> Self::Vector3 {
glam::Vec3::ZERO
}
fn vector3_add(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left + *right
}
fn vector3_sub(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left - *right
}
fn vector3_neg(value: &Self::Vector3) -> Self::Vector3 {
-*value
}
fn vector3_scale(value: &Self::Vector3, scalar: f32) -> Self::Vector3 {
*value * scalar
}
fn vector3_dot(left: &Self::Vector3, right: &Self::Vector3) -> f32 {
left.dot(*right)
}
fn vector3_cross(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
left.cross(*right)
}
fn vector3_is_finite(value: &Self::Vector3) -> bool {
value.is_finite()
}
fn vector3_cross_matrix(value: &Self::Vector3) -> Self::Matrix3 {
glam::Mat3::from_cols(
glam::Vec3::new(0.0, value.z, -value.y),
glam::Vec3::new(-value.z, 0.0, value.x),
glam::Vec3::new(value.y, -value.x, 0.0),
)
}
fn matrix3_zero() -> Self::Matrix3 {
glam::Mat3::ZERO
}
fn matrix3_identity() -> Self::Matrix3 {
glam::Mat3::IDENTITY
}
fn matrix3_add(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left + *right
}
fn matrix3_sub(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left - *right
}
fn matrix3_scale(value: &Self::Matrix3, scalar: f32) -> Self::Matrix3 {
*value * scalar
}
fn matrix3_mul(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left * *right
}
fn matrix3_vector_mul(matrix: &Self::Matrix3, vector: &Self::Vector3) -> Self::Vector3 {
*matrix * *vector
}
fn matrix3_is_finite(value: &Self::Matrix3) -> bool {
value.is_finite()
}
fn rotation3_identity() -> Self::Rotation3 {
glam::Mat3::IDENTITY
}
fn rotation3_inverse(value: &Self::Rotation3) -> Self::Rotation3 {
value.transpose()
}
fn rotation3_mul(left: &Self::Rotation3, right: &Self::Rotation3) -> Self::Rotation3 {
*left * *right
}
fn rotation3_transform_vector(
rotation: &Self::Rotation3,
vector: &Self::Vector3,
) -> Self::Vector3 {
*rotation * *vector
}
fn rotation3_to_matrix3(value: &Self::Rotation3) -> Self::Matrix3 {
*value
}
}
#[cfg(feature = "glam")]
impl SpatialRepresentation<f64> for Glam {
type Vector3 = glam::DVec3;
type Vector6 = [f64; 6];
type Matrix3 = glam::DMat3;
type Matrix6 = [[f64; 6]; 6];
type Rotation3 = glam::DMat3;
fn vector3_from_array(value: [f64; 3]) -> Self::Vector3 {
glam::DVec3::from_array(value)
}
fn vector3_to_array(value: &Self::Vector3) -> [f64; 3] {
value.to_array()
}
fn vector6_from_array(value: [f64; 6]) -> Self::Vector6 {
value
}
fn vector6_to_array(value: &Self::Vector6) -> [f64; 6] {
*value
}
fn matrix3_from_array(value: [[f64; 3]; 3]) -> Self::Matrix3 {
glam::DMat3::from_cols(
glam::DVec3::new(value[0][0], value[1][0], value[2][0]),
glam::DVec3::new(value[0][1], value[1][1], value[2][1]),
glam::DVec3::new(value[0][2], value[1][2], value[2][2]),
)
}
fn matrix3_to_array(value: &Self::Matrix3) -> [[f64; 3]; 3] {
let columns = value.to_cols_array();
[
[columns[0], columns[3], columns[6]],
[columns[1], columns[4], columns[7]],
[columns[2], columns[5], columns[8]],
]
}
fn matrix6_from_array(value: [[f64; 6]; 6]) -> Self::Matrix6 {
value
}
fn matrix6_to_array(value: &Self::Matrix6) -> [[f64; 6]; 6] {
*value
}
fn rotation3_from_array(value: [[f64; 3]; 3]) -> Self::Rotation3 {
<Self as SpatialRepresentation<f64>>::matrix3_from_array(value)
}
fn rotation3_to_array(value: &Self::Rotation3) -> [[f64; 3]; 3] {
<Self as SpatialRepresentation<f64>>::matrix3_to_array(value)
}
fn vector3_zero() -> Self::Vector3 {
glam::DVec3::ZERO
}
fn vector3_add(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left + *right
}
fn vector3_sub(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
*left - *right
}
fn vector3_neg(value: &Self::Vector3) -> Self::Vector3 {
-*value
}
fn vector3_scale(value: &Self::Vector3, scalar: f64) -> Self::Vector3 {
*value * scalar
}
fn vector3_dot(left: &Self::Vector3, right: &Self::Vector3) -> f64 {
left.dot(*right)
}
fn vector3_cross(left: &Self::Vector3, right: &Self::Vector3) -> Self::Vector3 {
left.cross(*right)
}
fn vector3_is_finite(value: &Self::Vector3) -> bool {
value.is_finite()
}
fn vector3_cross_matrix(value: &Self::Vector3) -> Self::Matrix3 {
glam::DMat3::from_cols(
glam::DVec3::new(0.0, value.z, -value.y),
glam::DVec3::new(-value.z, 0.0, value.x),
glam::DVec3::new(value.y, -value.x, 0.0),
)
}
fn matrix3_zero() -> Self::Matrix3 {
glam::DMat3::ZERO
}
fn matrix3_identity() -> Self::Matrix3 {
glam::DMat3::IDENTITY
}
fn matrix3_add(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left + *right
}
fn matrix3_sub(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left - *right
}
fn matrix3_scale(value: &Self::Matrix3, scalar: f64) -> Self::Matrix3 {
*value * scalar
}
fn matrix3_mul(left: &Self::Matrix3, right: &Self::Matrix3) -> Self::Matrix3 {
*left * *right
}
fn matrix3_vector_mul(matrix: &Self::Matrix3, vector: &Self::Vector3) -> Self::Vector3 {
*matrix * *vector
}
fn matrix3_is_finite(value: &Self::Matrix3) -> bool {
value.is_finite()
}
fn rotation3_identity() -> Self::Rotation3 {
glam::DMat3::IDENTITY
}
fn rotation3_inverse(value: &Self::Rotation3) -> Self::Rotation3 {
value.transpose()
}
fn rotation3_mul(left: &Self::Rotation3, right: &Self::Rotation3) -> Self::Rotation3 {
*left * *right
}
fn rotation3_transform_vector(
rotation: &Self::Rotation3,
vector: &Self::Vector3,
) -> Self::Vector3 {
*rotation * *vector
}
fn rotation3_to_matrix3(value: &Self::Rotation3) -> Self::Matrix3 {
*value
}
}