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