mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 07:25:28 +00:00
Changed vector-quaternion transformations to use standard q * v * q^-1 convention. Fixes issue [#1372]: "[Math] Vector transformation by Quaternion follows non-standard quaternion math convention".
This commit is contained in:
parent
6471772777
commit
0605607e6a
|
@ -908,12 +908,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector2 vec, ref Quaternion quat, out Vector2 result)
|
||||
{
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0);
|
||||
Quaternion i;
|
||||
Quaternion t;
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0), i, t;
|
||||
Quaternion.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaternion.Multiply(ref quat, ref v, out t);
|
||||
Quaternion.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector2(v.X, v.Y);
|
||||
}
|
||||
|
|
|
@ -796,12 +796,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result)
|
||||
{
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0);
|
||||
Quaterniond i;
|
||||
Quaterniond t;
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0), i, t;
|
||||
Quaterniond.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||
Quaterniond.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector2d(v.X, v.Y);
|
||||
}
|
||||
|
|
|
@ -1115,12 +1115,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector3 vec, ref Quaternion quat, out Vector3 result)
|
||||
{
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0);
|
||||
Quaternion i;
|
||||
Quaternion t;
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, 0), i, t;
|
||||
Quaternion.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaternion.Multiply(ref quat, ref v, out t);
|
||||
Quaternion.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector3(v.X, v.Y, v.Z);
|
||||
}
|
||||
|
|
|
@ -1111,12 +1111,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector3d vec, ref Quaterniond quat, out Vector3d result)
|
||||
{
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0);
|
||||
Quaterniond i;
|
||||
Quaterniond t;
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, 0), i, t;
|
||||
Quaterniond.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||
Quaterniond.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector3d(v.X, v.Y, v.Z);
|
||||
}
|
||||
|
|
|
@ -963,12 +963,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector4 vec, ref Quaternion quat, out Vector4 result)
|
||||
{
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W);
|
||||
Quaternion i;
|
||||
Quaternion t;
|
||||
Quaternion v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W), i, t;
|
||||
Quaternion.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaternion.Multiply(ref quat, ref v, out t);
|
||||
Quaternion.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector4(v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
|
|
|
@ -966,12 +966,10 @@ namespace OpenTK
|
|||
/// <param name="result">The result of the operation.</param>
|
||||
public static void Transform(ref Vector4d vec, ref Quaterniond quat, out Vector4d result)
|
||||
{
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W);
|
||||
Quaterniond i;
|
||||
Quaterniond t;
|
||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W), i, t;
|
||||
Quaterniond.Invert(ref quat, out i);
|
||||
t = i * v;
|
||||
v = t * quat;
|
||||
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||
Quaterniond.Multiply(ref t, ref i, out v);
|
||||
|
||||
result = new Vector4d(v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue