Skip to content

Commit

Permalink
Add tests for GridRotation::inverse().
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Oct 3, 2023
1 parent 78e1567 commit 3d4b154
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions all-is-cubes/src/math/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,32 @@ mod tests {
);
}

#[test]
fn inverse_axioms() {
assert_eq!(GridRotation::IDENTITY.inverse(), GridRotation::IDENTITY);
for rot in GridRotation::ALL {
assert_eq!(rot * rot.inverse(), GridRotation::IDENTITY, "{rot:?}");
assert_eq!(rot.inverse().inverse(), rot, "{rot:?}");
}
}

#[test]
fn inverse_effect() {
let v = GridVector::new(1, 5, 100);
for rot in GridRotation::ALL {
assert_eq!(
rot.transform_vector(rot.inverse().transform_vector(v)),
v,
"{rot:?}"
);
assert_eq!(
rot.inverse().transform_vector(rot.transform_vector(v)),
v,
"{rot:?}"
);
}
}

#[test]
fn is_reflection_consistency() {
for a in GridRotation::ALL {
Expand Down

0 comments on commit 3d4b154

Please sign in to comment.