forked from MoonsideGames/MoonWorks
add Vector2.Transform Matrix3x2 overload
parent
5424d05d63
commit
0fb7e98cb5
|
@ -877,6 +877,20 @@ namespace MoonWorks.Math
|
||||||
result.Y = value.Y + y * rotation.W + (rotation.Z * x - rotation.X * z);
|
result.Y = value.Y + y * rotation.W + (rotation.Z * x - rotation.X * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="Vector2"/> that contains a transformation of 2d-vector by the specified <see cref="Matrix4x4"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">Source <see cref="Vector2"/>.</param>
|
||||||
|
/// <param name="matrix">The transformation <see cref="Matrix4x4"/>.</param>
|
||||||
|
/// <returns>Transformed <see cref="Vector2"/>.</returns>
|
||||||
|
public static Vector2 Transform(Vector2 position, Matrix3x2 matrix)
|
||||||
|
{
|
||||||
|
return new Vector2(
|
||||||
|
(position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M31,
|
||||||
|
(position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M32
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply transformation on all vectors within array of <see cref="Vector2"/> by the specified <see cref="Matrix4x4"/> and places the results in an another array.
|
/// Apply transformation on all vectors within array of <see cref="Vector2"/> by the specified <see cref="Matrix4x4"/> and places the results in an another array.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue