Type Alias nalgebra::geometry::Isometry3

source ·
pub type Isometry3<T> = Isometry<T, UnitQuaternion<T>, 3>;
Expand description

A 3-dimensional direct isometry using a unit quaternion 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(3).

Aliased Type§

struct Isometry3<T> {
    pub rotation: Unit<Quaternion<T>>,
    pub translation: Translation<T, 3>,
}

Fields§

§rotation: Unit<Quaternion<T>>

The pure rotational part of this isometry.

§translation: Translation<T, 3>

The pure translational part of this isometry.

Implementations§

source§

impl<T: SimdRealField> Isometry3<T>

§Construction from a 3D vector and/or an axis-angle

source

pub fn new(translation: Vector3<T>, axisangle: Vector3<T>) -> Self

Creates a new isometry from a translation and a rotation axis-angle.

§Example
let axisangle = Vector3::y() * f32::consts::FRAC_PI_2;
let translation = Vector3::new(1.0, 2.0, 3.0);
// Point and vector being transformed in the tests.
let pt = Point3::new(4.0, 5.0, 6.0);
let vec = Vector3::new(4.0, 5.0, 6.0);

// Isometry with its rotation part represented as a UnitQuaternion
let iso = Isometry3::new(translation, axisangle);
assert_relative_eq!(iso * pt, Point3::new(7.0, 7.0, -1.0), epsilon = 1.0e-6);
assert_relative_eq!(iso * vec, Vector3::new(6.0, 5.0, -4.0), epsilon = 1.0e-6);

// Isometry with its rotation part represented as a Rotation3 (a 3x3 rotation matrix).
let iso = IsometryMatrix3::new(translation, axisangle);
assert_relative_eq!(iso * pt, Point3::new(7.0, 7.0, -1.0), epsilon = 1.0e-6);
assert_relative_eq!(iso * vec, Vector3::new(6.0, 5.0, -4.0), epsilon = 1.0e-6);
source

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

Creates a new isometry from the given translation coordinates.

source

pub fn rotation(axisangle: Vector3<T>) -> Self

Creates a new isometry from the given rotation angle.

source

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

Cast the components of self to another type.

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

impl<T: SimdRealField> Isometry3<T>

§Construction from a 3D eye position and target point

source

pub fn face_towards( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T> ) -> Self

Creates an isometry that corresponds to the local frame of an observer standing at the point eye and looking toward target.

It maps the z axis to the view direction target - eyeand the origin to the eye.

§Arguments
  • eye - The observer position.
  • target - The target position.
  • up - Vertical direction. The only requirement of this parameter is to not be collinear to eye - at. Non-collinearity is not checked.
§Example
let eye = Point3::new(1.0, 2.0, 3.0);
let target = Point3::new(2.0, 2.0, 3.0);
let up = Vector3::y();

// Isometry with its rotation part represented as a UnitQuaternion
let iso = Isometry3::face_towards(&eye, &target, &up);
assert_eq!(iso * Point3::origin(), eye);
assert_relative_eq!(iso * Vector3::z(), Vector3::x());

// Isometry with its rotation part represented as Rotation3 (a 3x3 rotation matrix).
let iso = IsometryMatrix3::face_towards(&eye, &target, &up);
assert_eq!(iso * Point3::origin(), eye);
assert_relative_eq!(iso * Vector3::z(), Vector3::x());
source

pub fn new_observer_frame( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T> ) -> Self

👎Deprecated: renamed to face_towards

Deprecated: Use Isometry::face_towards instead.

source

pub fn look_at_rh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self

Builds a right-handed look-at view matrix.

It maps the view direction target - eye to the negative z axis to and the eye to the origin. This conforms to the common notion of right handed camera look-at view matrix from the computer graphics community, i.e. the camera is assumed to look toward its local -z axis.

§Arguments
  • eye - The eye position.
  • target - The target position.
  • up - A vector approximately aligned with required the vertical axis. The only requirement of this parameter is to not be collinear to target - eye.
§Example
let eye = Point3::new(1.0, 2.0, 3.0);
let target = Point3::new(2.0, 2.0, 3.0);
let up = Vector3::y();

// Isometry with its rotation part represented as a UnitQuaternion
let iso = Isometry3::look_at_rh(&eye, &target, &up);
assert_eq!(iso * eye, Point3::origin());
assert_relative_eq!(iso * Vector3::x(), -Vector3::z());

// Isometry with its rotation part represented as Rotation3 (a 3x3 rotation matrix).
let iso = IsometryMatrix3::look_at_rh(&eye, &target, &up);
assert_eq!(iso * eye, Point3::origin());
assert_relative_eq!(iso * Vector3::x(), -Vector3::z());
source

pub fn look_at_lh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self

Builds a left-handed look-at view matrix.

It maps the view direction target - eye to the positive z axis and the eye to the origin. This conforms to the common notion of left handed camera look-at view matrix from the computer graphics community, i.e. the camera is assumed to look toward its local z axis.

§Arguments
  • eye - The eye position.
  • target - The target position.
  • up - A vector approximately aligned with required the vertical axis. The only requirement of this parameter is to not be collinear to target - eye.
§Example
let eye = Point3::new(1.0, 2.0, 3.0);
let target = Point3::new(2.0, 2.0, 3.0);
let up = Vector3::y();

// Isometry with its rotation part represented as a UnitQuaternion
let iso = Isometry3::look_at_lh(&eye, &target, &up);
assert_eq!(iso * eye, Point3::origin());
assert_relative_eq!(iso * Vector3::x(), Vector3::z());

// Isometry with its rotation part represented as Rotation3 (a 3x3 rotation matrix).
let iso = IsometryMatrix3::look_at_lh(&eye, &target, &up);
assert_eq!(iso * eye, Point3::origin());
assert_relative_eq!(iso * Vector3::x(), Vector3::z());
source§

impl<T: SimdRealField> Isometry3<T>

§Interpolation

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 = Translation3::new(1.0, 2.0, 3.0);
let t2 = Translation3::new(4.0, 8.0, 12.0);
let q1 = UnitQuaternion::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0);
let q2 = UnitQuaternion::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0);
let iso1 = Isometry3::from_parts(t1, q1);
let iso2 = Isometry3::from_parts(t2, q2);

let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0);

assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0));
assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0));
source

pub fn try_lerp_slerp(&self, other: &Self, t: T, epsilon: T) -> Option<Self>
where T: RealField,

Attempts to interpolate between two isometries using a linear interpolation for the translation part, and a spherical interpolation for the rotation part.

Returns None if the angle between both rotations is 180 degrees (in which case the interpolation is not well-defined).

§Examples:

let t1 = Translation3::new(1.0, 2.0, 3.0);
let t2 = Translation3::new(4.0, 8.0, 12.0);
let q1 = UnitQuaternion::from_euler_angles(std::f32::consts::FRAC_PI_4, 0.0, 0.0);
let q2 = UnitQuaternion::from_euler_angles(-std::f32::consts::PI, 0.0, 0.0);
let iso1 = Isometry3::from_parts(t1, q1);
let iso2 = Isometry3::from_parts(t2, q2);

let iso3 = iso1.lerp_slerp(&iso2, 1.0 / 3.0);

assert_eq!(iso3.translation.vector, Vector3::new(2.0, 4.0, 6.0));
assert_eq!(iso3.rotation.euler_angles(), (std::f32::consts::FRAC_PI_2, 0.0, 0.0));

Trait Implementations§

source§

impl<'a, 'b, T: SimdRealField> Div<&'b Unit<DualQuaternion<T>>> for &'a Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'b UnitDualQuaternion<T>) -> Self::Output

Performs the / operation. Read more
source§

impl<'b, T: SimdRealField> Div<&'b Unit<DualQuaternion<T>>> for Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &'b UnitDualQuaternion<T>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T: SimdRealField> Div<Unit<DualQuaternion<T>>> for &'a Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: UnitDualQuaternion<T>) -> Self::Output

Performs the / operation. Read more
source§

impl<T: SimdRealField> Div<Unit<DualQuaternion<T>>> for Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: UnitDualQuaternion<T>) -> Self::Output

Performs the / operation. Read more
source§

impl From<(DVec3, DQuat)> for Isometry3<f64>

source§

fn from((tra, rot): (DVec3, DQuat)) -> Self

Converts to this type from the input type.
source§

impl From<(Vec3, Quat)> for Isometry3<f32>

source§

fn from((tra, rot): (Vec3, Quat)) -> Self

Converts to this type from the input type.
source§

impl From<DQuat> for Isometry3<f64>

source§

fn from(rot: DQuat) -> Self

Converts to this type from the input type.
source§

impl From<DVec3> for Isometry3<f64>

source§

fn from(tra: DVec3) -> Self

Converts to this type from the input type.
source§

impl From<Quat> for Isometry3<f32>

source§

fn from(rot: Quat) -> Self

Converts to this type from the input type.
source§

impl<T: SimdRealField> From<Unit<DualQuaternion<T>>> for Isometry3<T>

source§

fn from(dq: UnitDualQuaternion<T>) -> Self

Converts to this type from the input type.
source§

impl From<Vec3> for Isometry3<f32>

source§

fn from(tra: Vec3) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for &'a Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b UnitDualQuaternion<T>) -> Self::Output

Performs the * operation. Read more
source§

impl<'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b UnitDualQuaternion<T>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for &'a Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: UnitDualQuaternion<T>) -> Self::Output

Performs the * operation. Read more
source§

impl<T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for Isometry3<T>

§

type Output = Unit<DualQuaternion<T>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: UnitDualQuaternion<T>) -> Self::Output

Performs the * operation. Read more
source§

impl<T1, T2> SubsetOf<Unit<DualQuaternion<T2>>> for Isometry3<T1>
where T1: RealField, T2: RealField + SupersetOf<T1>,

source§

fn to_superset(&self) -> UnitDualQuaternion<T2>

The inclusion map: converts self to the equivalent element of its superset.
source§

fn is_in_subset(dq: &UnitDualQuaternion<T2>) -> bool

Checks if element is actually part of the subset Self (and can be converted to it).
source§

fn from_superset_unchecked(dq: &UnitDualQuaternion<T2>) -> Self

Use with care! Same as self.to_superset but without any property checks. Always succeeds.
source§

fn from_superset(element: &T) -> Option<Self>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

impl TryFrom<DMat4> for Isometry3<f64>

§

type Error = ()

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

fn try_from(mat4: DMat4) -> Result<Isometry3<f64>, Self::Error>

Performs the conversion.
source§

impl TryFrom<Mat4> for Isometry3<f32>

§

type Error = ()

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

fn try_from(mat4: Mat4) -> Result<Isometry3<f32>, Self::Error>

Performs the conversion.