fix: Adds GetDistanceToSqrt for Point3D and centralizes all the calls (#2233)

This commit is contained in:
Kamron Batman 2025-07-18 09:24:41 -07:00 • committed by GitHub
parent 2086e9b292
commit 416e1be735
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 56 additions and 39 deletions

View file

@ -1524,4 +1524,53 @@ public static partial class Utility
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double GetDistanceToSqrt(this IEntity entity, Point2D p) => GetDistanceToSqrt(entity.Location, p);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double GetDistanceToSqrt(this IEntity entity, Point3D p) => GetDistanceToSqrt(entity.Location, p);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double GetDistanceToSqrt(this IEntity from, IEntity to) => GetDistanceToSqrt(from.Location, to.Location);
public static double GetDistanceToSqrt(this IEntity entity, IPoint2D p)
{
var xDelta = entity.X - p.X;
var yDelta = entity.Y - p.Y;
return Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
}
public static double GetDistanceToSqrt(this Point2D from, Point2D to)
{
var xDelta = from.m_X - to.m_X;
var yDelta = from.m_Y - to.m_Y;
return Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
}
public static double GetDistanceToSqrt(this Point2D from, Point3D to)
{
var xDelta = from.m_X - to.m_X;
var yDelta = from.m_Y - to.m_Y;
return Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
}
public static double GetDistanceToSqrt(this Point3D from, Point2D to)
{
var xDelta = from.m_X - to.m_X;
var yDelta = from.m_Y - to.m_Y;
return Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
}
public static double GetDistanceToSqrt(this Point3D from, Point3D to)
{
var xDelta = from.m_X - to.m_X;
var yDelta = from.m_Y - to.m_Y;
return Math.Sqrt(xDelta * xDelta + yDelta * yDelta);
}
}