add a Normalize() method for LSL_Rotation

cpu-performance
dahlia 2013-06-10 16:42:49 -07:00
parent 7af97f88b7
commit a949556c4e
1 changed files with 25 additions and 0 deletions

View File

@ -371,6 +371,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
#endregion
#region Methods
public Quaternion Normalize()
{
double length = Math.Sqrt(x * x + y * y + z * z + s * s);
if (length < float.Epsilon)
{
x = 1;
y = 0;
z = 0;
s = 0;
}
else
{
double invLength = 1.0 / length;
x *= invLength;
y *= invLength;
z *= invLength;
s *= invLength;
}
return this;
}
#endregion
#region Overriders
public override int GetHashCode()