diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 3ff06e89..8aa1a7bf 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -48,6 +48,19 @@ where /// Renamed to [ArrayStorage]. pub type MatrixArray = ArrayStorage; +impl Default for ArrayStorage +where + R: DimName, + C: DimName, + R::Value: Mul, + Prod: ArrayLength, + N: Default, +{ + fn default() -> Self { + ArrayStorage { data: Default::default() } + } +} + impl Hash for ArrayStorage where N: Hash, diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 783f8c19..e4821bf8 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -94,6 +94,21 @@ impl fmt::Debug for Matrix } } +impl Default for Matrix +where + N: Scalar, + R: Dim, + C: Dim, + S: Default, +{ + fn default() -> Self { + Matrix { + data: Default::default(), + _phantoms: PhantomData, + } + } +} + #[cfg(feature = "serde-serialize")] impl Serialize for Matrix where diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 45a03c78..c4f1617a 100755 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -33,6 +33,14 @@ pub struct Quaternion { pub coords: Vector4, } +impl Default for Quaternion { + fn default() -> Self { + Quaternion { + coords: Vector4::zeros() + } + } +} + #[cfg(feature = "abomonation-serialize")] impl Abomonation for Quaternion where @@ -1536,6 +1544,12 @@ where } } +impl Default for UnitQuaternion { + fn default() -> Self { + Self::identity() + } +} + impl fmt::Display for UnitQuaternion { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(axis) = self.axis() {