Last chance! 50% off unlimited learning
Sale ends in
Returns the radius for the ball centered at point pt
with radius=min distance to Y
points.
That is, for the point pt
pt
to the closest Y
point).
The point pt
and Y
points must be of same dimension.
radius(pt, Y)
A d-dimensional point for which radius is computed. Radius of pt
equals to the
distance to the closest Y
point to pt
.
A set of d-dimensional points representing the reference points for the balls. That is, radius
of the point pt
is defined as the minimum distance to the Y
points.
A list with three elements
Radius value for the point, pt
defined as
Index of the closest Y
points to the point pt
The closest Y
point to the point pt
# NOT RUN {
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
ny<-10
Y<-cbind(runif(ny),runif(ny))
radius(A,Y)
radius(B,Y)
radius(C,Y)
radius(B,C)
nx<-10
X<-cbind(runif(nx),runif(nx))
rad<-rep(0,nx)
for (i in 1:nx)
rad[i]<-radius(X[i,],Y)$rad
Xlim<-range(X[,1]-rad,X[,1]+rad,Y[,1])
Ylim<-range(X[,2]-rad,X[,2]+rad,Y[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(rbind(Y),asp=1,pch=16,col=2,xlab="",ylab="",axes=TRUE,
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
points(rbind(X))
interp::circles(X[,1],X[,2],rad,lty=1,lwd=1,col=4)
dat.fr<-data.frame(a=Y)
radii(A,dat.fr)
# }
Run the code above in your browser using DataLab