Closed
Description
I wrote this thinking it would be possible, but it turns out it isn't yet. It would be very nice if this could be done.
impl Mul<Quaternion, Quaternion> for Quaternion
{
fn mul(&self, rhs: &Quaternion) -> Quaternion
{
Quaternion::new
(
self.w * rhs.x + self.x * self.w + self.y * rhs.z - self.z * rhs.y,
self.w * rhs.y + self.y * self.w + self.z * rhs.x - self.x * rhs.z,
self.w * rhs.z + self.z * self.w + self.x * rhs.y - self.y * rhs.x,
self.w * rhs.w - self.x * self.x - self.y * rhs.y - self.z * rhs.z
)
}
}
impl Mul<math::Vec3f, math::Vec3f> for Quaternion
{
fn mul(&self, rhs: &math::Vec3f) -> math::Vec3f
{
let vn = math::Vec3f::new_normalized(rhs);
let vecq = Quaternion::new(vn.x, vn.y, vn.z, 0.0);
let resq = (vecq * self.get_conjugate()) * self;
math::Vec3f::new(resq.x, resq.y, resq.z)
}
}
impl Mul<Component, Quaternion> for Quaternion
{
fn mul(&self, rhs: &Component) -> Quaternion
{
Quaternion::new
(
self.x * *rhs,
self.y * *rhs,
self.z * *rhs,
self.w * *rhs
)
}
}