nalgebra/nalgebra-glm/src/gtc/matrix_inverse.rs

17 lines
523 B
Rust
Raw Normal View History

2021-08-08 18:59:40 +08:00
use crate::RealNumber;
2019-03-23 21:29:07 +08:00
use crate::aliases::TMat;
/// Fast matrix inverse for affine matrix.
2021-08-08 18:59:40 +08:00
pub fn affine_inverse<T: RealNumber, const D: usize>(m: TMat<T, D, D>) -> TMat<T, D, D> {
2020-11-15 23:57:49 +08:00
// TODO: this should be optimized.
m.try_inverse().unwrap_or_else(TMat::<_, D, D>::zeros)
}
/// Compute the transpose of the inverse of a matrix.
2021-08-08 18:59:40 +08:00
pub fn inverse_transpose<T: RealNumber, const D: usize>(m: TMat<T, D, D>) -> TMat<T, D, D> {
2018-10-22 04:11:27 +08:00
m.try_inverse()
.unwrap_or_else(TMat::<_, D, D>::zeros)
.transpose()
}