File: nearestPointOnSegment.Rd

package info (click to toggle)
r-cran-maptools 1%3A0.8-30-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,896 kB
  • ctags: 230
  • sloc: ansic: 3,007; makefile: 3
file content (42 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\name{nearestPointOnSegment}
\alias{nearestPointOnSegment}
\title{
Get the nearest point on a segment to a given point
}
\description{
This function calculates the coordinates of and the distance to the nearest 
point on a segment to a given point. This function does not work with 
geographic coordinates.
}
\usage{
nearestPointOnSegment(s, p)
}
\arguments{
  \item{s}{
A matrix representing the coordinates of the segment. The matrix has 2x2 
dimension where each row represents one of the end points. 
}
  \item{p}{
A vector representing the X and Y coordinates of the point.
}
}
\value{
A vector with three numeric values representing X and Y coordinates of the 
nearest point on a segment to a given point as well as the distance between
both points.
}
\references{
The function was ported to R based on this code: http://pastebin.com/n9rUuGRh
}
\author{
German Carrillo 
}
\seealso{
\code{\link{nearestPointOnLine}}, \code{\link{snapPointsToLines}} 
}
\examples{
segment = cbind(c(1,2),c(1,1.5))
point = c(1.2,1.5)
nearestPointOnSegment(segment, point)
}
\keyword{ spatial }