Skip to content

Commit

Permalink
Add scalar multiplication to DQ
Browse files Browse the repository at this point in the history
  • Loading branch information
chinedufn committed Dec 16, 2020
1 parent 6bb5503 commit 61f0bc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/geometry/dual_quaternion.rs
Expand Up @@ -18,7 +18,10 @@ pub struct DualQuaternion<N: Scalar + SimdValue> {

impl<N: RealField> Default for DualQuaternion<N> {
fn default() -> Self {
Self::identity()
Self {
rot: Quaternion::default(),
trans: Quaternion::default(),
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/geometry/dual_quaternion_ops.rs
Expand Up @@ -5,6 +5,7 @@
*
* (Assignment Operators)
*
* DualQuaternion × Scalar
* DualQuaternion × DualQuaternion
*
* ---
Expand Down Expand Up @@ -33,3 +34,18 @@ where
}
}
}

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,
}
}
}

0 comments on commit 61f0bc5

Please sign in to comment.