Example #1
0
    public static float Angle(MyQuat q1, MyQuat q2)
    {
        q1.Normalization();
        q2.Normalization();

        q2.Inverse();
        MyQuat newQuaternion = new MyQuat();

        newQuaternion = MyQuat.Multiply(q1, q2);

        return(2 * Mathf.Acos(newQuaternion.w) * Mathf.Rad2Deg);
    }
Example #2
0
    public static MyQuat Axis2Quad(float angle, MyVector3 v3)
    {
        MyQuat axisQuat = new MyQuat();

        // RADIANES

        v3.Normalize();

        float radianAngle = angle * Mathf.Deg2Rad;

        axisQuat.x = v3.x * Mathf.Sin(radianAngle / 2);
        axisQuat.y = v3.y * Mathf.Sin(radianAngle / 2);
        axisQuat.z = v3.z * Mathf.Sin(radianAngle / 2);
        axisQuat.w = Mathf.Cos(radianAngle / 2);

        axisQuat.Normalization();

        return(axisQuat);
    }