2018-10-22 04:11:27 +08:00
|
|
|
use na::{DefaultAllocator, Real};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::TMat;
|
|
|
|
use crate::traits::{Alloc, Dimension};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Fast matrix inverse for affine matrix.
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn affine_inverse<N: Real, 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-09-20 20:23:31 +08:00
|
|
|
// FIXME: this should be optimized.
|
2018-10-05 11:21:38 +08:00
|
|
|
m.try_inverse().unwrap_or_else(TMat::<_, D, D>::zeros)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Compute the transpose of the inverse of a matrix.
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn inverse_transpose<N: Real, 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()
|
2018-10-05 11:21:38 +08:00
|
|
|
}
|