refactor: code styles enforced with .editorconfig
This commit is contained in:
@@ -173,17 +173,13 @@ public readonly struct Line(Vector2D from, Vector2D to)
|
||||
/// </summary>
|
||||
public static Vector2D ClosestPointTo(Line line, Vector2D point)
|
||||
{
|
||||
// Convert edge points to vectors
|
||||
var edgeVector = new Vector2D(line.To.X - line.From.X, line.To.Y - line.From.Y);
|
||||
var pointVector = new Vector2D(point.X - line.From.X, point.Y - line.From.Y);
|
||||
Vector2D edgeVector = new(line.To.X - line.From.X, line.To.Y - line.From.Y);
|
||||
Vector2D pointVector = new(point.X - line.From.X, point.Y - line.From.Y);
|
||||
|
||||
// Calculate the projection of pointVector onto edgeVector
|
||||
float t = (pointVector.X * edgeVector.X + pointVector.Y * edgeVector.Y) / (edgeVector.X * edgeVector.X + edgeVector.Y * edgeVector.Y);
|
||||
|
||||
// Clamp t to the range [0, 1] to ensure the closest point is on the edge
|
||||
t = MathF.Max(0, MathF.Min(1, t));
|
||||
|
||||
// Calculate the closest point on the edge
|
||||
float closestX = line.From.X + t * edgeVector.X;
|
||||
float closestY = line.From.Y + t * edgeVector.Y;
|
||||
|
||||
@@ -207,13 +203,11 @@ public static class LineExtensions
|
||||
/// </summary>
|
||||
public static Vector2D Lerp(this Line line, float t) => Line.Lerp(line, t);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The equation of the <see cref="Line"/> defined by this <see cref="Line"/> segment.
|
||||
/// </summary>
|
||||
public static LineEquation ToLineEquation(this Line line) => Line.GetLineEquation(line);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="Vector2D"/> lies on the <see cref="Line"/>.
|
||||
/// </summary>
|
||||
@@ -224,13 +218,11 @@ public static class LineExtensions
|
||||
/// </summary>
|
||||
public static float GetT(this Line line, Vector2D point) => Line.GetT(line, point);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="Line"/> segment intersects with another <see cref="Line"/> segment.
|
||||
/// </summary>
|
||||
public static bool Intersects(this Line left, Line right) => Line.Intersects(left, right);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="Line"/> segments intersect.
|
||||
/// </summary>
|
||||
|
@@ -27,7 +27,7 @@ public readonly struct Projection(float min, float max)
|
||||
/// <param name="left">The first projection to check.</param>
|
||||
/// <param name="right">The second projection to check.</param>
|
||||
/// <returns><see cref="true"/> if the projections overlap; otherwise, <see cref="false"/>.</returns>
|
||||
public static bool Overlaps(Projection left, Projection right) => Overlaps(left, right, out var _);
|
||||
public static bool Overlaps(Projection left, Projection right) => Overlaps(left, right, out float _);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two projections overlap and calculates the depth of the overlap.
|
||||
|
Reference in New Issue
Block a user