Пример #1
0
    // Quarternion multiplication
    public static Quarts operator *(Quarts S, Quarts R)
    {
        Quarts r = new Quarts(0, new Vectors(0, 0, 0));

        // Turn Quarternions into vectors for calculating xyz values later
        Vectors SV = GetAxis(S);
        Vectors RV = GetAxis(R);

        // Calculates the new W value
        float Cross = Vectors.DotProduct(GetAxis(S), GetAxis(R));

        r.w = (S.w * R.w) - Cross;

        // Calculates the new XYZ values
        Vectors temp = new Vectors(0, 0, 0);

        temp = ((RV * S.w) + (SV * R.w) + Vectors.CrossProduct(RV, SV));

        // Put the new xyz values into the return quaternion
        r.x = temp.x;
        r.y = temp.y;
        r.z = temp.z;

        return(r);
    }