Aurora.ScriptEngine.AuroraDotNetEngine.APIs.LSL_Api.llRot2Axis C# (CSharp) Method

llRot2Axis() public method

public llRot2Axis ( Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Quaternion rot ) : Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3
rot Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Quaternion
return Aurora.ScriptEngine.AuroraDotNetEngine.LSL_Types.Vector3
        public LSL_Vector llRot2Axis(LSL_Rotation rot)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return new LSL_Vector();

            double x, y, z;

            if (rot.s > 1) // normalization needed
            {
                double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
                        rot.z * rot.z + rot.s * rot.s);
                if (length == 0)
                    return new LSL_Vector(0, 0, 0);
                length = 1 / length;
                rot.x *= length;
                rot.y *= length;
                rot.z *= length;
                rot.s *= length;
            }

            // double angle = 2 * Math.Acos(rot.s);
            double s = Math.Sqrt(1 - rot.s * rot.s);
            if (s < 0.001)
            {
                x = 1;
                y = z = 0;
            }
            else
            {
                s = 1 / s;
                x = rot.x * s; // normalise axis
                y = rot.y * s;
                z = rot.z * s;
            }

            return new LSL_Vector(x, y, z);
        }
LSL_Api