| 1 |
#[macro_use] |
| 2 |
extern crate approx; |
| 3 |
extern crate nalgebra as na; |
| 4 |
|
| 5 |
use na::{Isometry2, Point2, Vector2}; |
| 6 |
use std::f32; |
| 7 |
|
| 8 |
fn main() { |
| 9 |
let t = Isometry2::new(Vector2::new(1.0, 1.0), f32::consts::PI); |
| 10 |
let p = Point2::new(1.0, 0.0); // Will be affected by te rotation and the translation. |
| 11 |
let v = Vector2::x(); // Will *not* be affected by the translation. |
| 12 |
|
| 13 |
assert_relative_eq!(t * p, Point2::new(-1.0 + 1.0, 1.0)); |
| 14 |
// ^^^^ │ ^^^^^^^^ |
| 15 |
// rotated │ translated |
| 16 |
|
| 17 |
assert_relative_eq!(t * v, Vector2::new(-1.0, 0.0)); |
| 18 |
// ^^^^^ |
| 19 |
// rotated only |
| 20 |
} |