batbox-la 0.16.0

Linear algebra
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

impl<T: Float> mat3<T> {
    /// Get 2d part of the orthographic projection matrix
    pub fn ortho(aabb: Aabb2<T>) -> Self {
        let Aabb2 {
            min: vec2(l, b),
            max: vec2(r, t),
        } = aabb;
        let two = T::ONE + T::ONE;
        Self::new([
            [two / (r - l), T::ZERO, -(r + l) / (r - l)],
            [T::ZERO, two / (t - b), -(t + b) / (t - b)],
            [T::ZERO, T::ZERO, T::ONE],
        ])
    }
}