
project2segment(X, Y)
"ppp"
)."psp"
).X
, and its entries correspond to the
points of X
."ppp"
containing the projected points.X
to
the corresponding projected point.mapXY[2] = 5
and tp[2] = 0.33
.
Then Y[5]
is the line segment lying closest to X[2]
.
The projection of the point X[2]
onto the segment Y[5]
is the point Xproj[2]
, which lies one-third of the way
between the first and second endpoints of the line segment Y[5]
.x
in the point pattern X
, this function
finds the closest line segment y
in the line segment pattern
Y
. It then `projects' the point x
onto the line segment
y
by finding the position z
along y
which is closest to x
. This position z
is returned,
along with supplementary information.nearestsegment
for a faster way to determine
which segment is closest to each point.X <- rstrat(square(1), 5)
Y <- as.psp(matrix(runif(20), 5, 4), window=owin())
plot(Y, lwd=3, col="green")
plot(X, add=TRUE, col="red", pch=16)
v <- project2segment(X,Y)
Xproj <- v$Xproj
plot(Xproj, add=TRUE, pch=16)
arrows(X$x, X$y, Xproj$x, Xproj$y, angle=10, length=0.15, col="red")
Run the code above in your browser using DataLab