nalgebra/examples/transform_vector_point.rs

21 lines
721 B
Rust
Raw Normal View History

2017-02-13 01:17:09 +08:00
#[macro_use]
extern crate approx;
extern crate nalgebra as na;
use std::f32;
use na::{Vector2, Point2, Isometry2};
fn main() {
let t = Isometry2::new(Vector2::new(1.0, 1.0), f32::consts::PI);
let p = Point2::new(1.0, 0.0); // Will be affected by te rotation and the translation.
let v = Vector2::x(); // Will *not* be affected by the translation.
assert_relative_eq!(t * p, Point2::new(-1.0 + 1.0, 1.0));
// ^^^^ │ ^^^^^^^^
// rotated │ translated
assert_relative_eq!(t * v, Vector2::new(-1.0, 0.0));
// ^^^^^
// rotated only
}