transform

Function transform 

Source
pub fn transform(points: &mut [Vector], m: Pose)
Expand description

Applies in-place a transformation to an array of points.

This function modifies each point in the slice by applying the given isometry (rigid transformation consisting of rotation and translation).

§Arguments

  • points - A mutable slice of points to transform
  • m - The isometry (rigid transformation) to apply

§Example

use parry3d::transformation::utils::transform;
use parry3d::math::{Vector, Pose, Rotation};

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

// Create a translation
let transform_iso = Pose::from_parts(
    Vector::new(10.0, 20.0, 30.0),
    Rotation::IDENTITY
);

// Apply the transformation in-place
transform(&mut points, transform_iso);

assert_eq!(points[0], Vector::new(11.0, 20.0, 30.0));
assert_eq!(points[1], Vector::new(10.0, 21.0, 30.0));
assert_eq!(points[2], Vector::new(10.0, 20.0, 31.0));