fix: Build Errors

This commit is contained in:
Syntriax 2024-01-24 12:42:18 +03:00
parent 0c3bf48d2c
commit 56b46b93eb
2 changed files with 19 additions and 8 deletions

View File

@ -107,18 +107,27 @@ public record Line(Vector2D From, Vector2D To)
public static bool Intersects(Line left, Line right) public static bool Intersects(Line left, Line right)
{ {
int o1 = PhysicsMath.Orientation(left.From, left.To, right.From); int o1 = Vector2D.Orientation(left.From, left.To, right.From);
int o2 = PhysicsMath.Orientation(left.From, left.To, right.To); int o2 = Vector2D.Orientation(left.From, left.To, right.To);
int o3 = PhysicsMath.Orientation(right.From, right.To, left.From); int o3 = Vector2D.Orientation(right.From, right.To, left.From);
int o4 = PhysicsMath.Orientation(right.From, right.To, left.To); int o4 = Vector2D.Orientation(right.From, right.To, left.To);
if (o1 != o2 && o3 != o4) if (o1 != o2 && o3 != o4)
return true; return true;
if (o1 == 0 && PhysicsMath.OnSegment(left.From, right.From, left.To)) return true; if (o1 == 0 && OnSegment(left, right.From)) return true;
if (o2 == 0 && PhysicsMath.OnSegment(left.From, right.To, left.To)) return true; if (o2 == 0 && OnSegment(left, right.To)) return true;
if (o3 == 0 && PhysicsMath.OnSegment(right.From, left.From, right.To)) return true; if (o3 == 0 && OnSegment(right, left.From)) return true;
if (o4 == 0 && PhysicsMath.OnSegment(right.From, left.To, right.To)) return true; if (o4 == 0 && OnSegment(right, left.To)) return true;
return false;
}
public static bool OnSegment(Line line, Vector2D point)
{
if (point.X <= MathF.Max(line.From.X, line.To.X) && point.X >= MathF.Min(line.From.X, line.To.X) &&
point.Y <= MathF.Max(line.From.Y, line.To.Y) && point.Y >= MathF.Min(line.From.Y, line.To.Y))
return true;
return false; return false;
} }

View File

@ -1,3 +1,5 @@
using Syntriax.Engine.Core;
namespace Syntriax.Engine.Physics2D.Primitives; namespace Syntriax.Engine.Physics2D.Primitives;
public record LineEquation(float Slope, float OffsetY) public record LineEquation(float Slope, float OffsetY)