Distance of a Point to a Segment

The distance of a point to a segment is the length of the shortest line joining the point to a point on the segment. This Demonstration depicts this shortest line as dotted. The measurements are normalized so that the point starts at a distance of 1 to the segment.

SNAPSHOTS

  • [Snapshot]
  • [Snapshot]
  • [Snapshot]

DETAILS

To compute the distance from point p to segment ab (all as complex numbers) compute first z=(p-a)/(b-a). If 0 ≤ Re[z] ≤ 1 then the distance is equal to Abs[Im[z](b-a)]. If not, it is equal to the smallest of the distances from p to a or to b.

RELATED LINKS

    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.







Related Curriculum Standards

US Common Core State Standards, Mathematics