Fix warnings and compilation with the `arbitrary` feature.
This commit is contained in:
parent
c9bedc80dd
commit
191ccbf551
|
@ -3,7 +3,6 @@ use std::fmt;
|
||||||
use std::hash;
|
use std::hash;
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use std::io::{Result as IOResult, Write};
|
use std::io::{Result as IOResult, Write};
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -37,7 +36,8 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
||||||
Owned<N, D>: Deserialize<'de>"))
|
Owned<N, D>: Deserialize<'de>"))
|
||||||
)]
|
)]
|
||||||
pub struct Isometry<N: Scalar, D: DimName, R>
|
pub struct Isometry<N: Scalar, D: DimName, R>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// The pure rotational part of this isometry.
|
/// The pure rotational part of this isometry.
|
||||||
pub rotation: R,
|
pub rotation: R,
|
||||||
|
@ -91,7 +91,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar, D: DimName, R: AbstractRotation<N, D> + Clone> Clone for Isometry<N, D, R>
|
impl<N: Scalar, D: DimName, R: AbstractRotation<N, D> + Clone> Clone for Isometry<N, D, R>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
|
@ -100,7 +101,8 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar, D: DimName, R: AbstractRotation<N, D>> Isometry<N, D, R>
|
impl<N: Scalar, D: DimName, R: AbstractRotation<N, D>> Isometry<N, D, R>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// Creates a new isometry from its rotational and translational parts.
|
/// Creates a new isometry from its rotational and translational parts.
|
||||||
///
|
///
|
||||||
|
@ -353,7 +355,8 @@ where
|
||||||
// This is OK since all constructors of the isometry enforce the Rotation bound already (and
|
// This is OK since all constructors of the isometry enforce the Rotation bound already (and
|
||||||
// explicit struct construction is prevented by the dummy ZST field).
|
// explicit struct construction is prevented by the dummy ZST field).
|
||||||
impl<N: SimdRealField, D: DimName, R> Isometry<N, D, R>
|
impl<N: SimdRealField, D: DimName, R> Isometry<N, D, R>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// Converts this isometry into its equivalent homogeneous transformation matrix.
|
/// Converts this isometry into its equivalent homogeneous transformation matrix.
|
||||||
///
|
///
|
||||||
|
@ -440,8 +443,7 @@ where
|
||||||
other: &Self,
|
other: &Self,
|
||||||
epsilon: Self::Epsilon,
|
epsilon: Self::Epsilon,
|
||||||
max_relative: Self::Epsilon,
|
max_relative: Self::Epsilon,
|
||||||
) -> bool
|
) -> bool {
|
||||||
{
|
|
||||||
self.translation
|
self.translation
|
||||||
.relative_eq(&other.translation, epsilon, max_relative)
|
.relative_eq(&other.translation, epsilon, max_relative)
|
||||||
&& self
|
&& self
|
||||||
|
|
|
@ -2,7 +2,7 @@ use simba::simd::SimdValue;
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::DimName;
|
use crate::base::dimension::DimName;
|
||||||
use crate::base::{DefaultAllocator, Scalar};
|
use crate::base::DefaultAllocator;
|
||||||
use crate::SimdRealField;
|
use crate::SimdRealField;
|
||||||
|
|
||||||
use crate::geometry::{AbstractRotation, Isometry, Translation};
|
use crate::geometry::{AbstractRotation, Isometry, Translation};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf};
|
use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf};
|
||||||
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
use simba::simd::PrimitiveSimdValue;
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
||||||
|
@ -143,7 +143,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar, D: DimName> From<VectorN<N, D>> for Point<N, D>
|
impl<N: Scalar, D: DimName> From<VectorN<N, D>> for Point<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(coords: VectorN<N, D>) -> Self {
|
fn from(coords: VectorN<N, D>) -> Self {
|
||||||
|
|
|
@ -71,7 +71,9 @@ impl<N: SimdRealField> Quaternion<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
// FIXME: take a reference to `vector`?
|
// FIXME: take a reference to `vector`?
|
||||||
pub fn from_parts<SB>(scalar: N, vector: Vector<N, U3, SB>) -> Self
|
pub fn from_parts<SB>(scalar: N, vector: Vector<N, U3, SB>) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
Self::new(scalar, vector[0], vector[1], vector[2])
|
Self::new(scalar, vector[0], vector[1], vector[2])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,14 +102,17 @@ impl<N: SimdRealField> Quaternion<N> {
|
||||||
|
|
||||||
// FIXME: merge with the previous block.
|
// FIXME: merge with the previous block.
|
||||||
impl<N: SimdRealField> Quaternion<N>
|
impl<N: SimdRealField> Quaternion<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
/// Creates a new quaternion from its polar decomposition.
|
/// Creates a new quaternion from its polar decomposition.
|
||||||
///
|
///
|
||||||
/// Note that `axis` is assumed to be a unit vector.
|
/// Note that `axis` is assumed to be a unit vector.
|
||||||
// FIXME: take a reference to `axis`?
|
// FIXME: take a reference to `axis`?
|
||||||
pub fn from_polar_decomposition<SB>(scale: N, theta: N, axis: Unit<Vector<N, U3, SB>>) -> Self
|
pub fn from_polar_decomposition<SB>(scale: N, theta: N, axis: Unit<Vector<N, U3, SB>>) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
let rot = UnitQuaternion::<N>::from_axis_angle(&axis, theta * crate::convert(2.0f64));
|
let rot = UnitQuaternion::<N>::from_axis_angle(&axis, theta * crate::convert(2.0f64));
|
||||||
|
|
||||||
rot.into_inner() * scale
|
rot.into_inner() * scale
|
||||||
|
@ -115,7 +120,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> One for Quaternion<N>
|
impl<N: SimdRealField> One for Quaternion<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn one() -> Self {
|
fn one() -> Self {
|
||||||
|
@ -124,7 +130,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> Zero for Quaternion<N>
|
impl<N: SimdRealField> Zero for Quaternion<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn zero() -> Self {
|
fn zero() -> Self {
|
||||||
|
@ -138,7 +145,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> Distribution<Quaternion<N>> for Standard
|
impl<N: SimdRealField> Distribution<Quaternion<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where
|
||||||
|
Standard: Distribution<N>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<N> {
|
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<N> {
|
||||||
|
@ -148,7 +156,8 @@ where Standard: Distribution<N>
|
||||||
|
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
impl<N: SimdRealField + Arbitrary> Arbitrary for Quaternion<N>
|
impl<N: SimdRealField + Arbitrary> Arbitrary for Quaternion<N>
|
||||||
where Owned<N, U4>: Send
|
where
|
||||||
|
Owned<N, U4>: Send,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn arbitrary<G: Gen>(g: &mut G) -> Self {
|
fn arbitrary<G: Gen>(g: &mut G) -> Self {
|
||||||
|
@ -162,7 +171,8 @@ where Owned<N, U4>: Send
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> UnitQuaternion<N>
|
impl<N: SimdRealField> UnitQuaternion<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
/// The rotation identity.
|
/// The rotation identity.
|
||||||
///
|
///
|
||||||
|
@ -209,7 +219,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_axis_angle<SB>(axis: &Unit<Vector<N, U3, SB>>, angle: N) -> Self
|
pub fn from_axis_angle<SB>(axis: &Unit<Vector<N, U3, SB>>, angle: N) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
let (sang, cang) = (angle / crate::convert(2.0f64)).simd_sin_cos();
|
let (sang, cang) = (angle / crate::convert(2.0f64)).simd_sin_cos();
|
||||||
|
|
||||||
let q = Quaternion::from_parts(cang, axis.as_ref() * sang);
|
let q = Quaternion::from_parts(cang, axis.as_ref() * sang);
|
||||||
|
@ -335,7 +347,9 @@ where N::Element: SimdRealField
|
||||||
/// convergence parameters and starting solution.
|
/// convergence parameters and starting solution.
|
||||||
/// This implements "A Robust Method to Extract the Rotational Part of Deformations" by Müller et al.
|
/// This implements "A Robust Method to Extract the Rotational Part of Deformations" by Müller et al.
|
||||||
pub fn from_matrix(m: &Matrix3<N>) -> Self
|
pub fn from_matrix(m: &Matrix3<N>) -> Self
|
||||||
where N: RealField {
|
where
|
||||||
|
N: RealField,
|
||||||
|
{
|
||||||
Rotation3::from_matrix(m).into()
|
Rotation3::from_matrix(m).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +366,9 @@ where N::Element: SimdRealField
|
||||||
/// to the actual solution is provided. Can be set to `UnitQuaternion::identity()` if no other
|
/// to the actual solution is provided. Can be set to `UnitQuaternion::identity()` if no other
|
||||||
/// guesses come to mind.
|
/// guesses come to mind.
|
||||||
pub fn from_matrix_eps(m: &Matrix3<N>, eps: N, max_iter: usize, guess: Self) -> Self
|
pub fn from_matrix_eps(m: &Matrix3<N>, eps: N, max_iter: usize, guess: Self) -> Self
|
||||||
where N: RealField {
|
where
|
||||||
|
N: RealField,
|
||||||
|
{
|
||||||
let guess = Rotation3::from(guess);
|
let guess = Rotation3::from(guess);
|
||||||
Rotation3::from_matrix_eps(m, eps, max_iter, guess).into()
|
Rotation3::from_matrix_eps(m, eps, max_iter, guess).into()
|
||||||
}
|
}
|
||||||
|
@ -619,7 +635,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<SB>(axisangle: Vector<N, U3, SB>) -> Self
|
pub fn new<SB>(axisangle: Vector<N, U3, SB>) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
let two: N = crate::convert(2.0f64);
|
let two: N = crate::convert(2.0f64);
|
||||||
let q = Quaternion::<N>::from_imag(axisangle / two).exp();
|
let q = Quaternion::<N>::from_imag(axisangle / two).exp();
|
||||||
Self::new_unchecked(q)
|
Self::new_unchecked(q)
|
||||||
|
@ -648,7 +666,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_eps<SB>(axisangle: Vector<N, U3, SB>, eps: N) -> Self
|
pub fn new_eps<SB>(axisangle: Vector<N, U3, SB>, eps: N) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
let two: N = crate::convert(2.0f64);
|
let two: N = crate::convert(2.0f64);
|
||||||
let q = Quaternion::<N>::from_imag(axisangle / two).exp_eps(eps);
|
let q = Quaternion::<N>::from_imag(axisangle / two).exp_eps(eps);
|
||||||
Self::new_unchecked(q)
|
Self::new_unchecked(q)
|
||||||
|
@ -678,7 +698,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_scaled_axis<SB>(axisangle: Vector<N, U3, SB>) -> Self
|
pub fn from_scaled_axis<SB>(axisangle: Vector<N, U3, SB>) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
Self::new(axisangle)
|
Self::new(axisangle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +728,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_scaled_axis_eps<SB>(axisangle: Vector<N, U3, SB>, eps: N) -> Self
|
pub fn from_scaled_axis_eps<SB>(axisangle: Vector<N, U3, SB>, eps: N) -> Self
|
||||||
where SB: Storage<N, U3> {
|
where
|
||||||
|
SB: Storage<N, U3>,
|
||||||
|
{
|
||||||
Self::new_eps(axisangle, eps)
|
Self::new_eps(axisangle, eps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +760,9 @@ where N::Element: SimdRealField
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mean_of(unit_quaternions: impl IntoIterator<Item = Self>) -> Self
|
pub fn mean_of(unit_quaternions: impl IntoIterator<Item = Self>) -> Self
|
||||||
where N: RealField {
|
where
|
||||||
|
N: RealField,
|
||||||
|
{
|
||||||
let quaternions_matrix: Matrix4<N> = unit_quaternions
|
let quaternions_matrix: Matrix4<N> = unit_quaternions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|q| q.as_vector() * q.as_vector().transpose())
|
.map(|q| q.as_vector() * q.as_vector().transpose())
|
||||||
|
@ -765,7 +791,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> One for UnitQuaternion<N>
|
impl<N: SimdRealField> One for UnitQuaternion<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn one() -> Self {
|
fn one() -> Self {
|
||||||
|
@ -800,7 +827,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
impl<N: SimdRealField + Arbitrary> Arbitrary for UnitQuaternion<N>
|
impl<N: RealField + Arbitrary> Arbitrary for UnitQuaternion<N>
|
||||||
where
|
where
|
||||||
Owned<N, U4>: Send,
|
Owned<N, U4>: Send,
|
||||||
Owned<N, U3>: Send,
|
Owned<N, U3>: Send,
|
||||||
|
|
|
@ -2,10 +2,11 @@ use simba::simd::SimdValue;
|
||||||
|
|
||||||
use crate::base::Vector4;
|
use crate::base::Vector4;
|
||||||
use crate::geometry::{Quaternion, UnitQuaternion};
|
use crate::geometry::{Quaternion, UnitQuaternion};
|
||||||
use crate::{RealField, Scalar};
|
use crate::Scalar;
|
||||||
|
|
||||||
impl<N: Scalar + SimdValue> SimdValue for Quaternion<N>
|
impl<N: Scalar + SimdValue> SimdValue for Quaternion<N>
|
||||||
where N::Element: Scalar
|
where
|
||||||
|
N::Element: Scalar,
|
||||||
{
|
{
|
||||||
type Element = Quaternion<N::Element>;
|
type Element = Quaternion<N::Element>;
|
||||||
type SimdBool = N::SimdBool;
|
type SimdBool = N::SimdBool;
|
||||||
|
@ -47,7 +48,8 @@ where N::Element: Scalar
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar + SimdValue> SimdValue for UnitQuaternion<N>
|
impl<N: Scalar + SimdValue> SimdValue for UnitQuaternion<N>
|
||||||
where N::Element: Scalar
|
where
|
||||||
|
N::Element: Scalar,
|
||||||
{
|
{
|
||||||
type Element = UnitQuaternion<N::Element>;
|
type Element = UnitQuaternion<N::Element>;
|
||||||
type SimdBool = N::SimdBool;
|
type SimdBool = N::SimdBool;
|
||||||
|
|
|
@ -107,15 +107,15 @@ where
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
impl<N, D: DimName, R> Arbitrary for Similarity<N, D, R>
|
impl<N, D: DimName, R> Arbitrary for Similarity<N, D, R>
|
||||||
where
|
where
|
||||||
N: SimdRealField + Arbitrary + Send,
|
N: RealField + Arbitrary + Send,
|
||||||
N::Element: SimdRealField,
|
N::Element: RealField,
|
||||||
R: AbstractRotation<N, D> + Arbitrary + Send,
|
R: AbstractRotation<N, D> + Arbitrary + Send,
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
Owned<N, D>: Send,
|
Owned<N, D>: Send,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn arbitrary<G: Gen>(rng: &mut G) -> Self {
|
fn arbitrary<G: Gen>(rng: &mut G) -> Self {
|
||||||
let mut s = Arbitrary::arbitrary(rng);
|
let mut s: N = Arbitrary::arbitrary(rng);
|
||||||
while s.is_zero() {
|
while s.is_zero() {
|
||||||
s = Arbitrary::arbitrary(rng)
|
s = Arbitrary::arbitrary(rng)
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,8 @@ where
|
||||||
|
|
||||||
// 2D similarity.
|
// 2D similarity.
|
||||||
impl<N: SimdRealField> Similarity<N, U2, Rotation2<N>>
|
impl<N: SimdRealField> Similarity<N, U2, Rotation2<N>>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
/// Creates a new similarity from a translation, a rotation, and an uniform scaling factor.
|
/// Creates a new similarity from a translation, a rotation, and an uniform scaling factor.
|
||||||
///
|
///
|
||||||
|
@ -157,7 +158,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> Similarity<N, U2, UnitComplex<N>>
|
impl<N: SimdRealField> Similarity<N, U2, UnitComplex<N>>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
/// Creates a new similarity from a translation and a rotation angle.
|
/// Creates a new similarity from a translation and a rotation angle.
|
||||||
///
|
///
|
||||||
|
|
|
@ -2,7 +2,7 @@ use simba::simd::{SimdRealField, SimdValue};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::DimName;
|
use crate::base::dimension::DimName;
|
||||||
use crate::base::{DefaultAllocator, Scalar};
|
use crate::base::DefaultAllocator;
|
||||||
|
|
||||||
use crate::geometry::{AbstractRotation, Isometry, Similarity};
|
use crate::geometry::{AbstractRotation, Isometry, Similarity};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub, RealField};
|
use simba::scalar::{ClosedAdd, ClosedNeg, ClosedSub};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
||||||
|
@ -24,7 +24,8 @@ use crate::geometry::Point;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Translation<N: Scalar, D: DimName>
|
pub struct Translation<N: Scalar, D: DimName>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
||||||
/// translated.
|
/// translated.
|
||||||
|
@ -87,7 +88,9 @@ where
|
||||||
Owned<N, D>: Serialize,
|
Owned<N, D>: Serialize,
|
||||||
{
|
{
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where S: Serializer {
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
self.vector.serialize(serializer)
|
self.vector.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +102,9 @@ where
|
||||||
Owned<N, D>: Deserialize<'a>,
|
Owned<N, D>: Deserialize<'a>,
|
||||||
{
|
{
|
||||||
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
|
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
|
||||||
where Des: Deserializer<'a> {
|
where
|
||||||
|
Des: Deserializer<'a>,
|
||||||
|
{
|
||||||
let matrix = VectorN::<N, D>::deserialize(deserializer)?;
|
let matrix = VectorN::<N, D>::deserialize(deserializer)?;
|
||||||
|
|
||||||
Ok(Translation::from(matrix))
|
Ok(Translation::from(matrix))
|
||||||
|
@ -107,7 +112,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar, D: DimName> Translation<N, D>
|
impl<N: Scalar, D: DimName> Translation<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// Creates a new translation from the given vector.
|
/// Creates a new translation from the given vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -133,7 +139,9 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use = "Did you mean to use inverse_mut()?"]
|
#[must_use = "Did you mean to use inverse_mut()?"]
|
||||||
pub fn inverse(&self) -> Translation<N, D>
|
pub fn inverse(&self) -> Translation<N, D>
|
||||||
where N: ClosedNeg {
|
where
|
||||||
|
N: ClosedNeg,
|
||||||
|
{
|
||||||
Translation::from(-&self.vector)
|
Translation::from(-&self.vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,13 +197,16 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inverse_mut(&mut self)
|
pub fn inverse_mut(&mut self)
|
||||||
where N: ClosedNeg {
|
where
|
||||||
|
N: ClosedNeg,
|
||||||
|
{
|
||||||
self.vector.neg_mut()
|
self.vector.neg_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar + ClosedAdd, D: DimName> Translation<N, D>
|
impl<N: Scalar + ClosedAdd, D: DimName> Translation<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// Translate the given point.
|
/// Translate the given point.
|
||||||
///
|
///
|
||||||
|
@ -214,7 +225,8 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar + ClosedSub, D: DimName> Translation<N, D>
|
impl<N: Scalar + ClosedSub, D: DimName> Translation<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
/// Translate the given point by the inverse of this translation.
|
/// Translate the given point by the inverse of this translation.
|
||||||
///
|
///
|
||||||
|
@ -233,7 +245,8 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
impl<N: Scalar + Eq, D: DimName> Eq for Translation<N, D> where DefaultAllocator: Allocator<N, D> {}
|
impl<N: Scalar + Eq, D: DimName> Eq for Translation<N, D> where DefaultAllocator: Allocator<N, D> {}
|
||||||
|
|
||||||
impl<N: Scalar + PartialEq, D: DimName> PartialEq for Translation<N, D>
|
impl<N: Scalar + PartialEq, D: DimName> PartialEq for Translation<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, right: &Translation<N, D>) -> bool {
|
fn eq(&self, right: &Translation<N, D>) -> bool {
|
||||||
|
@ -275,8 +288,7 @@ where
|
||||||
other: &Self,
|
other: &Self,
|
||||||
epsilon: Self::Epsilon,
|
epsilon: Self::Epsilon,
|
||||||
max_relative: Self::Epsilon,
|
max_relative: Self::Epsilon,
|
||||||
) -> bool
|
) -> bool {
|
||||||
{
|
|
||||||
self.vector
|
self.vector
|
||||||
.relative_eq(&other.vector, epsilon, max_relative)
|
.relative_eq(&other.vector, epsilon, max_relative)
|
||||||
}
|
}
|
||||||
|
@ -304,7 +316,8 @@ where
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
impl<N: Scalar + fmt::Display, D: DimName> fmt::Display for Translation<N, D>
|
impl<N: Scalar + fmt::Display, D: DimName> fmt::Display for Translation<N, D>
|
||||||
where DefaultAllocator: Allocator<N, D> + Allocator<usize, D>
|
where
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<usize, D>,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let precision = f.precision().unwrap_or(3);
|
let precision = f.precision().unwrap_or(3);
|
||||||
|
|
|
@ -2,7 +2,7 @@ use num::Zero;
|
||||||
use num_complex::Complex;
|
use num_complex::Complex;
|
||||||
|
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue};
|
use simba::simd::{PrimitiveSimdValue, SimdRealField};
|
||||||
|
|
||||||
use crate::base::dimension::U2;
|
use crate::base::dimension::U2;
|
||||||
use crate::base::{Matrix2, Matrix3, Scalar};
|
use crate::base::{Matrix2, Matrix3, Scalar};
|
||||||
|
@ -155,7 +155,8 @@ impl<N1: RealField, N2: RealField + SupersetOf<N1>> SubsetOf<Matrix3<N2>> for Un
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> From<UnitComplex<N>> for Rotation2<N>
|
impl<N: SimdRealField> From<UnitComplex<N>> for Rotation2<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(q: UnitComplex<N>) -> Self {
|
fn from(q: UnitComplex<N>) -> Self {
|
||||||
|
@ -164,7 +165,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> From<Rotation2<N>> for UnitComplex<N>
|
impl<N: SimdRealField> From<Rotation2<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(q: Rotation2<N>) -> Self {
|
fn from(q: Rotation2<N>) -> Self {
|
||||||
|
@ -173,7 +175,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> From<UnitComplex<N>> for Matrix3<N>
|
impl<N: SimdRealField> From<UnitComplex<N>> for Matrix3<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(q: UnitComplex<N>) -> Matrix3<N> {
|
fn from(q: UnitComplex<N>) -> Matrix3<N> {
|
||||||
|
@ -182,7 +185,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> From<UnitComplex<N>> for Matrix2<N>
|
impl<N: SimdRealField> From<UnitComplex<N>> for Matrix2<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(q: UnitComplex<N>) -> Self {
|
fn from(q: UnitComplex<N>) -> Self {
|
||||||
|
|
|
@ -5,7 +5,6 @@ use crate::base::dimension::{U1, U2};
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{DefaultAllocator, Unit, Vector, Vector2};
|
use crate::base::{DefaultAllocator, Unit, Vector, Vector2};
|
||||||
use crate::geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex};
|
use crate::geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex};
|
||||||
use simba::scalar::RealField;
|
|
||||||
use simba::simd::SimdRealField;
|
use simba::simd::SimdRealField;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -53,7 +52,8 @@ impl<N: SimdRealField> Mul<Self> for UnitComplex<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, N: SimdRealField> Mul<UnitComplex<N>> for &'a UnitComplex<N>
|
impl<'a, N: SimdRealField> Mul<UnitComplex<N>> for &'a UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = UnitComplex<N>;
|
type Output = UnitComplex<N>;
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, N: SimdRealField> Mul<&'b UnitComplex<N>> for UnitComplex<N>
|
impl<'b, N: SimdRealField> Mul<&'b UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
|
@ -75,7 +76,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, N: SimdRealField> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N>
|
impl<'a, 'b, N: SimdRealField> Mul<&'b UnitComplex<N>> for &'a UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = UnitComplex<N>;
|
type Output = UnitComplex<N>;
|
||||||
|
|
||||||
|
@ -87,7 +89,8 @@ where N::Element: SimdRealField
|
||||||
|
|
||||||
// UnitComplex ÷ UnitComplex
|
// UnitComplex ÷ UnitComplex
|
||||||
impl<N: SimdRealField> Div<Self> for UnitComplex<N>
|
impl<N: SimdRealField> Div<Self> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
|
@ -98,7 +101,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, N: SimdRealField> Div<UnitComplex<N>> for &'a UnitComplex<N>
|
impl<'a, N: SimdRealField> Div<UnitComplex<N>> for &'a UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = UnitComplex<N>;
|
type Output = UnitComplex<N>;
|
||||||
|
|
||||||
|
@ -109,7 +113,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, N: SimdRealField> Div<&'b UnitComplex<N>> for UnitComplex<N>
|
impl<'b, N: SimdRealField> Div<&'b UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
|
@ -120,7 +125,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, N: SimdRealField> Div<&'b UnitComplex<N>> for &'a UnitComplex<N>
|
impl<'a, 'b, N: SimdRealField> Div<&'b UnitComplex<N>> for &'a UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Output = UnitComplex<N>;
|
type Output = UnitComplex<N>;
|
||||||
|
|
||||||
|
@ -315,7 +321,8 @@ complex_op_impl_all!(
|
||||||
|
|
||||||
// UnitComplex ×= UnitComplex
|
// UnitComplex ×= UnitComplex
|
||||||
impl<N: SimdRealField> MulAssign<UnitComplex<N>> for UnitComplex<N>
|
impl<N: SimdRealField> MulAssign<UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: UnitComplex<N>) {
|
fn mul_assign(&mut self, rhs: UnitComplex<N>) {
|
||||||
|
@ -324,7 +331,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, N: SimdRealField> MulAssign<&'b UnitComplex<N>> for UnitComplex<N>
|
impl<'b, N: SimdRealField> MulAssign<&'b UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: &'b UnitComplex<N>) {
|
fn mul_assign(&mut self, rhs: &'b UnitComplex<N>) {
|
||||||
|
@ -334,7 +342,8 @@ where N::Element: SimdRealField
|
||||||
|
|
||||||
// UnitComplex /= UnitComplex
|
// UnitComplex /= UnitComplex
|
||||||
impl<N: SimdRealField> DivAssign<UnitComplex<N>> for UnitComplex<N>
|
impl<N: SimdRealField> DivAssign<UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: UnitComplex<N>) {
|
fn div_assign(&mut self, rhs: UnitComplex<N>) {
|
||||||
|
@ -343,7 +352,8 @@ where N::Element: SimdRealField
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, N: SimdRealField> DivAssign<&'b UnitComplex<N>> for UnitComplex<N>
|
impl<'b, N: SimdRealField> DivAssign<&'b UnitComplex<N>> for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: &'b UnitComplex<N>) {
|
fn div_assign(&mut self, rhs: &'b UnitComplex<N>) {
|
||||||
|
|
|
@ -2,12 +2,13 @@ use num_complex::Complex;
|
||||||
use simba::simd::SimdValue;
|
use simba::simd::SimdValue;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use crate::base::{Scalar, Unit};
|
use crate::base::Unit;
|
||||||
use crate::geometry::UnitComplex;
|
use crate::geometry::UnitComplex;
|
||||||
use crate::SimdRealField;
|
use crate::SimdRealField;
|
||||||
|
|
||||||
impl<N: SimdRealField> SimdValue for UnitComplex<N>
|
impl<N: SimdRealField> SimdValue for UnitComplex<N>
|
||||||
where N::Element: SimdRealField
|
where
|
||||||
|
N::Element: SimdRealField,
|
||||||
{
|
{
|
||||||
type Element = UnitComplex<N::Element>;
|
type Element = UnitComplex<N::Element>;
|
||||||
type SimdBool = N::SimdBool;
|
type SimdBool = N::SimdBool;
|
||||||
|
|
Loading…
Reference in New Issue