Function transform

Source
pub fn transform(points: &mut [Point<f32>], m: Isometry<f32>)
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::{Point, Isometry, Vector};
use parry3d::na::Translation3;

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

// Create a translation
let transform_iso = Isometry::from_parts(
    Translation3::new(10.0, 20.0, 30.0).into(),
    parry3d::na::UnitQuaternion::identity()
);

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

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