Learn R Programming

healthcareai (version 1.2.4)

distancePointSegment: Compute the distance of a point from a line segment

Description

compute the distance of a point from a line segment given the x, y axes of the points.

Usage

distancePointSegment(px, py, x1, y1, x2, y2)

Arguments

px

A numeric vector, x axis of the points

py

A numeric vector, y axis of the points

x1

A number, x axis of the end point of the line segment

y1

A number, y axis of the end point of the line segment

x2

A number, x axis of the other end point of the line segment

y2

A number, y axis of the other end point of the line segment

Value

numeric vector, the length between the pointS and the line segment. If the intersection point is outside the line segment, return the distance to the nearest endpoint.

References

http://healthcare.ai

The helper funtion is originally found here http://paulbourke.net/geometry/pointlineplane/pointline.r

https://github.com/bryanhanson/ChemoSpecMarkeR/blob/master/R/findElbow.R

See Also

healthcareai

Examples

Run this code
# NOT RUN {
distancePointSegment(c(2,0),c(3,2),1,2,3,1)
# }

Run the code above in your browser using DataLab