nalgebra/geometry/
isometry.rs

1use approx::{AbsDiffEq, RelativeEq, UlpsEq};
2use std::fmt;
3use std::hash;
4
5#[cfg(feature = "serde-serialize-no-std")]
6use serde::{Deserialize, Serialize};
7
8use simba::scalar::{RealField, SubsetOf};
9use simba::simd::SimdRealField;
10
11use crate::base::allocator::Allocator;
12use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
13use crate::base::storage::Owned;
14use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar, Unit};
15use crate::geometry::{AbstractRotation, Point, Translation};
16
17use crate::{Isometry3, Quaternion, Vector3, Vector4};
18
19#[cfg(feature = "rkyv-serialize")]
20use rkyv::bytecheck;
21
22/// A direct isometry, i.e., a rotation followed by a translation (aka. a rigid-body motion).
23///
24/// This is also known as an element of a Special Euclidean (SE) group.
25/// The `Isometry` type can either represent a 2D or 3D isometry.
26/// A 2D isometry is composed of:
27/// - A translation part of type [`Translation2`](crate::Translation2)
28/// - A rotation part which can either be a [`UnitComplex`](crate::UnitComplex) or a [`Rotation2`](crate::Rotation2).
29///
30/// A 3D isometry is composed of:
31/// - A translation part of type [`Translation3`](crate::Translation3)
32/// - A rotation part which can either be a [`UnitQuaternion`](crate::UnitQuaternion) or a [`Rotation3`](crate::Rotation3).
33///
34/// Note that instead of using the [`Isometry`](crate::Isometry) type in your code directly, you should use one
35/// of its aliases: [`Isometry2`](crate::Isometry2), [`Isometry3`](crate::Isometry3),
36/// [`IsometryMatrix2`](crate::IsometryMatrix2), [`IsometryMatrix3`](crate::IsometryMatrix3). Though
37/// keep in mind that all the documentation of all the methods of these aliases will also appears on
38/// this page.
39///
40/// # Construction
41/// * [From a 2D vector and/or an angle <span style="float:right;">`new`, `translation`, `rotation`…</span>](#construction-from-a-2d-vector-andor-a-rotation-angle)
42/// * [From a 3D vector and/or an axis-angle <span style="float:right;">`new`, `translation`, `rotation`…</span>](#construction-from-a-3d-vector-andor-an-axis-angle)
43/// * [From a 3D eye position and target point <span style="float:right;">`look_at`, `look_at_lh`, `face_towards`…</span>](#construction-from-a-3d-eye-position-and-target-point)
44/// * [From the translation and rotation parts <span style="float:right;">`from_parts`…</span>](#from-the-translation-and-rotation-parts)
45///
46/// # Transformation and composition
47/// Note that transforming vectors and points can be done by multiplication, e.g., `isometry * point`.
48/// Composing an isometry with another transformation can also be done by multiplication or division.
49///
50/// * [Transformation of a vector or a point <span style="float:right;">`transform_vector`, `inverse_transform_point`…</span>](#transformation-of-a-vector-or-a-point)
51/// * [Inversion and in-place composition <span style="float:right;">`inverse`, `append_rotation_wrt_point_mut`…</span>](#inversion-and-in-place-composition)
52/// * [Interpolation <span style="float:right;">`lerp_slerp`…</span>](#interpolation)
53///
54/// # Conversion to a matrix
55/// * [Conversion to a matrix <span style="float:right;">`to_matrix`…</span>](#conversion-to-a-matrix)
56///
57#[repr(C)]
58#[derive(Debug, Copy, Clone)]
59#[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))]
60#[cfg_attr(
61    feature = "serde-serialize-no-std",
62    serde(bound(serialize = "R: Serialize,
63                     DefaultAllocator: Allocator<Const<D>>,
64                     Owned<T, Const<D>>: Serialize,
65                     T: Scalar"))
66)]
67#[cfg_attr(
68    feature = "serde-serialize-no-std",
69    serde(bound(deserialize = "R: Deserialize<'de>,
70                       DefaultAllocator: Allocator<Const<D>>,
71                       Owned<T, Const<D>>: Deserialize<'de>,
72                       T: Scalar"))
73)]
74#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
75#[cfg_attr(
76    feature = "rkyv-serialize-no-std",
77    derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
78    archive(
79        as = "Isometry<T::Archived, R::Archived, D>",
80        bound(archive = "
81        T: rkyv::Archive,
82        R: rkyv::Archive,
83        Translation<T, D>: rkyv::Archive<Archived = Translation<T::Archived, D>>
84    ")
85    )
86)]
87pub struct Isometry<T, R, const D: usize> {
88    /// The pure rotational part of this isometry.
89    pub rotation: R,
90    /// The pure translational part of this isometry.
91    pub translation: Translation<T, D>,
92}
93
94impl<T: Scalar + hash::Hash, R: hash::Hash, const D: usize> hash::Hash for Isometry<T, R, D>
95where
96    Owned<T, Const<D>>: hash::Hash,
97{
98    fn hash<H: hash::Hasher>(&self, state: &mut H) {
99        self.translation.hash(state);
100        self.rotation.hash(state);
101    }
102}
103
104#[cfg(feature = "bytemuck")]
105unsafe impl<T: Scalar, R, const D: usize> bytemuck::Zeroable for Isometry<T, R, D>
106where
107    SVector<T, D>: bytemuck::Zeroable,
108    R: bytemuck::Zeroable,
109{
110}
111
112#[cfg(feature = "bytemuck")]
113unsafe impl<T: Scalar, R, const D: usize> bytemuck::Pod for Isometry<T, R, D>
114where
115    SVector<T, D>: bytemuck::Pod,
116    R: bytemuck::Pod,
117    T: Copy,
118{
119}
120
121/// # From the translation and rotation parts
122impl<T: Scalar, R: AbstractRotation<T, D>, const D: usize> Isometry<T, R, D> {
123    /// Creates a new isometry from its rotational and translational parts.
124    ///
125    /// # Example
126    ///
127    /// ```
128    /// # #[macro_use] extern crate approx;
129    /// # use std::f32;
130    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3, Point3};
131    /// let tra = Translation3::new(0.0, 0.0, 3.0);
132    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::y() * f32::consts::PI);
133    /// let iso = Isometry3::from_parts(tra, rot);
134    ///
135    /// assert_relative_eq!(iso * Point3::new(1.0, 2.0, 3.0), Point3::new(-1.0, 2.0, 0.0), epsilon = 1.0e-6);
136    /// ```
137    #[inline]
138    pub fn from_parts(translation: Translation<T, D>, rotation: R) -> Self {
139        Self {
140            rotation,
141            translation,
142        }
143    }
144}
145
146/// # Inversion and in-place composition
147impl<T: SimdRealField, R: AbstractRotation<T, D>, const D: usize> Isometry<T, R, D>
148where
149    T::Element: SimdRealField,
150{
151    /// Inverts `self`.
152    ///
153    /// # Example
154    ///
155    /// ```
156    /// # use std::f32;
157    /// # use nalgebra::{Isometry2, Point2, Vector2};
158    /// let iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
159    /// let inv = iso.inverse();
160    /// let pt = Point2::new(1.0, 2.0);
161    ///
162    /// assert_eq!(inv * (iso * pt), pt);
163    /// ```
164    #[inline]
165    #[must_use = "Did you mean to use inverse_mut()?"]
166    pub fn inverse(&self) -> Self {
167        let mut res = self.clone();
168        res.inverse_mut();
169        res
170    }
171
172    /// Inverts `self` in-place.
173    ///
174    /// # Example
175    ///
176    /// ```
177    /// # use std::f32;
178    /// # use nalgebra::{Isometry2, Point2, Vector2};
179    /// let mut iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
180    /// let pt = Point2::new(1.0, 2.0);
181    /// let transformed_pt = iso * pt;
182    /// iso.inverse_mut();
183    ///
184    /// assert_eq!(iso * transformed_pt, pt);
185    /// ```
186    #[inline]
187    pub fn inverse_mut(&mut self) {
188        self.rotation.inverse_mut();
189        self.translation.inverse_mut();
190        self.translation.vector = self.rotation.transform_vector(&self.translation.vector);
191    }
192
193    /// Computes `self.inverse() * rhs` in a more efficient way.
194    ///
195    /// # Example
196    ///
197    /// ```
198    /// # use std::f32;
199    /// # use nalgebra::{Isometry2, Point2, Vector2};
200    /// let mut iso1 = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
201    /// let mut iso2 = Isometry2::new(Vector2::new(10.0, 20.0), f32::consts::FRAC_PI_4);
202    ///
203    /// assert_eq!(iso1.inverse() * iso2, iso1.inv_mul(&iso2));
204    /// ```
205    #[inline]
206    #[must_use]
207    pub fn inv_mul(&self, rhs: &Isometry<T, R, D>) -> Self {
208        let inv_rot1 = self.rotation.inverse();
209        let tr_12 = &rhs.translation.vector - &self.translation.vector;
210        Isometry::from_parts(
211            inv_rot1.transform_vector(&tr_12).into(),
212            inv_rot1 * rhs.rotation.clone(),
213        )
214    }
215
216    /// Appends to `self` the given translation in-place.
217    ///
218    /// # Example
219    ///
220    /// ```
221    /// # use std::f32;
222    /// # use nalgebra::{Isometry2, Translation2, Vector2};
223    /// let mut iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
224    /// let tra = Translation2::new(3.0, 4.0);
225    /// // Same as `iso = tra * iso`.
226    /// iso.append_translation_mut(&tra);
227    ///
228    /// assert_eq!(iso.translation, Translation2::new(4.0, 6.0));
229    /// ```
230    #[inline]
231    pub fn append_translation_mut(&mut self, t: &Translation<T, D>) {
232        self.translation.vector += &t.vector
233    }
234
235    /// Appends to `self` the given rotation in-place.
236    ///
237    /// # Example
238    ///
239    /// ```
240    /// # #[macro_use] extern crate approx;
241    /// # use std::f32;
242    /// # use nalgebra::{Isometry2, Translation2, UnitComplex, Vector2};
243    /// let mut iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::PI / 6.0);
244    /// let rot = UnitComplex::new(f32::consts::PI / 2.0);
245    /// // Same as `iso = rot * iso`.
246    /// iso.append_rotation_mut(&rot);
247    ///
248    /// assert_relative_eq!(iso, Isometry2::new(Vector2::new(-2.0, 1.0), f32::consts::PI * 2.0 / 3.0), epsilon = 1.0e-6);
249    /// ```
250    #[inline]
251    pub fn append_rotation_mut(&mut self, r: &R) {
252        self.rotation = r.clone() * self.rotation.clone();
253        self.translation.vector = r.transform_vector(&self.translation.vector);
254    }
255
256    /// Appends in-place to `self` a rotation centered at the point `p`, i.e., the rotation that
257    /// lets `p` invariant.
258    ///
259    /// # Example
260    ///
261    /// ```
262    /// # #[macro_use] extern crate approx;
263    /// # use std::f32;
264    /// # use nalgebra::{Isometry2, Translation2, UnitComplex, Vector2, Point2};
265    /// let mut iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
266    /// let rot = UnitComplex::new(f32::consts::FRAC_PI_2);
267    /// let pt = Point2::new(1.0, 0.0);
268    /// iso.append_rotation_wrt_point_mut(&rot, &pt);
269    ///
270    /// assert_relative_eq!(iso * pt, Point2::new(-2.0, 0.0), epsilon = 1.0e-6);
271    /// ```
272    #[inline]
273    pub fn append_rotation_wrt_point_mut(&mut self, r: &R, p: &Point<T, D>) {
274        self.translation.vector -= &p.coords;
275        self.append_rotation_mut(r);
276        self.translation.vector += &p.coords;
277    }
278
279    /// Appends in-place to `self` a rotation centered at the point with coordinates
280    /// `self.translation`.
281    ///
282    /// # Example
283    ///
284    /// ```
285    /// # use std::f32;
286    /// # use nalgebra::{Isometry2, Translation2, UnitComplex, Vector2, Point2};
287    /// let mut iso = Isometry2::new(Vector2::new(1.0, 2.0), f32::consts::FRAC_PI_2);
288    /// let rot = UnitComplex::new(f32::consts::FRAC_PI_2);
289    /// iso.append_rotation_wrt_center_mut(&rot);
290    ///
291    /// // The translation part should not have changed.
292    /// assert_eq!(iso.translation.vector, Vector2::new(1.0, 2.0));
293    /// assert_eq!(iso.rotation, UnitComplex::new(f32::consts::PI));
294    /// ```
295    #[inline]
296    pub fn append_rotation_wrt_center_mut(&mut self, r: &R) {
297        self.rotation = r.clone() * self.rotation.clone();
298    }
299}
300
301/// # Transformation of a vector or a point
302impl<T: SimdRealField, R: AbstractRotation<T, D>, const D: usize> Isometry<T, R, D>
303where
304    T::Element: SimdRealField,
305{
306    /// Transform the given point by this isometry.
307    ///
308    /// This is the same as the multiplication `self * pt`.
309    ///
310    /// # Example
311    ///
312    /// ```
313    /// # #[macro_use] extern crate approx;
314    /// # use std::f32;
315    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3, Point3};
316    /// let tra = Translation3::new(0.0, 0.0, 3.0);
317    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::y() * f32::consts::FRAC_PI_2);
318    /// let iso = Isometry3::from_parts(tra, rot);
319    ///
320    /// let transformed_point = iso.transform_point(&Point3::new(1.0, 2.0, 3.0));
321    /// assert_relative_eq!(transformed_point, Point3::new(3.0, 2.0, 2.0), epsilon = 1.0e-6);
322    /// ```
323    #[inline]
324    #[must_use]
325    pub fn transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {
326        self * pt
327    }
328
329    /// Transform the given vector by this isometry, ignoring the translation
330    /// component of the isometry.
331    ///
332    /// This is the same as the multiplication `self * v`.
333    ///
334    /// # Example
335    ///
336    /// ```
337    /// # #[macro_use] extern crate approx;
338    /// # use std::f32;
339    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3};
340    /// let tra = Translation3::new(0.0, 0.0, 3.0);
341    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::y() * f32::consts::FRAC_PI_2);
342    /// let iso = Isometry3::from_parts(tra, rot);
343    ///
344    /// let transformed_point = iso.transform_vector(&Vector3::new(1.0, 2.0, 3.0));
345    /// assert_relative_eq!(transformed_point, Vector3::new(3.0, 2.0, -1.0), epsilon = 1.0e-6);
346    /// ```
347    #[inline]
348    #[must_use]
349    pub fn transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
350        self * v
351    }
352
353    /// Transform the given point by the inverse of this isometry. This may be
354    /// less expensive than computing the entire isometry inverse and then
355    /// transforming the point.
356    ///
357    /// # Example
358    ///
359    /// ```
360    /// # #[macro_use] extern crate approx;
361    /// # use std::f32;
362    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3, Point3};
363    /// let tra = Translation3::new(0.0, 0.0, 3.0);
364    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::y() * f32::consts::FRAC_PI_2);
365    /// let iso = Isometry3::from_parts(tra, rot);
366    ///
367    /// let transformed_point = iso.inverse_transform_point(&Point3::new(1.0, 2.0, 3.0));
368    /// assert_relative_eq!(transformed_point, Point3::new(0.0, 2.0, 1.0), epsilon = 1.0e-6);
369    /// ```
370    #[inline]
371    #[must_use]
372    pub fn inverse_transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {
373        self.rotation
374            .inverse_transform_point(&(pt - &self.translation.vector))
375    }
376
377    /// Transform the given vector by the inverse of this isometry, ignoring the
378    /// translation component of the isometry. This may be
379    /// less expensive than computing the entire isometry inverse and then
380    /// transforming the point.
381    ///
382    /// # Example
383    ///
384    /// ```
385    /// # #[macro_use] extern crate approx;
386    /// # use std::f32;
387    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3};
388    /// let tra = Translation3::new(0.0, 0.0, 3.0);
389    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::y() * f32::consts::FRAC_PI_2);
390    /// let iso = Isometry3::from_parts(tra, rot);
391    ///
392    /// let transformed_point = iso.inverse_transform_vector(&Vector3::new(1.0, 2.0, 3.0));
393    /// assert_relative_eq!(transformed_point, Vector3::new(-3.0, 2.0, 1.0), epsilon = 1.0e-6);
394    /// ```
395    #[inline]
396    #[must_use]
397    pub fn inverse_transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
398        self.rotation.inverse_transform_vector(v)
399    }
400
401    /// Transform the given unit vector by the inverse of this isometry, ignoring the
402    /// translation component of the isometry. This may be
403    /// less expensive than computing the entire isometry inverse and then
404    /// transforming the point.
405    ///
406    /// # Example
407    ///
408    /// ```
409    /// # #[macro_use] extern crate approx;
410    /// # use std::f32;
411    /// # use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3};
412    /// let tra = Translation3::new(0.0, 0.0, 3.0);
413    /// let rot = UnitQuaternion::from_scaled_axis(Vector3::z() * f32::consts::FRAC_PI_2);
414    /// let iso = Isometry3::from_parts(tra, rot);
415    ///
416    /// let transformed_point = iso.inverse_transform_unit_vector(&Vector3::x_axis());
417    /// assert_relative_eq!(transformed_point, -Vector3::y_axis(), epsilon = 1.0e-6);
418    /// ```
419    #[inline]
420    #[must_use]
421    pub fn inverse_transform_unit_vector(&self, v: &Unit<SVector<T, D>>) -> Unit<SVector<T, D>> {
422        self.rotation.inverse_transform_unit_vector(v)
423    }
424}
425
426// NOTE: we don't require `R: Rotation<...>` here because this is not useful for the implementation
427// and makes it hard to use it, e.g., for Transform × Isometry implementation.
428// This is OK since all constructors of the isometry enforce the Rotation bound already (and
429// explicit struct construction is prevented by the dummy ZST field).
430/// # Conversion to a matrix
431impl<T: SimdRealField, R, const D: usize> Isometry<T, R, D> {
432    /// Converts this isometry into its equivalent homogeneous transformation matrix.
433    ///
434    /// This is the same as `self.to_matrix()`.
435    ///
436    /// # Example
437    ///
438    /// ```
439    /// # #[macro_use] extern crate approx;
440    /// # use std::f32;
441    /// # use nalgebra::{Isometry2, Vector2, Matrix3};
442    /// let iso = Isometry2::new(Vector2::new(10.0, 20.0), f32::consts::FRAC_PI_6);
443    /// let expected = Matrix3::new(0.8660254, -0.5,      10.0,
444    ///                             0.5,       0.8660254, 20.0,
445    ///                             0.0,       0.0,       1.0);
446    ///
447    /// assert_relative_eq!(iso.to_homogeneous(), expected, epsilon = 1.0e-6);
448    /// ```
449    #[inline]
450    #[must_use]
451    pub fn to_homogeneous(&self) -> OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
452    where
453        Const<D>: DimNameAdd<U1>,
454        R: SubsetOf<OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>>,
455        DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
456    {
457        let mut res: OMatrix<T, _, _> = crate::convert_ref(&self.rotation);
458        res.fixed_view_mut::<D, 1>(0, D)
459            .copy_from(&self.translation.vector);
460
461        res
462    }
463
464    /// Converts this isometry into its equivalent homogeneous transformation matrix.
465    ///
466    /// This is the same as `self.to_homogeneous()`.
467    ///
468    /// # Example
469    ///
470    /// ```
471    /// # #[macro_use] extern crate approx;
472    /// # use std::f32;
473    /// # use nalgebra::{Isometry2, Vector2, Matrix3};
474    /// let iso = Isometry2::new(Vector2::new(10.0, 20.0), f32::consts::FRAC_PI_6);
475    /// let expected = Matrix3::new(0.8660254, -0.5,      10.0,
476    ///                             0.5,       0.8660254, 20.0,
477    ///                             0.0,       0.0,       1.0);
478    ///
479    /// assert_relative_eq!(iso.to_matrix(), expected, epsilon = 1.0e-6);
480    /// ```
481    #[inline]
482    #[must_use]
483    pub fn to_matrix(&self) -> OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
484    where
485        Const<D>: DimNameAdd<U1>,
486        R: SubsetOf<OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>>,
487        DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
488    {
489        self.to_homogeneous()
490    }
491}
492
493impl<T: SimdRealField, R, const D: usize> Eq for Isometry<T, R, D> where
494    R: AbstractRotation<T, D> + Eq
495{
496}
497
498impl<T: SimdRealField, R, const D: usize> PartialEq for Isometry<T, R, D>
499where
500    R: AbstractRotation<T, D> + PartialEq,
501{
502    #[inline]
503    fn eq(&self, right: &Self) -> bool {
504        self.translation == right.translation && self.rotation == right.rotation
505    }
506}
507
508impl<T: RealField, R, const D: usize> AbsDiffEq for Isometry<T, R, D>
509where
510    R: AbstractRotation<T, D> + AbsDiffEq<Epsilon = T::Epsilon>,
511    T::Epsilon: Clone,
512{
513    type Epsilon = T::Epsilon;
514
515    #[inline]
516    fn default_epsilon() -> Self::Epsilon {
517        T::default_epsilon()
518    }
519
520    #[inline]
521    fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
522        self.translation
523            .abs_diff_eq(&other.translation, epsilon.clone())
524            && self.rotation.abs_diff_eq(&other.rotation, epsilon)
525    }
526}
527
528impl<T: RealField, R, const D: usize> RelativeEq for Isometry<T, R, D>
529where
530    R: AbstractRotation<T, D> + RelativeEq<Epsilon = T::Epsilon>,
531    T::Epsilon: Clone,
532{
533    #[inline]
534    fn default_max_relative() -> Self::Epsilon {
535        T::default_max_relative()
536    }
537
538    #[inline]
539    fn relative_eq(
540        &self,
541        other: &Self,
542        epsilon: Self::Epsilon,
543        max_relative: Self::Epsilon,
544    ) -> bool {
545        self.translation
546            .relative_eq(&other.translation, epsilon.clone(), max_relative.clone())
547            && self
548                .rotation
549                .relative_eq(&other.rotation, epsilon, max_relative)
550    }
551}
552
553impl<T: RealField, R, const D: usize> UlpsEq for Isometry<T, R, D>
554where
555    R: AbstractRotation<T, D> + UlpsEq<Epsilon = T::Epsilon>,
556    T::Epsilon: Clone,
557{
558    #[inline]
559    fn default_max_ulps() -> u32 {
560        T::default_max_ulps()
561    }
562
563    #[inline]
564    fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
565        self.translation
566            .ulps_eq(&other.translation, epsilon.clone(), max_ulps)
567            && self.rotation.ulps_eq(&other.rotation, epsilon, max_ulps)
568    }
569}
570
571/*
572 *
573 * Display
574 *
575 */
576impl<T: RealField + fmt::Display, R, const D: usize> fmt::Display for Isometry<T, R, D>
577where
578    R: fmt::Display,
579{
580    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
581        let precision = f.precision().unwrap_or(3);
582
583        writeln!(f, "Isometry {{")?;
584        write!(f, "{:.*}", precision, self.translation)?;
585        write!(f, "{:.*}", precision, self.rotation)?;
586        writeln!(f, "}}")
587    }
588}