diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index 2b38581b..aef6b79d 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -1191,6 +1191,30 @@ namespace OpenTK Vector3.Add(ref vec, ref temp, out result); } + /// Transform a Vector by the given Matrix using right-handed notation + /// The vector to transform + /// The desired transformation + /// The transformed vector + public static void RightHandedTransform(ref Vector3 vec, ref Matrix3 mat, out Vector3 result) + { + result = new Vector3( + mat.Row0.X * vec.X + mat.Row0.Y * vec.Y + mat.Row0.Z * vec.Z, + mat.Row1.X * vec.X + mat.Row1.Y * vec.Y + mat.Row1.Z * vec.Z, + mat.Row2.X * vec.X + mat.Row2.Y * vec.Y + mat.Row2.Z * vec.Z); + } + + /// Transform a Vector by the given Matrix using right-handed notation + /// The vector to transform + /// The desired transformation + /// The transformed vector + public static void RightHandedTransform(ref Vector3 vec, ref Matrix4 mat, out Vector3 result) + { + result = new OpenTK.Vector3( + mat.Row0.X * vec.X + mat.Row0.Y * vec.Y + mat.Row0.Z * vec.Z + mat.Row0.W, + mat.Row1.X * vec.X + mat.Row1.Y * vec.Y + mat.Row1.Z * vec.Z + mat.Row1.W, + mat.Row2.X * vec.X + mat.Row2.Y * vec.Y + mat.Row2.Z * vec.Z + mat.Row2.W); + } + /// Transform a Vector3 by the given Matrix, and project the resulting Vector4 back to a Vector3 /// The vector to transform /// The desired transformation diff --git a/Source/OpenTK/Math/Vector4.cs b/Source/OpenTK/Math/Vector4.cs index 4e8d6777..980da2c6 100644 --- a/Source/OpenTK/Math/Vector4.cs +++ b/Source/OpenTK/Math/Vector4.cs @@ -1017,6 +1017,19 @@ namespace OpenTK result = new Vector4(v.X, v.Y, v.Z, v.W); } + /// Transform a Vector by the given Matrix using right-handed notation + /// The vector to transform + /// The desired transformation + /// The transformed vector + public static void RightHandedTransform(ref Vector4 vec, ref Matrix4 mat, out Vector4 result) + { + result = new OpenTK.Vector4( + mat.Row0.X * vec.X + mat.Row0.Y * vec.Y + mat.Row0.Z * vec.Z + mat.Row0.W * vec.W, + mat.Row1.X * vec.X + mat.Row1.Y * vec.Y + mat.Row1.Z * vec.Z + mat.Row1.W * vec.W, + mat.Row2.X * vec.X + mat.Row2.Y * vec.Y + mat.Row2.Z * vec.Z + mat.Row2.W * vec.W, + mat.Row3.X * vec.X + mat.Row3.Y * vec.Y + mat.Row3.Z * vec.Z + mat.Row3.W * vec.W); + } + #endregion #endregion