Thank you very much, mjm for :
Fixing LSL multiplication and division operators for quaternions0.6.0-stable
parent
fbac37ad8c
commit
e25818d832
|
@ -211,21 +211,16 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
Quaternion vq = new Quaternion(v.x, v.y, v.z, 0);
|
Quaternion vq = new Quaternion(v.x, v.y, v.z, 0);
|
||||||
Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s);
|
Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s);
|
||||||
|
|
||||||
Quaternion result = (r * vq) * nq;
|
// adapted for operator * computing "b * a"
|
||||||
|
Quaternion result = nq * (vq * r);
|
||||||
|
|
||||||
return new Vector3(result.x, result.y, result.z);
|
return new Vector3(result.x, result.y, result.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I *think* this is how it works....
|
public static Vector3 operator /(Vector3 v, Quaternion r)
|
||||||
public static Vector3 operator /(Vector3 vec, Quaternion quat)
|
|
||||||
{
|
{
|
||||||
quat.s = -quat.s;
|
r.s = -r.s;
|
||||||
Quaternion vq = new Quaternion(vec.x, vec.y, vec.z, 0);
|
return v * r;
|
||||||
Quaternion nq = new Quaternion(-quat.x, -quat.y, -quat.z, quat.s);
|
|
||||||
|
|
||||||
Quaternion result = (quat * vq) * nq;
|
|
||||||
|
|
||||||
return new Vector3(result.x, result.y, result.z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -371,9 +366,8 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
|
|
||||||
public static Quaternion operator /(Quaternion a, Quaternion b)
|
public static Quaternion operator /(Quaternion a, Quaternion b)
|
||||||
{
|
{
|
||||||
Quaternion c = a * b;
|
b.s = -b.s;
|
||||||
c.s = c.s * -1;
|
return a * b;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Quaternion operator -(Quaternion a, Quaternion b)
|
public static Quaternion operator -(Quaternion a, Quaternion b)
|
||||||
|
@ -381,7 +375,8 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s);
|
return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Quaternion operator *(Quaternion a, Quaternion b)
|
// using the equations below, we need to do "b * a" to be compatible with LSL
|
||||||
|
public static Quaternion operator *(Quaternion b, Quaternion a)
|
||||||
{
|
{
|
||||||
Quaternion c;
|
Quaternion c;
|
||||||
c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y;
|
c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y;
|
||||||
|
|
Loading…
Reference in New Issue