feat: add VectorExtensions(WithX, WithY,...)

This commit is contained in:
goaaats 2022-05-27 22:34:42 +02:00
parent 71aeee605d
commit 3ff67c709d
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -0,0 +1,56 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
namespace Dalamud.Utility.Numerics;
/// <summary>
/// Extension methods for vectors.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Redundant.")]
public static class VectorExtensions
{
public static Vector4 WithX(this Vector4 v, float x)
{
return new Vector4(x, v.Y, v.Z, v.W);
}
public static Vector4 WithY(this Vector4 v, float y)
{
return new Vector4(v.X, y, v.Z, v.W);
}
public static Vector4 WithZ(this Vector4 v, float z)
{
return new Vector4(v.X, v.Y, z, v.W);
}
public static Vector4 WithW(this Vector4 v, float w)
{
return new Vector4(v.X, v.Y, v.Z, w);
}
public static Vector3 WithX(this Vector3 v, float x)
{
return new Vector3(x, v.Y, v.Z);
}
public static Vector3 WithY(this Vector3 v, float y)
{
return new Vector3(v.X, y, v.Z);
}
public static Vector3 WithZ(this Vector3 v, float z)
{
return new Vector3(v.X, v.Y, z);
}
public static Vector2 WithX(this Vector2 v, float x)
{
return new Vector2(x, v.Y);
}
public static Vector2 WithY(this Vector2 v, float y)
{
return new Vector2(v.X, y);
}
}