//! Extra utilities for 3×3 matrices.12use glam::{Mat3A, Vec3, Vec3A};34/// Creates a 3×3 matrix that reflects points across the plane at the origin5/// with the given normal.6///7/// This is also known as a [Householder matrix]. It has the general form I -8/// 2NNᵀ, where N is the normal of the plane and I is the identity matrix.9///10/// If the plane across which points are to be reflected isn't at the origin,11/// you can create a translation matrix that translates the points to the12/// origin, then apply the matrix that this function returns on top of that, and13/// finally translate back to the original position.14///15/// See the `mirror` example for a demonstration of how you might use this16/// function.17///18/// [Householder matrix]: https://en.wikipedia.org/wiki/Householder_transformation19#[doc(alias = "householder")]20pub fn reflection_matrix(plane_normal: Vec3) -> Mat3A {21// N times Nᵀ.22let n_nt = Mat3A::from_cols(23Vec3A::from(plane_normal) * plane_normal.x,24Vec3A::from(plane_normal) * plane_normal.y,25Vec3A::from(plane_normal) * plane_normal.z,26);2728Mat3A::IDENTITY - n_nt * 2.029}303132