Refactor out some duplicate code.
parent
c1bec32efc
commit
6da664edbe
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue