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>where
T::Element: SimdRealField,
impl<T: SimdRealField> Isometry3<T>where
T::Element: SimdRealField,
§Construction from a 3D vector and/or an axis-angle
sourcepub fn new(translation: Vector3<T>, axisangle: Vector3<T>) -> Self
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);
sourcepub fn translation(x: T, y: T, z: T) -> Self
pub fn translation(x: T, y: T, z: T) -> Self
Creates a new isometry from the given translation coordinates.
source§impl<T: SimdRealField> Isometry3<T>where
T::Element: SimdRealField,
impl<T: SimdRealField> Isometry3<T>where
T::Element: SimdRealField,
§Construction from a 3D eye position and target point
sourcepub fn face_towards(
eye: &Point3<T>,
target: &Point3<T>,
up: &Vector3<T>
) -> Self
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 - eye
and 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());
sourcepub fn new_observer_frame(
eye: &Point3<T>,
target: &Point3<T>,
up: &Vector3<T>
) -> Self
👎Deprecated: renamed to face_towards
pub fn new_observer_frame( eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T> ) -> Self
face_towards
Deprecated: Use Isometry::face_towards
instead.
sourcepub fn look_at_rh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
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());
sourcepub fn look_at_lh(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self
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>
impl<T: SimdRealField> Isometry3<T>
§Interpolation
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 = 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));
sourcepub fn try_lerp_slerp(&self, other: &Self, t: T, epsilon: T) -> Option<Self>where
T: RealField,
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>where
T::Element: SimdRealField,
impl<'a, 'b, T: SimdRealField> Div<&'b Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
/
operator.source§impl<'b, T: SimdRealField> Div<&'b Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> Div<&'b Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
/
operator.source§impl<'a, T: SimdRealField> Div<Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Div<Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
/
operator.source§impl<T: SimdRealField> Div<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
impl<T: SimdRealField> Div<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
/
operator.source§impl<T: SimdRealField> From<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
impl<T: SimdRealField> From<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
source§fn from(dq: UnitDualQuaternion<T>) -> Self
fn from(dq: UnitDualQuaternion<T>) -> Self
source§impl<'a, 'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
impl<'a, 'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
*
operator.source§impl<'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
impl<'b, T: SimdRealField> Mul<&'b Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
*
operator.source§impl<'a, T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
impl<'a, T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for &'a Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
*
operator.source§impl<T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
impl<T: SimdRealField> Mul<Unit<DualQuaternion<T>>> for Isometry3<T>where
T::Element: SimdRealField,
§type Output = Unit<DualQuaternion<T>>
type Output = Unit<DualQuaternion<T>>
*
operator.source§impl<T1, T2> SubsetOf<Unit<DualQuaternion<T2>>> for Isometry3<T1>
impl<T1, T2> SubsetOf<Unit<DualQuaternion<T2>>> for Isometry3<T1>
source§fn to_superset(&self) -> UnitDualQuaternion<T2>
fn to_superset(&self) -> UnitDualQuaternion<T2>
self
to the equivalent element of its superset.source§fn is_in_subset(dq: &UnitDualQuaternion<T2>) -> bool
fn is_in_subset(dq: &UnitDualQuaternion<T2>) -> bool
element
is actually part of the subset Self
(and can be converted to it).source§fn from_superset_unchecked(dq: &UnitDualQuaternion<T2>) -> Self
fn from_superset_unchecked(dq: &UnitDualQuaternion<T2>) -> Self
self.to_superset
but without any property checks. Always succeeds.