Implement Default for most geometry types
This commit is contained in:
parent
2f0ecf40d7
commit
7275b5146e
|
@ -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
|
||||
|
|
|
@ -21,6 +21,15 @@ use crate::{
|
|||
UnitQuaternion,
|
||||
};
|
||||
|
||||
impl<T: SimdRealField, R: AbstractRotation<T, D>, const D: usize> Default for Isometry<T, R, D>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SimdRealField, R: AbstractRotation<T, D>, const D: usize> Isometry<T, R, D>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
|
|
|
@ -19,6 +19,15 @@ use simba::scalar::{ClosedDiv, SupersetOf};
|
|||
|
||||
use crate::geometry::Point;
|
||||
|
||||
impl<T: Scalar + Zero, D: DimName> Default for OPoint<T, D>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D>,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::origin()
|
||||
}
|
||||
}
|
||||
|
||||
/// # Other construction methods
|
||||
impl<T: Scalar, D: DimName> OPoint<T, D>
|
||||
where
|
||||
|
|
|
@ -197,6 +197,15 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: SimdRealField> Default for UnitQuaternion<T>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SimdRealField> UnitQuaternion<T>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
|
|
|
@ -6,6 +6,15 @@ use crate::base::{SMatrix, Scalar};
|
|||
|
||||
use crate::geometry::Rotation;
|
||||
|
||||
impl<T, const D: usize> Default for Rotation<T, D>
|
||||
where
|
||||
T: Scalar + Zero + One,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
/// # Identity
|
||||
impl<T, const D: usize> Rotation<T, D>
|
||||
where
|
||||
|
|
|
@ -20,6 +20,16 @@ use crate::{
|
|||
Translation, UnitComplex, UnitQuaternion,
|
||||
};
|
||||
|
||||
impl<T: SimdRealField, R, const D: usize> Default for Similarity<T, R, D>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
R: AbstractRotation<T, D>,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: SimdRealField, R, const D: usize> Similarity<T, R, D>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
|
|
|
@ -8,6 +8,16 @@ use crate::base::{Const, DefaultAllocator, OMatrix};
|
|||
|
||||
use crate::geometry::{TCategory, Transform};
|
||||
|
||||
impl<T: RealField, C: TCategory, const D: usize> Default for Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RealField, C: TCategory, const D: usize> Transform<T, C, D>
|
||||
where
|
||||
Const<D>: DimNameAdd<U1>,
|
||||
|
|
|
@ -15,6 +15,12 @@ use simba::scalar::{ClosedAdd, SupersetOf};
|
|||
use crate::base::{SVector, Scalar};
|
||||
use crate::geometry::Translation;
|
||||
|
||||
impl<T: Scalar + Zero, const D: usize> Default for Translation<T, D> {
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Scalar, const D: usize> Translation<T, D> {
|
||||
/// Creates a new identity translation.
|
||||
///
|
||||
|
|
|
@ -17,6 +17,15 @@ use crate::geometry::{Rotation2, UnitComplex};
|
|||
use simba::scalar::{RealField, SupersetOf};
|
||||
use simba::simd::SimdRealField;
|
||||
|
||||
impl<T: SimdRealField> Default for UnitComplex<T>
|
||||
where
|
||||
T::Element: SimdRealField,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::identity()
|
||||
}
|
||||
}
|
||||
|
||||
/// # Identity
|
||||
impl<T: SimdRealField> UnitComplex<T>
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue