/* * This file provides: * * NOTE: Work in progress https://github.com/dimforge/nalgebra/issues/487 * * (Dual Quaternion) * * Index * IndexMut * * (Assignment Operators) * * DualQuaternion × Scalar * DualQuaternion × DualQuaternion * DualQuaternion + DualQuaternion * 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, SimdRealField, U1, U4}; use simba::simd::SimdValue; use std::ops::{Add, Index, IndexMut, Mul, Sub}; impl Index for DualQuaternion { type Output = N; #[inline] fn index(&self, i: usize) -> &Self::Output { &self.dq[i] } } impl IndexMut for DualQuaternion { #[inline] fn index_mut(&mut self, i: usize) -> &mut N { &mut self.dq[i] } } impl Mul> for DualQuaternion where N::Element: SimdRealField, DefaultAllocator: Allocator + Allocator, { type Output = DualQuaternion; fn mul(self, rhs: Self) -> Self::Output { Self::from_real_and_dual( self.real() * rhs.real(), self.real() * rhs.dual() + self.dual() * rhs.real(), ) } } impl Mul for DualQuaternion where N::Element: SimdRealField + SimdValue, DefaultAllocator: Allocator + Allocator, { type Output = DualQuaternion; fn mul(self, rhs: N) -> Self::Output { Self::from_real_and_dual(self.real() * rhs, self.dual() * rhs) } } impl Add> for DualQuaternion where N::Element: SimdRealField, DefaultAllocator: Allocator + Allocator, { type Output = DualQuaternion; fn add(self, rhs: DualQuaternion) -> Self::Output { Self::from_real_and_dual(self.real() + rhs.real(), self.dual() + rhs.dual()) } } impl Sub> for DualQuaternion where N::Element: SimdRealField, DefaultAllocator: Allocator + Allocator, { type Output = DualQuaternion; fn sub(self, rhs: DualQuaternion) -> Self::Output { Self::from_real_and_dual(self.real() - rhs.real(), self.dual() - rhs.dual()) } }