Merge branch 'master' into careminster

avinationmerge
Melanie 2013-06-11 01:04:50 +01:00
commit 6b55be6e2f
1 changed files with 6 additions and 22 deletions

View File

@ -5123,37 +5123,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llRot2Axis(LSL_Rotation rot) public LSL_Vector llRot2Axis(LSL_Rotation rot)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
double x,y,z; double x, y, z;
if (rot.s > 1) // normalization needed if (Math.Abs(rot.s) > 1) // normalization needed
{ rot.Normalize();
double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
rot.z * rot.z + rot.s * rot.s);
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); double s = Math.Sqrt(1 - rot.s * rot.s);
if (s < 0.001) if (s < 0.001)
{ {
x = 1; return new LSL_Vector(1, 0, 0);
y = z = 0;
} }
else else
{ {
x = rot.x / s; // normalise axis double invS = 1.0 / s;
y = rot.y / s; return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
z = rot.z / s;
} }
if ((double.IsNaN(x)) || double.IsInfinity(x)) x = 0;
if ((double.IsNaN(y)) || double.IsInfinity(y)) y = 0;
if ((double.IsNaN(z)) || double.IsInfinity(z)) z = 0;
return new LSL_Vector(x,y,z);
} }