Reverse order of arguments in quaternion multiplication in order to bring it in line with BulletX physics engine and Unity3D (it's reversed in LSL). Also should fix breakage in code that depends on this ordering like Opensim.
TODO: comprehensive test suite for quaternion math git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3462 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -115,7 +115,7 @@ namespace OpenMetaverse.Tests
|
||||
|
||||
a = new Quaternion(1, 0, 0, 0);
|
||||
b = new Quaternion(0, 1, 0, 0);
|
||||
expected = new Quaternion(0, 0, -1, 0);
|
||||
expected = new Quaternion(0, 0, 1, 0);
|
||||
result = a * b;
|
||||
|
||||
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
|
||||
@@ -123,7 +123,7 @@ namespace OpenMetaverse.Tests
|
||||
|
||||
a = new Quaternion(0, 0, 1, 0);
|
||||
b = new Quaternion(0, 1, 0, 0);
|
||||
expected = new Quaternion(1, 0, 0, 0);
|
||||
expected = new Quaternion(-1, 0, 0, 0);
|
||||
result = a * b;
|
||||
|
||||
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
|
||||
|
||||
@@ -602,10 +602,10 @@ namespace OpenMetaverse
|
||||
public static Quaternion Multiply(Quaternion a, Quaternion b)
|
||||
{
|
||||
return new Quaternion(
|
||||
b.W * a.X + b.X * a.W + b.Y * a.Z - b.Z * a.Y,
|
||||
b.W * a.Y + b.Y * a.W + b.Z * a.X - b.X * a.Z,
|
||||
b.W * a.Z + b.Z * a.W + b.X * a.Y - b.Y * a.X,
|
||||
b.W * a.W - b.X * a.X - b.Y * a.Y - b.Z * a.Z
|
||||
a.W * b.X + a.X * b.W + a.Y * b.Z - a.Z * b.Y,
|
||||
a.W * b.Y + a.Y * b.W + a.Z * b.X - a.X * b.Z,
|
||||
a.W * b.Z + a.Z * b.W + a.X * b.Y - a.Y * b.X,
|
||||
a.W * b.W - a.X * b.X - a.Y * b.Y - a.Z * b.Z
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user