DropPerpendicular | Cellzilla2D Home |
Description
Given a point and a line segement, find the intersection of the line through the point with a line perpendicular to the original segment.
Needs["Cellzilla2D`"];
Return Value
DropPerpendicular[{x,y}, {{lx1,ly1}, {lx2,ly2}} ] - returns the coordinates of the intersection of the line through {x, y} that is perpendicular to the line segment from {lx1,ly1} to {lx2,ly2}, but only if the point is between the two endpoints; returns $Failed if the perpendicular does not intersect the segment.
DropPerpendicular[{x,y}, {{lx1,ly1}, {lx2,ly2}}, True ] - same as the first form if the intersection is between the endpoints of the line segment; if the intersection is not between the endpoints, the intersection is "slid" to the nearest endpoint. This form finds the shortest distance between the point and the line segment.Options
Example
[ Download Example as Zipped Mathematica Notebook ]
Implementation Notes
See Also