mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Box2 from two points (#3211)
This commit is contained in:
@@ -125,6 +125,34 @@ namespace Robust.Shared.Maths
|
||||
return FromDimensions(-size / 2, size);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Box2 FromTwoPoints(Vector2 a, Vector2 b)
|
||||
{
|
||||
float minX, minY, maxX, maxY;
|
||||
if (a.X < b.X)
|
||||
{
|
||||
minX = a.X;
|
||||
maxX = b.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
minX = b.X;
|
||||
maxX = a.X;
|
||||
}
|
||||
if (a.Y < b.Y)
|
||||
{
|
||||
minY = a.Y;
|
||||
maxY = b.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
minY = b.Y;
|
||||
maxY = a.Y;
|
||||
}
|
||||
|
||||
return new Box2(minX, minY, maxX, maxY);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Intersects(in Box2 other)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user