File: transform_vector_point.rs

package info (click to toggle)
rust-nalgebra 0.33.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,340 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[macro_use]
extern crate approx;
extern crate nalgebra as na;

use na::{Isometry2, Point2, Vector2};
use std::f32;

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
}