forked from M-Labs/nalgebra
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.
|
`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
|
- 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.
|
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]
|
## [0.29.0]
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
@ -21,6 +21,15 @@ use crate::{
|
|||||||
UnitQuaternion,
|
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>
|
impl<T: SimdRealField, R: AbstractRotation<T, D>, const D: usize> Isometry<T, R, D>
|
||||||
where
|
where
|
||||||
T::Element: SimdRealField,
|
T::Element: SimdRealField,
|
||||||
|
@ -19,6 +19,15 @@ use simba::scalar::{ClosedDiv, SupersetOf};
|
|||||||
|
|
||||||
use crate::geometry::Point;
|
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
|
/// # Other construction methods
|
||||||
impl<T: Scalar, D: DimName> OPoint<T, D>
|
impl<T: Scalar, D: DimName> OPoint<T, D>
|
||||||
where
|
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>
|
impl<T: SimdRealField> UnitQuaternion<T>
|
||||||
where
|
where
|
||||||
T::Element: SimdRealField,
|
T::Element: SimdRealField,
|
||||||
|
@ -6,6 +6,15 @@ use crate::base::{SMatrix, Scalar};
|
|||||||
|
|
||||||
use crate::geometry::Rotation;
|
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
|
/// # Identity
|
||||||
impl<T, const D: usize> Rotation<T, D>
|
impl<T, const D: usize> Rotation<T, D>
|
||||||
where
|
where
|
||||||
|
@ -20,6 +20,16 @@ use crate::{
|
|||||||
Translation, UnitComplex, UnitQuaternion,
|
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>
|
impl<T: SimdRealField, R, const D: usize> Similarity<T, R, D>
|
||||||
where
|
where
|
||||||
T::Element: SimdRealField,
|
T::Element: SimdRealField,
|
||||||
|
@ -8,6 +8,16 @@ use crate::base::{Const, DefaultAllocator, OMatrix};
|
|||||||
|
|
||||||
use crate::geometry::{TCategory, Transform};
|
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>
|
impl<T: RealField, C: TCategory, const D: usize> Transform<T, C, D>
|
||||||
where
|
where
|
||||||
Const<D>: DimNameAdd<U1>,
|
Const<D>: DimNameAdd<U1>,
|
||||||
|
@ -15,6 +15,12 @@ use simba::scalar::{ClosedAdd, SupersetOf};
|
|||||||
use crate::base::{SVector, Scalar};
|
use crate::base::{SVector, Scalar};
|
||||||
use crate::geometry::Translation;
|
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> {
|
impl<T: Scalar, const D: usize> Translation<T, D> {
|
||||||
/// Creates a new identity translation.
|
/// Creates a new identity translation.
|
||||||
///
|
///
|
||||||
|
@ -17,6 +17,15 @@ use crate::geometry::{Rotation2, UnitComplex};
|
|||||||
use simba::scalar::{RealField, SupersetOf};
|
use simba::scalar::{RealField, SupersetOf};
|
||||||
use simba::simd::SimdRealField;
|
use simba::simd::SimdRealField;
|
||||||
|
|
||||||
|
impl<T: SimdRealField> Default for UnitComplex<T>
|
||||||
|
where
|
||||||
|
T::Element: SimdRealField,
|
||||||
|
{
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::identity()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// # Identity
|
/// # Identity
|
||||||
impl<T: SimdRealField> UnitComplex<T>
|
impl<T: SimdRealField> UnitComplex<T>
|
||||||
where
|
where
|
||||||
|
Loading…
Reference in New Issue
Block a user