refactor: TransformFoo like extension methods renamed to Transform
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
@@ -278,6 +279,17 @@ public readonly struct Vector2D(float x, float y)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the <see cref="Vector2D"/> using the specified <see cref="ITransform2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to transform.</param>
|
||||
/// <param name="transform">The <see cref="ITransform2D"/> to apply.</param>
|
||||
/// <returns>The transformed <see cref="Vector2D"/>.</returns>
|
||||
public static Vector2D Transform(Vector2D vector, ITransform2D transform)
|
||||
=> vector.Scale(transform.Scale)
|
||||
.Rotate(transform.Rotation * Math.DegreeToRadian)
|
||||
.Add(transform.Position);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Vector2D"/>s are approximately equal within a specified epsilon range.
|
||||
/// </summary>
|
||||
@@ -379,6 +391,12 @@ public static class Vector2DExtensions
|
||||
/// <inheritdoc cref="Vector2D.Dot(Vector2D, Vector2D)" />
|
||||
public static float Dot(this Vector2D left, Vector2D right) => Vector2D.Dot(left, right);
|
||||
|
||||
/// <inheritdoc cref="Vector2D.Transform(Vector2D, ITransform2D)" />
|
||||
public static Vector2D Transform(this Vector2D vector, ITransform2D transform) => Vector2D.Transform(vector, transform);
|
||||
|
||||
/// <inheritdoc cref="Vector2D.Transform(Vector2D, ITransform2D)" />
|
||||
public static Vector2D Transform(this ITransform2D transform, Vector2D vector) => Vector2D.Transform(vector, transform);
|
||||
|
||||
/// <inheritdoc cref="Vector2D.ApproximatelyEquals(Vector2D, Vector2D, float) " />
|
||||
public static bool ApproximatelyEquals(this Vector2D left, Vector2D right, float epsilon = float.Epsilon) => Vector2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user