/
dual_quaternion_ops.rs
51 lines (46 loc) · 1.29 KB
/
dual_quaternion_ops.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* This file provides:
*
* NOTE: Work in progress https://github.com/dimforge/nalgebra/issues/487
*
* (Assignment Operators)
*
* DualQuaternion × Scalar
* DualQuaternion × DualQuaternion
*
* ---
*
* References:
* Multiplication:
* - https://cs.gmu.edu/~jmlien/teaching/cs451/uploads/Main/dual-quaternion.pdf
*/
use crate::base::allocator::Allocator;
use crate::{DefaultAllocator, DualQuaternion, Scalar, SimdRealField, U1, U4};
use simba::simd::SimdValue;
use std::ops::Mul;
impl<N: Scalar + SimdValue + SimdRealField> Mul<DualQuaternion<N>> for DualQuaternion<N>
where
N::Element: Scalar + SimdValue + SimdRealField,
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U4, U1>,
{
type Output = DualQuaternion<N>;
fn mul(self, rhs: Self) -> Self::Output {
Self {
rot: self.rot * rhs.rot,
trans: self.rot * rhs.trans + rhs.rot * self.trans,
}
}
}
impl<N: Scalar + SimdValue + SimdRealField> Mul<N> for DualQuaternion<N>
where
N::Element: Scalar + SimdValue + SimdRealField,
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U4, U1>,
{
type Output = DualQuaternion<N>;
fn mul(self, rhs: N) -> Self::Output {
Self {
rot: self.rot * rhs,
trans: self.trans * rhs,
}
}
}