Table of Contents

Class BorderGeometryUtils

Namespace
Map.Rendering.Border
Assembly
MapAssembly.dll

Geometric utility functions for border processing Extracted from BorderCurveExtractor for reusability

Contains:

  • Line segment intersection detection
  • Path self-intersection checking
  • Convex hull computation (Graham scan)
  • Distance calculations
  • Angle calculations
public static class BorderGeometryUtils
Inheritance
object
BorderGeometryUtils

Methods

CalculateAngle(Vector2, Vector2, Vector2)

Calculate angle in degrees at point B formed by line A-B-C Returns 0° for straight line, 180° for complete reversal

public static float CalculateAngle(Vector2 pointA, Vector2 pointB, Vector2 pointC)

Parameters

pointA Vector2
pointB Vector2
pointC Vector2

Returns

float

ComputeConvexHull(List<Vector2>)

Compute convex hull of points using Graham scan algorithm Returns hull vertices in counter-clockwise order

public static List<Vector2> ComputeConvexHull(List<Vector2> points)

Parameters

points List<Vector2>

Returns

List<Vector2>

DistancePointToSegment(Vector2, Vector2, Vector2)

Compute distance from point to line segment

public static float DistancePointToSegment(Vector2 point, Vector2 segStart, Vector2 segEnd)

Parameters

point Vector2
segStart Vector2
segEnd Vector2

Returns

float

FilterToConvexHullPerimeter(List<Vector2>)

Filter border pixels to convex hull perimeter, removing interior pixels This prevents U-turns caused by peninsula indents creating interior loops

public static List<Vector2> FilterToConvexHullPerimeter(List<Vector2> pixels)

Parameters

pixels List<Vector2>

Returns

List<Vector2>

IsPointOnOrNearPolyline(Vector2, List<Vector2>, float)

Check if point is on or near a polyline (within tolerance distance)

public static bool IsPointOnOrNearPolyline(Vector2 point, List<Vector2> polyline, float tolerance)

Parameters

point Vector2
polyline List<Vector2>
tolerance float

Returns

bool

LineSegmentsIntersect(Vector2, Vector2, Vector2, Vector2)

Check if two line segments intersect (not just touch at endpoints) Uses cross product method for robust intersection detection

public static bool LineSegmentsIntersect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4)

Parameters

p1 Vector2
p2 Vector2
p3 Vector2
p4 Vector2

Returns

bool

PathSelfIntersects(List<Vector2>)

Check if path self-intersects (detects U-turns)

public static bool PathSelfIntersects(List<Vector2> path)

Parameters

path List<Vector2>

Returns

bool