ClosestPoint: Find Closest Point

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/ClosestPoint.R

Description

Find the the point on a line segment (x1,y1) (x2,y2) that is closest to point (px,py).

Usage

1
ClosestPoint(px, py, x1, y1, x2, y2)

Arguments

px

x coordinate of point

py

y coordinate of point

x1

x coordinate of one end of a segment

y1

y coordinate of one end of a segment

x2

x coordenite of other end of a segment

y2

y coordinate of other end of a segment

Details

This function finds the the point on a line segment (x1,y1) (x2,y2) that is closest to point (px,py). If the line perpendicular to the line segment does not intersect the segment, the function will return an end point of the segment, otherwise, it will return a point on the line segment where the perpendicular line intersects the segment.

Value

a point-pair (x,y)

Note

Uses LineMagnitude, also supplied by the pathmapping package.

Author(s)

Shane T. Mueller and Brandon Perelman

References

See Mueller et al., (2016). https://sites.google.com/a/mtu.edu/mapping/

See Also

LineMagnitude, DistancePointSegment

Examples

1
2
3
ClosestPoint(1,10,2,0,5,0)    #returns end point 2 0
ClosestPoint(20,10,2,0,5,0)   #returns other end point 5 0
ClosestPoint(4.5,10,2,0,5,0)  #returns closest point 4.5 0

pathmapping documentation built on May 2, 2019, 4:20 a.m.