private bool projectionIntersectionCheck(LineSegment other, IntersectionCheckOptions option) { bool call1 = projectionIntersection(Start.X, End.X, other.Start.X, other.End.X, option); bool call2 = projectionIntersection(Start.Y, End.Y, other.Start.Y, other.End.Y, option); return(call1 && call2); }
private bool signedTriangleSquareCheck(LineSegment other, IntersectionCheckOptions option) { int call1 = signedTriangleSquare(Start, End, other.Start); int call2 = signedTriangleSquare(Start, End, other.End); int call3 = signedTriangleSquare(other.Start, other.End, Start); int call4 = signedTriangleSquare(other.Start, other.End, End); return option == IntersectionCheckOptions.WithoutEdgePoints ? call1*call2 < 0 && call3*call4 < 0 : call1*call2 <= 0 && call3*call4 <= 0; }
private bool signedTriangleSquareCheck(LineSegment other, IntersectionCheckOptions option) { int call1 = signedTriangleSquare(Start, End, other.Start); int call2 = signedTriangleSquare(Start, End, other.End); int call3 = signedTriangleSquare(other.Start, other.End, Start); int call4 = signedTriangleSquare(other.Start, other.End, End); return(option == IntersectionCheckOptions.WithoutEdgePoints ? call1 * call2 < 0 && call3 * call4 < 0 : call1 *call2 <= 0 && call3 *call4 <= 0); }
private static bool projectionIntersection(int a, int b, int c, int d, IntersectionCheckOptions option) { if (a > b){ HelperUtils.Swap(ref a, ref b); } if (c > d){ HelperUtils.Swap(ref c, ref d); } return option == IntersectionCheckOptions.WithoutEdgePoints ? Math.Max(a, c) < Math.Min(b, d) : Math.Max(a, c) <= Math.Min(b, d); }
public bool IntersectsWithLineSegment(LineSegment segment, IntersectionCheckOptions option) { bool result = false; for (int i = 1; i < Count && !result; i++) { result = segment.Intersects(new LineSegment(this[i - 1], this[i]), option); } return(result); }
private static bool projectionIntersection(int a, int b, int c, int d, IntersectionCheckOptions option) { if (a > b) { HelperUtils.Swap(ref a, ref b); } if (c > d) { HelperUtils.Swap(ref c, ref d); } return(option == IntersectionCheckOptions.WithoutEdgePoints ? Math.Max(a, c) < Math.Min(b, d) : Math.Max(a, c) <= Math.Min(b, d)); }
private bool projectionIntersectionCheck(LineSegment other, IntersectionCheckOptions option) { bool call1 = projectionIntersection(Start.X, End.X, other.Start.X, other.End.X, option); bool call2 = projectionIntersection(Start.Y, End.Y, other.Start.Y, other.End.Y, option); return call1 && call2; }
public bool Intersects(LineSegment other, IntersectionCheckOptions option) { return projectionIntersectionCheck(other, option) && signedTriangleSquareCheck(other, option); }
public bool Intersects(LineSegment other, IntersectionCheckOptions option) { return(projectionIntersectionCheck(other, option) && signedTriangleSquareCheck(other, option)); }