From a32f41bd410a214a022d76adc60d09f67e52ad75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Thu, 25 Feb 2021 15:01:53 +0100 Subject: [PATCH] Fix compilation when targetting no-std. --- src/geometry/dual_quaternion.rs | 15 ++++++++++++--- src/geometry/dual_quaternion_construction.rs | 9 ++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/geometry/dual_quaternion.rs b/src/geometry/dual_quaternion.rs index cce0da2a..b11e7364 100644 --- a/src/geometry/dual_quaternion.rs +++ b/src/geometry/dual_quaternion.rs @@ -1,6 +1,6 @@ use crate::{ Isometry3, Matrix4, Normed, Point3, Quaternion, Scalar, SimdRealField, Translation3, Unit, - UnitQuaternion, Vector3, VectorN, U8, + UnitQuaternion, Vector3, VectorN, Zero, U8, }; use approx::{AbsDiffEq, RelativeEq, UlpsEq}; #[cfg(feature = "serde-serialize")] @@ -35,14 +35,23 @@ use simba::scalar::{ClosedNeg, RealField}; /// If a feature that you need is missing, feel free to open an issue or a PR. /// See https://github.com/dimforge/nalgebra/issues/487 #[repr(C)] -#[derive(Debug, Default, Eq, PartialEq, Copy, Clone)] -pub struct DualQuaternion { +#[derive(Debug, Eq, PartialEq, Copy, Clone)] +pub struct DualQuaternion { /// The real component of the quaternion pub real: Quaternion, /// The dual component of the quaternion pub dual: Quaternion, } +impl Default for DualQuaternion { + fn default() -> Self { + Self { + real: Quaternion::default(), + dual: Quaternion::default(), + } + } +} + impl DualQuaternion where N::Element: SimdRealField, diff --git a/src/geometry/dual_quaternion_construction.rs b/src/geometry/dual_quaternion_construction.rs index 95c208ce..b0ae8036 100644 --- a/src/geometry/dual_quaternion_construction.rs +++ b/src/geometry/dual_quaternion_construction.rs @@ -1,12 +1,12 @@ use crate::{ - DualQuaternion, Isometry3, Quaternion, SimdRealField, Translation3, UnitDualQuaternion, + DualQuaternion, Isometry3, Quaternion, Scalar, SimdRealField, Translation3, UnitDualQuaternion, UnitQuaternion, }; use num::{One, Zero}; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; -impl DualQuaternion { +impl DualQuaternion { /// Creates a dual quaternion from its rotation and translation components. /// /// # Example @@ -40,7 +40,10 @@ impl DualQuaternion { /// assert_eq!(dq2 * dq1, dq2); /// ``` #[inline] - pub fn identity() -> Self { + pub fn identity() -> Self + where + N: SimdRealField, + { Self::from_real_and_dual( Quaternion::from_real(N::one()), Quaternion::from_real(N::zero()),