Mathematics: Distance 2D

The following table shows what queries are implemented and gives you an easy lookup for the source code. The acronyms are point (PNT), line (LIN), ray (RAY), segment (SEG), aligned box (ABX), oriented box (OBX), rectangle (RCT), triangle (TRI), polygon (PGN), circular arc (ARC), circle (CIR) and ellipse (ELL). Selecting a table entry will load the source code in a separate browser tab. If you are looking for a query that is not in this table, send us a request and we will try to schedule time to implement it.

  PNT LIN RAY SEG ABX OBX RCT TRI PGN ARC CIR ELL
PNT - -
LIN - - - -
RAY - - - -
SEG - - - - -
ABX - - - - - - -
OBX - - - - - - - -
RCT - - - - - - - - - - -
TRI - - - - - - - - - - -
PGN - - - - - - - - - - - -
ARC - - - - - - - -
CIR - - - - - - - -
ELL - - - - - - - - - - -



Template definition for distance and closest-point queries.
Point-linear distance queries: point-line, point-ray, point-segment, point-arc, point-circle
Point-planar distance queries: point-alignedbox, point-orientedbox, point-ellipse, point-triangle. The point-triangle PDF for 3D applies in general dimensions; in particular, it applies to 2D.
Linear-linear and linear-circle distance queries: line-line, line-ray, line-segment, ray-ray, ray-segment, segment-segment, line2-circle2, ray2-circle2. The DistanceSegmentSegment file have an implementation for segment-segment that is robust when using floating-point arithmetic and works in any dimension. The PDF file has a description of the new algorithm.
Circle-circle distance query in 2D.
Linear-planar distance queries: line-alignedbox, line-orientedbox, ray-alignedbox, ray-orientedbox, segment-alignedbox, segment-orientedbox
Planar-planar distance queries: alignedbox-alignedbox