transformed

Function transformed 

Source
pub fn transformed(points: Vec<Vector>, m: Pose) -> Vec<Vector> 
Expand description

Returns the transformed version of a vector of points.

This function takes ownership of a vector of points, applies the given isometry transformation, and returns the transformed vector.

§Arguments

  • points - A vector of points to transform (ownership is taken)
  • m - The isometry (rigid transformation) to apply

§Returns

A new vector containing the transformed points

§Example

use parry2d::transformation::utils::transformed;
use parry2d::math::{Vector, Pose, Rotation};
use std::f32::consts::PI;

let points = vec![
    Vector::new(1.0, 0.0),
    Vector::new(0.0, 1.0),
];

// Rotate 90 degrees counter-clockwise around origin
let rotation = Rotation::new(PI / 2.0);
let transform = Pose::from_parts(Vector::ZERO, rotation);

let result = transformed(points, transform);

// Vectors are now rotated
assert!((result[0].x - 0.0).abs() < 1e-6);
assert!((result[0].y - 1.0).abs() < 1e-6);