mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 00:05:37 +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>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector2 vec, ref Quaternion quat, out Vector2 result)
|
public static void Transform(ref Vector2 vec, ref Quaternion quat, out Vector2 result)
|
||||||
{
|
{
|
||||||
Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0);
|
Quaternion v = new Quaternion(vec.X, vec.Y, 0, 0), i, t;
|
||||||
Quaternion i;
|
|
||||||
Quaternion t;
|
|
||||||
Quaternion.Invert(ref quat, out i);
|
Quaternion.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaternion.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaternion.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector2(v.X, v.Y);
|
result = new Vector2(v.X, v.Y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,12 +796,10 @@ namespace OpenTK
|
||||||
/// <param name="result">The result of the operation.</param>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result)
|
public static void Transform(ref Vector2d vec, ref Quaterniond quat, out Vector2d result)
|
||||||
{
|
{
|
||||||
Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0);
|
Quaterniond v = new Quaterniond(vec.X, vec.Y, 0, 0), i, t;
|
||||||
Quaterniond i;
|
|
||||||
Quaterniond t;
|
|
||||||
Quaterniond.Invert(ref quat, out i);
|
Quaterniond.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaterniond.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector2d(v.X, v.Y);
|
result = new Vector2d(v.X, v.Y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1115,12 +1115,10 @@ namespace OpenTK
|
||||||
/// <param name="result">The result of the operation.</param>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector3 vec, ref Quaternion quat, out Vector3 result)
|
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 v = new Quaternion(vec.X, vec.Y, vec.Z, 0), i, t;
|
||||||
Quaternion i;
|
|
||||||
Quaternion t;
|
|
||||||
Quaternion.Invert(ref quat, out i);
|
Quaternion.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaternion.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaternion.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector3(v.X, v.Y, v.Z);
|
result = new Vector3(v.X, v.Y, v.Z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1111,12 +1111,10 @@ namespace OpenTK
|
||||||
/// <param name="result">The result of the operation.</param>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector3d vec, ref Quaterniond quat, out Vector3d result)
|
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 v = new Quaterniond(vec.X, vec.Y, vec.Z, 0), i, t;
|
||||||
Quaterniond i;
|
|
||||||
Quaterniond t;
|
|
||||||
Quaterniond.Invert(ref quat, out i);
|
Quaterniond.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaterniond.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector3d(v.X, v.Y, v.Z);
|
result = new Vector3d(v.X, v.Y, v.Z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -963,12 +963,10 @@ namespace OpenTK
|
||||||
/// <param name="result">The result of the operation.</param>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector4 vec, ref Quaternion quat, out Vector4 result)
|
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 v = new Quaternion(vec.X, vec.Y, vec.Z, vec.W), i, t;
|
||||||
Quaternion i;
|
|
||||||
Quaternion t;
|
|
||||||
Quaternion.Invert(ref quat, out i);
|
Quaternion.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaternion.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaternion.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector4(v.X, v.Y, v.Z, v.W);
|
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>
|
/// <param name="result">The result of the operation.</param>
|
||||||
public static void Transform(ref Vector4d vec, ref Quaterniond quat, out Vector4d result)
|
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 v = new Quaterniond(vec.X, vec.Y, vec.Z, vec.W), i, t;
|
||||||
Quaterniond i;
|
|
||||||
Quaterniond t;
|
|
||||||
Quaterniond.Invert(ref quat, out i);
|
Quaterniond.Invert(ref quat, out i);
|
||||||
t = i * v;
|
Quaterniond.Multiply(ref quat, ref v, out t);
|
||||||
v = t * quat;
|
Quaterniond.Multiply(ref t, ref i, out v);
|
||||||
|
|
||||||
result = new Vector4d(v.X, v.Y, v.Z, v.W);
|
result = new Vector4d(v.X, v.Y, v.Z, v.W);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue