diff --git a/CHANGELOG.md b/CHANGELOG.md index b248ab25..281c8f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). `glam 0.18`. These can be enabled by enabling the `convert-glam018` cargo features. - Added the methods `Matrix::product`, `::row_product`, `::row_product_tr`, and `::column_product` to compute the product of the components, rows, or columns, of a single matrix or vector. +- The `Default` trait is now implemented for most geometric types: `Point`, `Isometry`, `Rotation`, `Similarity`, + `Transform`, `UnitComplex`, and `UnitQuaternion`. ## [0.29.0] ### Breaking changes diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index 9b855599..cce2932d 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -21,6 +21,15 @@ use crate::{ UnitQuaternion, }; +impl, const D: usize> Default for Isometry +where + T::Element: SimdRealField, +{ + fn default() -> Self { + Self::identity() + } +} + impl, const D: usize> Isometry where T::Element: SimdRealField, diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index e4e729aa..2136080a 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -19,6 +19,15 @@ use simba::scalar::{ClosedDiv, SupersetOf}; use crate::geometry::Point; +impl Default for OPoint +where + DefaultAllocator: Allocator, +{ + fn default() -> Self { + Self::origin() + } +} + /// # Other construction methods impl OPoint where diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 6de21bd5..8bf62e58 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -197,6 +197,15 @@ where } } +impl Default for UnitQuaternion +where + T::Element: SimdRealField, +{ + fn default() -> Self { + Self::identity() + } +} + impl UnitQuaternion where T::Element: SimdRealField, diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index 1fc033e4..84e42693 100644 --- a/src/geometry/rotation_construction.rs +++ b/src/geometry/rotation_construction.rs @@ -6,6 +6,15 @@ use crate::base::{SMatrix, Scalar}; use crate::geometry::Rotation; +impl Default for Rotation +where + T: Scalar + Zero + One, +{ + fn default() -> Self { + Self::identity() + } +} + /// # Identity impl Rotation where diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index feb5719b..8d1d38b8 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -20,6 +20,16 @@ use crate::{ Translation, UnitComplex, UnitQuaternion, }; +impl Default for Similarity +where + T::Element: SimdRealField, + R: AbstractRotation, +{ + fn default() -> Self { + Self::identity() + } +} + impl Similarity where T::Element: SimdRealField, diff --git a/src/geometry/transform_construction.rs b/src/geometry/transform_construction.rs index e9601864..45d61fcf 100644 --- a/src/geometry/transform_construction.rs +++ b/src/geometry/transform_construction.rs @@ -8,6 +8,16 @@ use crate::base::{Const, DefaultAllocator, OMatrix}; use crate::geometry::{TCategory, Transform}; +impl Default for Transform +where + Const: DimNameAdd, + DefaultAllocator: Allocator, U1>, DimNameSum, U1>>, +{ + fn default() -> Self { + Self::identity() + } +} + impl Transform where Const: DimNameAdd, diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index 5371b648..128937bf 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -15,6 +15,12 @@ use simba::scalar::{ClosedAdd, SupersetOf}; use crate::base::{SVector, Scalar}; use crate::geometry::Translation; +impl Default for Translation { + fn default() -> Self { + Self::identity() + } +} + impl Translation { /// Creates a new identity translation. /// diff --git a/src/geometry/unit_complex_construction.rs b/src/geometry/unit_complex_construction.rs index 0bf0188c..ebf4e81d 100644 --- a/src/geometry/unit_complex_construction.rs +++ b/src/geometry/unit_complex_construction.rs @@ -17,6 +17,15 @@ use crate::geometry::{Rotation2, UnitComplex}; use simba::scalar::{RealField, SupersetOf}; use simba::simd::SimdRealField; +impl Default for UnitComplex +where + T::Element: SimdRealField, +{ + fn default() -> Self { + Self::identity() + } +} + /// # Identity impl UnitComplex where