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

20 lines
651 B
Rust
Raw Normal View History

2019-03-25 18:21:41 +08:00
use na::{DefaultAllocator, RealField};
2019-03-23 21:29:07 +08:00
use crate::aliases::TMat;
use crate::traits::{Alloc, Dimension};
/// Fast matrix inverse for affine matrix.
2019-03-25 18:21:41 +08:00
pub fn affine_inverse<N: RealField, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
2018-10-22 13:00:10 +08:00
where DefaultAllocator: Alloc<N, D, D> {
// FIXME: this should be optimized.
m.try_inverse().unwrap_or_else(TMat::<_, D, D>::zeros)
}
/// Compute the transpose of the inverse of a matrix.
2019-03-25 18:21:41 +08:00
pub fn inverse_transpose<N: RealField, D: Dimension>(m: TMat<N, D, D>) -> TMat<N, D, D>
2018-10-22 13:00:10 +08:00
where DefaultAllocator: Alloc<N, D, D> {
2018-10-22 04:11:27 +08:00
m.try_inverse()
.unwrap_or_else(TMat::<_, D, D>::zeros)
.transpose()
}