diff --git a/rtchallenge/src/matrices.rs b/rtchallenge/src/matrices.rs index 6b32bbd..cb67bbc 100644 --- a/rtchallenge/src/matrices.rs +++ b/rtchallenge/src/matrices.rs @@ -57,6 +57,21 @@ impl From<[f32; 16]> for Matrix4x4 { impl Matrix4x4 { /// Create a `Matrix4x4` containing the identity, all zeros with ones along the diagonal. + /// # Examples + /// + /// ``` + /// use rtchallenge::matrices::Matrix4x4; + /// + /// let a = Matrix4x4::new( + /// [0., 1., 2., 3.], + /// [1., 2., 4., 8.], + /// [2., 4., 8., 16.], + /// [4., 8., 16., 32.], + /// ); + /// let i = Matrix4x4::identity(); + /// + /// assert_eq!(a * i, a); + /// ``` pub fn identity() -> Matrix4x4 { Matrix4x4::new( [1., 0., 0., 0.], @@ -264,7 +279,7 @@ impl Mul for Matrix4x4 { /// [8., 6., 4., 1.], /// [0., 0., 0., 1.], /// ); - /// let b = Tuple::new(1.,2.,3.,1.); + /// let b = Tuple::new(1., 2., 3., 1.); /// /// assert_eq!(a * b, Tuple::new(18., 24., 33., 1.)); /// ```