Refactor out some duplicate code.

0.6.0-stable
Jeff Ames 2008-03-11 22:15:28 +00:00
parent c1bec32efc
commit 6da664edbe
2 changed files with 5 additions and 5 deletions

View File

@ -191,13 +191,13 @@ namespace OpenSim.Region.ScriptEngine.Common
public double llVecMag(LSL_Types.Vector3 v) public double llVecMag(LSL_Types.Vector3 v)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); return LSL_Types.Vector3.Mag(v);
} }
public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
double mag = Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); double mag = LSL_Types.Vector3.Mag(v);
LSL_Types.Vector3 nor = new LSL_Types.Vector3(); LSL_Types.Vector3 nor = new LSL_Types.Vector3();
nor.x = v.x / mag; nor.x = v.x / mag;
nor.y = v.y / mag; nor.y = v.y / mag;

View File

@ -231,14 +231,14 @@ namespace OpenSim.Region.ScriptEngine.Common
); );
} }
public static float Mag(Vector3 v) public static double Mag(Vector3 v)
{ {
return (float)Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
} }
public static Vector3 Norm(Vector3 vector) public static Vector3 Norm(Vector3 vector)
{ {
float mag = Mag(vector); double mag = Mag(vector);
return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag);
} }