# NOT RUN {
K <- owin(poly=list(x=c(2.5,2,0.5,-2.5,-2,-0.5),y=c(0,1,2,0,-1,-2)))
plot(K)
points(0,0)
m <- convexmetric(K)
m
summary(m)
## show redwood data and identify point number 43
plot(redwood, main="")
plot(redwood[43], pch=16, add=TRUE)
## compute nearest neighbour distances and identifiers
## using the distance metric m
nd <- nndist(redwood, metric=m)
nw <- nnwhich(redwood, metric=m)
## Nearest neighbour distance for point number 43 is nd[43]; verify
B43 <- disc(radius=nd[43], centre=redwood[43], metric=m)
plot(B43, add=TRUE)
## nearest neighbour for point number 43 is point number nw[43]; verify
plot(redwood[nw[43]], pch=3, col="red", add=TRUE)
# }
Run the code above in your browser using DataLab