formatting
This commit is contained in:
parent
686ed10624
commit
063140d533
|
@ -1,5 +1,7 @@
|
|||
use crate::{RealField, Rotation, Rotation2, Rotation3, SimdRealField, UnitComplex, UnitQuaternion};
|
||||
use crate::{Const, U1, DimSub, DimDiff, Storage, ArrayStorage, Allocator, DefaultAllocator};
|
||||
use crate::{Allocator, ArrayStorage, Const, DefaultAllocator, DimDiff, DimSub, Storage, U1};
|
||||
use crate::{
|
||||
RealField, Rotation, Rotation2, Rotation3, SimdRealField, UnitComplex, UnitQuaternion,
|
||||
};
|
||||
|
||||
/// # Interpolation
|
||||
impl<T: SimdRealField> Rotation2<T> {
|
||||
|
@ -81,14 +83,15 @@ impl<T: SimdRealField> Rotation3<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:RealField, const D: usize> Rotation<T,D> where
|
||||
impl<T: RealField, const D: usize> Rotation<T, D>
|
||||
where
|
||||
Const<D>: DimSub<U1>,
|
||||
ArrayStorage<T, D, D>: Storage<T, Const<D>, Const<D>>,
|
||||
DefaultAllocator: Allocator<T,Const<D>,Const<D>,Buffer=ArrayStorage<T,D,D>> + Allocator<T,Const<D>> +
|
||||
Allocator<T,Const<D>,DimDiff<Const<D>,U1>> +
|
||||
Allocator<T,DimDiff<Const<D>,U1>>
|
||||
DefaultAllocator: Allocator<T, Const<D>, Const<D>, Buffer = ArrayStorage<T, D, D>>
|
||||
+ Allocator<T, Const<D>>
|
||||
+ Allocator<T, Const<D>, DimDiff<Const<D>, U1>>
|
||||
+ Allocator<T, DimDiff<Const<D>, U1>>,
|
||||
{
|
||||
|
||||
///
|
||||
/// Computes the spherical linear interpolation between two general rotations.
|
||||
///
|
||||
|
@ -110,14 +113,12 @@ impl<T:RealField, const D: usize> Rotation<T,D> where
|
|||
#[inline]
|
||||
#[must_use]
|
||||
pub fn slerp(&self, other: &Self, t: T) -> Self {
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
//The best option here would be to use #[feature(specialization)], but until
|
||||
//that's stabilized, this is the best we can do. Theoretically, the compiler should
|
||||
//pretty thoroughly optimize away all the excess checks and conversions
|
||||
match D {
|
||||
|
||||
0 => self.clone(),
|
||||
|
||||
//FIXME: this doesn't really work in 1D since we can't interp between -1 and 1
|
||||
|
@ -141,9 +142,7 @@ impl<T:RealField, const D: usize> Rotation<T,D> where
|
|||
},
|
||||
|
||||
//the multiplication order matters here
|
||||
_ => (other/self).powf(t) * self
|
||||
_ => (other / self).powf(t) * self,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ use simba::scalar::RealField;
|
|||
use simba::simd::{SimdBool, SimdRealField};
|
||||
use std::ops::Neg;
|
||||
|
||||
use crate::base::dimension::{Const, U1, U2, U3, DimSub, DimDiff};
|
||||
use crate::base::allocator::Allocator;
|
||||
use crate::base::dimension::{Const, DimDiff, DimSub, U1, U2, U3};
|
||||
use crate::base::storage::Storage;
|
||||
use crate::base::{ Matrix2, Matrix3, SMatrix, SVector, Unit, Vector, Vector1, Vector2, Vector3};
|
||||
use crate::base::{ArrayStorage, DefaultAllocator};
|
||||
use crate::base::{Matrix2, Matrix3, SMatrix, SVector, Unit, Vector, Vector1, Vector2, Vector3};
|
||||
|
||||
use crate::geometry::{Rotation, Rotation2, Rotation3, UnitComplex, UnitQuaternion};
|
||||
|
||||
|
@ -1007,9 +1007,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T:RealField, const D: usize> Rotation<T,D>
|
||||
{
|
||||
|
||||
impl<T: RealField, const D: usize> Rotation<T, D> {
|
||||
///
|
||||
/// Raise the rotation to a given floating power, i.e., returns the rotation with the same
|
||||
/// axis as `self` and an angle equal to `self.angle()` multiplied by `n`.
|
||||
|
@ -1028,12 +1026,14 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
/// assert_eq!(pow.angle(), 2.4);
|
||||
/// ```
|
||||
//FIXME: merging powf for Rotation2 into this raises the trait bounds from SimdRealField to RealField
|
||||
pub fn powf(&self, t: T) -> Self where
|
||||
pub fn powf(&self, t: T) -> Self
|
||||
where
|
||||
Const<D>: DimSub<U1>,
|
||||
ArrayStorage<T, D, D>: Storage<T, Const<D>, Const<D>>,
|
||||
DefaultAllocator: Allocator<T,Const<D>,Const<D>,Buffer=ArrayStorage<T,D,D>> + Allocator<T,Const<D>> +
|
||||
Allocator<T,Const<D>,DimDiff<Const<D>,U1>> +
|
||||
Allocator<T,DimDiff<Const<D>,U1>>
|
||||
DefaultAllocator: Allocator<T, Const<D>, Const<D>, Buffer = ArrayStorage<T, D, D>>
|
||||
+ Allocator<T, Const<D>>
|
||||
+ Allocator<T, Const<D>, DimDiff<Const<D>, U1>>
|
||||
+ Allocator<T, DimDiff<Const<D>, U1>>,
|
||||
{
|
||||
use std::mem::*;
|
||||
|
||||
|
@ -1041,7 +1041,6 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
//that's stabilized, this is the best we can do. Theoretically, the compiler should
|
||||
//pretty thoroughly optimize away all the excess checks and conversions
|
||||
match D {
|
||||
|
||||
0 => self.clone(),
|
||||
1 => self.clone(),
|
||||
|
||||
|
@ -1056,18 +1055,22 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
transmute::<&Rotation3<T>, &Self>(&r3d).clone()
|
||||
},
|
||||
|
||||
_ => self.clone().general_pow(t)
|
||||
_ => self.clone().general_pow(t),
|
||||
}
|
||||
}
|
||||
|
||||
fn general_pow(self, t:T) -> Self where
|
||||
fn general_pow(self, t: T) -> Self
|
||||
where
|
||||
Const<D>: DimSub<U1>,
|
||||
ArrayStorage<T, D, D>: Storage<T, Const<D>, Const<D>>,
|
||||
DefaultAllocator: Allocator<T,Const<D>,Const<D>,Buffer=ArrayStorage<T,D,D>> + Allocator<T,Const<D>> +
|
||||
Allocator<T,Const<D>,DimDiff<Const<D>,U1>> +
|
||||
Allocator<T,DimDiff<Const<D>,U1>>
|
||||
DefaultAllocator: Allocator<T, Const<D>, Const<D>, Buffer = ArrayStorage<T, D, D>>
|
||||
+ Allocator<T, Const<D>>
|
||||
+ Allocator<T, Const<D>, DimDiff<Const<D>, U1>>
|
||||
+ Allocator<T, DimDiff<Const<D>, U1>>,
|
||||
{
|
||||
if D<=1 { return self; }
|
||||
if D <= 1 {
|
||||
return self;
|
||||
}
|
||||
|
||||
// println!("r:{}", self);
|
||||
// println!("{}", self.clone().into_inner().hessenberg().unpack_h());
|
||||
|
@ -1083,7 +1086,6 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
//go down the diagonal and pow every block
|
||||
let mut i = 0;
|
||||
while i < D - 1 {
|
||||
|
||||
if
|
||||
//For most 2x2 blocks
|
||||
//NOTE: we use strict equality since `nalgebra`'s schur decomp sets the infradiagonal to zero
|
||||
|
@ -1092,7 +1094,6 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
//for +-180 deg rotations
|
||||
d[(i,i)]<T::zero() && d[(i+1,i+1)]<T::zero()
|
||||
{
|
||||
|
||||
//convert to a complex num and find the arg()
|
||||
let (c, s) = (d[(i, i)].clone(), d[(i + 1, i)].clone());
|
||||
let angle = s.atan2(c); //for +-180deg rots, this implicitely takes the +180 branch
|
||||
|
@ -1110,18 +1111,14 @@ impl<T:RealField, const D: usize> Rotation<T,D>
|
|||
//increase by 2 so we don't accidentally misinterpret the
|
||||
//next line as a 180deg rotation
|
||||
i += 2;
|
||||
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
}
|
||||
// println!("d:{:.3}", d);
|
||||
|
||||
let qt = q.transpose(); //avoids an extra clone
|
||||
|
||||
Self::from_matrix_unchecked(q * d * qt)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ fn quaternion_euler_angles_issue_494() {
|
|||
|
||||
#[cfg(feature = "proptest-support")]
|
||||
mod proptest_tests {
|
||||
use na::{self, Rotation, Rotation2, Rotation3, Unit, Vector, Matrix, SMatrix};
|
||||
use simba::scalar::RealField;
|
||||
use na::{self, Matrix, Rotation, Rotation2, Rotation3, SMatrix, Unit, Vector};
|
||||
use num_traits::Zero;
|
||||
use simba::scalar::RealField;
|
||||
use std::f64;
|
||||
|
||||
use crate::proptest::*;
|
||||
|
@ -338,7 +338,6 @@ mod proptest_tests {
|
|||
)*}
|
||||
}
|
||||
|
||||
|
||||
gen_powf_rotation_test!(
|
||||
fn powf_rotation_4(v1 in vector4(), v2 in vector4(), v3 in vector4(), v4 in vector4());
|
||||
fn powf_rotation_5(v1 in vector5(), v2 in vector5(), v3 in vector5(), v4 in vector5());
|
||||
|
|
Loading…
Reference in New Issue