Type Definition nalgebra::geometry::IsometryMatrix2
source · Expand description
A 2-dimensional direct isometry using a rotation matrix for its rotational part.
Because this is an alias, not all its methods are listed here. See the Isometry
type too.
Also known as a rigid-body motion, or as an element of SE(2).
Implementations§
source§impl<T: SimdRealField> IsometryMatrix2<T>where
T::Element: SimdRealField,
impl<T: SimdRealField> IsometryMatrix2<T>where
T::Element: SimdRealField,
sourcepub fn new(translation: Vector2<T>, angle: T) -> Self
pub fn new(translation: Vector2<T>, angle: T) -> Self
Creates a new 2D isometry from a translation and a rotation angle.
Its rotational part is represented as a 2x2 rotation matrix.
Example
let iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
assert_eq!(iso * Point2::new(3.0, 4.0), Point2::new(-3.0, 5.0));
sourcepub fn translation(x: T, y: T) -> Self
pub fn translation(x: T, y: T) -> Self
Creates a new isometry from the given translation coordinates.
sourcepub fn cast<To: Scalar>(self) -> IsometryMatrix2<To>where
IsometryMatrix2<To>: SupersetOf<Self>,
pub fn cast<To: Scalar>(self) -> IsometryMatrix2<To>where
IsometryMatrix2<To>: SupersetOf<Self>,
Cast the components of self
to another type.
Example
let iso = IsometryMatrix2::<f64>::identity();
let iso2 = iso.cast::<f32>();
assert_eq!(iso2, IsometryMatrix2::<f32>::identity());
source§impl<T: SimdRealField> IsometryMatrix2<T>
impl<T: SimdRealField> IsometryMatrix2<T>
sourcepub fn lerp_slerp(&self, other: &Self, t: T) -> Selfwhere
T: RealField,
pub fn lerp_slerp(&self, other: &Self, t: T) -> Selfwhere
T: RealField,
Interpolates between two isometries using a linear interpolation for the translation part, and a spherical interpolation for the rotation part.
Panics if the angle between both rotations is 180 degrees (in which case the interpolation
is not well-defined). Use .try_lerp_slerp
instead to avoid the panic.
Examples:
let t1 = Translation2::new(1.0, 2.0);
let t2 = Translation2::new(4.0, 8.0);
let q1 = Rotation2::new(std::f32::consts::FRAC_PI_4);
let q2 = Rotation2::new(-std::f32::consts::PI);
let iso1 = IsometryMatrix2::from_parts(t1, q1);
let iso2 = IsometryMatrix2::from_parts(t2, q2);
let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0);
assert_eq!(iso3.translation.vector, Vector2::new(2.0, 4.0));
assert_relative_eq!(iso3.rotation.angle(), std::f32::consts::FRAC_PI_2);