Test identity multiplication
This commit is contained in:
parent
4d649c735b
commit
fa5971faa4
@ -57,6 +57,21 @@ impl From<[f32; 16]> for Matrix4x4 {
|
|||||||
|
|
||||||
impl Matrix4x4 {
|
impl Matrix4x4 {
|
||||||
/// Create a `Matrix4x4` containing the identity, all zeros with ones along the diagonal.
|
/// 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 {
|
pub fn identity() -> Matrix4x4 {
|
||||||
Matrix4x4::new(
|
Matrix4x4::new(
|
||||||
[1., 0., 0., 0.],
|
[1., 0., 0., 0.],
|
||||||
@ -264,7 +279,7 @@ impl Mul<Tuple> for Matrix4x4 {
|
|||||||
/// [8., 6., 4., 1.],
|
/// [8., 6., 4., 1.],
|
||||||
/// [0., 0., 0., 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.));
|
/// assert_eq!(a * b, Tuple::new(18., 24., 33., 1.));
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user