nalgebra::geometry

Type Alias Isometry2

Source
pub type Isometry2<T> = Isometry<T, UnitComplex<T>, 2>;
Expand description

A 2-dimensional direct isometry using a unit complex number 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 2D rigid-body motion, or as an element of SE(2).

Aliased Type§

struct Isometry2<T> {
    pub rotation: Unit<Complex<T>>,
    pub translation: Translation<T, 2>,
}

Fields§

§rotation: Unit<Complex<T>>

The pure rotational part of this isometry.

§translation: Translation<T, 2>

The pure translational part of this isometry.

Implementations§

Source§

impl<T: SimdRealField> Isometry2<T>

Source

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 an unit complex number.

§Example
let iso = IsometryMatrix2::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));
Source

pub fn translation(x: T, y: T) -> Self

Creates a new isometry from the given translation coordinates.

Source

pub fn rotation(angle: T) -> Self

Creates a new isometry from the given rotation angle.

Source

pub fn cast<To: Scalar>(self) -> Isometry2<To>
where Isometry2<To>: SupersetOf<Self>,

Cast the components of self to another type.

§Example
let iso = Isometry2::<f64>::identity();
let iso2 = iso.cast::<f32>();
assert_eq!(iso2, Isometry2::<f32>::identity());
Source§

impl<T: SimdRealField> Isometry2<T>

Source

pub fn lerp_slerp(&self, other: &Self, t: T) -> Self
where 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 = UnitComplex::new(std::f32::consts::FRAC_PI_4);
let q2 = UnitComplex::new(-std::f32::consts::PI);
let iso1 = Isometry2::from_parts(t1, q1);
let iso2 = Isometry2::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);

Trait Implementations§

Source§

impl From<(DVec2, f64)> for Isometry2<f64>

Source§

fn from((tra, rot): (DVec2, f64)) -> Self

Converts to this type from the input type.
Source§

impl From<(Vec2, f32)> for Isometry2<f32>

Source§

fn from((tra, rot): (Vec2, f32)) -> Self

Converts to this type from the input type.
Source§

impl From<DVec2> for Isometry2<f64>

Source§

fn from(tra: DVec2) -> Self

Converts to this type from the input type.
Source§

impl From<Vec2> for Isometry2<f32>

Source§

fn from(tra: Vec2) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<DMat3> for Isometry2<f64>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(mat3: DMat3) -> Result<Isometry2<f64>, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Mat3> for Isometry2<f32>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(mat3: Mat3) -> Result<Isometry2<f32>, Self::Error>

Performs the conversion.