fix llRot2Axis(ZERO_ROTATION) and non normalized inputs, same for llRot2Angle()
parent
78c78f69b1
commit
218160494e
|
@ -5527,21 +5527,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (Math.Abs(rot.s) > 1) // normalization needed
|
||||
rot.Normalize();
|
||||
|
||||
double s = Math.Sqrt(1 - rot.s * rot.s);
|
||||
if (s < 0.001)
|
||||
{
|
||||
return new LSL_Vector(1, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s < 1e-8)
|
||||
return new LSL_Vector(0, 0, 0);
|
||||
|
||||
double invS = 1.0 / s;
|
||||
if (rot.s < 0) invS = -invS;
|
||||
if (rot.s < 0)
|
||||
invS = -invS;
|
||||
return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Returns the angle of a quaternion (see llRot2Axis for the axis)
|
||||
|
@ -5549,7 +5545,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (Math.Abs(rot.s) > 1) // normalization needed
|
||||
rot.Normalize();
|
||||
|
||||
double angle = 2 * Math.Acos(rot.s);
|
||||
|
|
Loading…
Reference in New Issue