Cleanup.
This commit is contained in:
parent
305ce7ac93
commit
609ebb0f37
@ -1,5 +1,5 @@
|
||||
use cgmath::{
|
||||
BaseFloat, BaseNum, InnerSpace, Quaternion, VectorSpace, Vector1, Vector2, Vector3, Vector4
|
||||
BaseFloat, BaseNum, InnerSpace, Quaternion, Vector1, Vector2, Vector3, Vector4
|
||||
};
|
||||
|
||||
use crate::interpolate::{Additive, Interpolate, Linear, One, cubic_hermite_def};
|
||||
@ -7,10 +7,12 @@ use crate::interpolate::{Additive, Interpolate, Linear, One, cubic_hermite_def};
|
||||
macro_rules! impl_interpolate_vec {
|
||||
($($t:tt)*) => {
|
||||
impl<T> Linear<T> for $($t)*<T> where T: BaseNum {
|
||||
#[inline(always)]
|
||||
fn outer_mul(self, t: T) -> Self {
|
||||
self * t
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn outer_div(self, t: T) -> Self {
|
||||
self / t
|
||||
}
|
||||
@ -18,10 +20,12 @@ macro_rules! impl_interpolate_vec {
|
||||
|
||||
impl<T> Interpolate<T> for $($t)*<T>
|
||||
where Self: InnerSpace<Scalar = T>, T: Additive + BaseFloat + One {
|
||||
#[inline(always)]
|
||||
fn lerp(a: Self, b: Self, t: T) -> Self {
|
||||
a.lerp(b, t)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn cubic_hermite(x: (Self, T), a: (Self, T), b: (Self, T), y: (Self, T), t: T) -> Self {
|
||||
cubic_hermite_def(x, a, b, y, t)
|
||||
}
|
||||
@ -35,10 +39,12 @@ impl_interpolate_vec!(Vector3);
|
||||
impl_interpolate_vec!(Vector4);
|
||||
|
||||
impl<T> Linear<T> for Quaternion<T> where T: BaseFloat {
|
||||
#[inline(always)]
|
||||
fn outer_mul(self, t: T) -> Self {
|
||||
self * t
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn outer_div(self, t: T) -> Self {
|
||||
self / t
|
||||
}
|
||||
@ -46,10 +52,12 @@ impl<T> Linear<T> for Quaternion<T> where T: BaseFloat {
|
||||
|
||||
impl<T> Interpolate<T> for Quaternion<T>
|
||||
where Self: InnerSpace<Scalar = T>, T: Additive + BaseFloat + One {
|
||||
#[inline(always)]
|
||||
fn lerp(a: Self, b: Self, t: T) -> Self {
|
||||
a.nlerp(b, t)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn cubic_hermite(x: (Self, T), a: (Self, T), b: (Self, T), y: (Self, T), t: T) -> Self {
|
||||
cubic_hermite_def(x, a, b, y, t)
|
||||
}
|
||||
|
@ -13,10 +13,12 @@ macro_rules! impl_interpolate_vector {
|
||||
($($t:tt)*) => {
|
||||
// implement Linear
|
||||
impl<T> Linear<T> for $($t)*<T> where T: Scalar + ClosedMul + ClosedDiv {
|
||||
#[inline(always)]
|
||||
fn outer_mul(self, t: T) -> Self {
|
||||
self * t
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn outer_div(self, t: T) -> Self {
|
||||
self / t
|
||||
}
|
||||
@ -33,10 +35,12 @@ macro_rules! impl_interpolate_vector {
|
||||
ClosedMul +
|
||||
ClosedSub +
|
||||
Interpolate<T> {
|
||||
#[inline(always)]
|
||||
fn lerp(a: Self, b: Self, t: T) -> Self {
|
||||
Vector::zip_map(&a, &b, |c1, c2| Interpolate::lerp(c1, c2, t))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn cubic_hermite(x: (Self, T), a: (Self, T), b: (Self, T), y: (Self, T), t: T) -> Self {
|
||||
cubic_hermite_def(x, a, b, y, t)
|
||||
}
|
||||
@ -56,10 +60,12 @@ where D: DimName,
|
||||
DefaultAllocator: Allocator<T, D>,
|
||||
<DefaultAllocator as Allocator<T, D>>::Buffer: Copy,
|
||||
T: Scalar + ClosedDiv + ClosedMul {
|
||||
#[inline(always)]
|
||||
fn outer_mul(self, t: T) -> Self {
|
||||
self * t
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn outer_div(self, t: T) -> Self {
|
||||
self / t
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user