mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 20:25:39 +00:00
Multiplication operator for Matrix-Vector transformation and Quaternion-Vector transformations
This commit is contained in:
parent
6ac1c63ff3
commit
66cd883fb4
|
@ -1114,6 +1114,29 @@ namespace OpenTK
|
||||||
mat.Row3.Z;
|
mat.Row3.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Transform a Vector by the given Matrix</summary>
|
||||||
|
/// <param name="vec">The vector to transform</param>
|
||||||
|
/// <param name="mat">The desired transformation</param>
|
||||||
|
/// <returns>The transformed vector</returns>
|
||||||
|
public static Vector3 Transform(Vector3 vec, Matrix3 mat)
|
||||||
|
{
|
||||||
|
Vector3 result;
|
||||||
|
Transform(ref vec, ref mat, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Transform a Vector by the given Matrix</summary>
|
||||||
|
/// <param name="vec">The vector to transform</param>
|
||||||
|
/// <param name="mat">The desired transformation</param>
|
||||||
|
/// <param name="result">The transformed vector</param>
|
||||||
|
public static void Transform(ref Vector3 vec, ref Matrix3 mat, out Vector3 result)
|
||||||
|
{
|
||||||
|
result = new Vector3(
|
||||||
|
vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X,
|
||||||
|
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y,
|
||||||
|
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Transform a Vector by the given Matrix</summary>
|
/// <summary>Transform a Vector by the given Matrix</summary>
|
||||||
/// <param name="vec">The vector to transform</param>
|
/// <param name="vec">The vector to transform</param>
|
||||||
/// <param name="mat">The desired transformation</param>
|
/// <param name="mat">The desired transformation</param>
|
||||||
|
@ -1503,6 +1526,32 @@ namespace OpenTK
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transform a Vector by the given Matrix.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">The vector to transform</param>
|
||||||
|
/// <param name="mat">The desired transformation</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Vector3 operator *(Matrix3 mat, Vector3 vec)
|
||||||
|
{
|
||||||
|
Vector3 result;
|
||||||
|
Vector3.Transform(ref vec, ref mat, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transforms a vector by a quaternion rotation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">The vector to transform.</param>
|
||||||
|
/// <param name="quat">The quaternion to rotate the vector by.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Vector3 operator *(Quaternion quat, Vector3 vec)
|
||||||
|
{
|
||||||
|
Vector3 result;
|
||||||
|
Vector3.Transform(ref vec, ref quat, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Divides an instance by a scalar.
|
/// Divides an instance by a scalar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1506,6 +1506,32 @@ namespace OpenTK
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transform a Vector by the given Matrix.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">The vector to transform</param>
|
||||||
|
/// <param name="mat">The desired transformation</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Vector4 operator *(Matrix4 mat, Vector4 vec)
|
||||||
|
{
|
||||||
|
Vector4 result;
|
||||||
|
Vector4.Transform(ref vec, ref mat, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transforms a vector by a quaternion rotation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vec">The vector to transform.</param>
|
||||||
|
/// <param name="quat">The quaternion to rotate the vector by.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Vector4 operator *(Quaternion quat, Vector4 vec)
|
||||||
|
{
|
||||||
|
Vector4 result;
|
||||||
|
Vector4.Transform(ref vec, ref quat, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Divides an instance by a scalar.
|
/// Divides an instance by a scalar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue