示例#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);
}