Пример #1
0
 static MyQuaternion identity()
 {
     return MyQuaternion(0,0,0,1);
 }
Пример #2
0
 //{ Special functions
     MyQuaternion inverse() const
     {
         return MyQuaternion(-MyVector4<T>::x, -MyVector4<T>::y, -MyVector4<T>::z, MyVector4<T>::w);
     };
Пример #3
0
MyQuaternion MyQuaternion::operator*(const MyQuaternion &operand) const {
    return MyQuaternion(a * operand.a - b * operand.b - c * operand.c - d * operand.d,
                    a * operand.b + b * operand.a + c * operand.d - d * operand.c,
                    a * operand.c - b * operand.d + c * operand.a + d * operand.b,
                    a * operand.d + b * operand.c - c * operand.b + d * operand.a);
}
Пример #4
0
MyQuaternion MyQuaternion::complement() const {
    return MyQuaternion(a, -b, -c, -d);
}
Пример #5
0
MyQuaternion MyQuaternion::normalize() {
    double temp = std::sqrt(a * a + b * b + c * c + d * d);
    return MyQuaternion(a / temp, b / temp, c / temp, d / temp);
}