Add dot product
This commit is contained in:
parent
b074ecafbd
commit
693a0adda0
1 changed files with 10 additions and 0 deletions
|
@ -33,6 +33,8 @@ pub trait Quaternion<T> {
|
|||
pure fn sub_q(other: &self) -> self;
|
||||
pure fn mul_q(other: &self) -> self;
|
||||
|
||||
pure fn dot(other: &self) -> T;
|
||||
|
||||
pure fn conjugate() -> self;
|
||||
pure fn inverse() -> self;
|
||||
pure fn length2() -> T;
|
||||
|
@ -122,6 +124,14 @@ pub impl<T:Copy Num NumCast Exp FuzzyEq> Quat<T>: Quaternion<T> {
|
|||
self.w * other.z + self.z * other.w + self.x * other.y - self.y * other.x)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn dot(other: &Quat<T>) -> T {
|
||||
self.w * other.w +
|
||||
self.x * other.x +
|
||||
self.y * other.y +
|
||||
self.z * other.z
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn conjugate() -> Quat<T> {
|
||||
Quat::new(self.w, -self.x, -self.y, -self.z)
|
||||
|
|
Loading…
Reference in a new issue