#![allow(clippy::float_cmp)]
use affine_rs::Affine;
#[test]
fn default_is_identity() {
assert_eq!(Affine::default(), Affine::IDENTITY);
}
#[test]
fn constructs_common_transforms() {
assert_eq!(
Affine::translation(1.0, 5.0),
Affine::new(1.0, 0.0, 1.0, 0.0, 1.0, 5.0)
);
assert_eq!(
Affine::scale(2.0, 3.0),
Affine::new(2.0, 0.0, 0.0, 0.0, 3.0, 0.0)
);
assert_eq!(
Affine::permutation(),
Affine::new(0.0, 1.0, 0.0, 1.0, 0.0, 0.0)
);
}
#[test]
fn rotation_has_exact_right_angles() {
assert_eq!(
Affine::rotation(90.0),
Affine::new(0.0, -1.0, 0.0, 1.0, 0.0, 0.0)
);
assert_eq!(
Affine::rotation(-90.0),
Affine::new(0.0, 1.0, 0.0, -1.0, 0.0, 0.0)
);
}
#[test]
fn rotates_around_pivot() {
let transform = Affine::rotation_around(90.0, [1.0, 1.0]);
assert_eq!(transform.transform_point([2.0, 1.0]), [1.0, 2.0]);
}