dist.point2set: Distance from a point to a set of finite cardinality

View source: R/AuxGeometry.R

dist.point2setR Documentation

Distance from a point to a set of finite cardinality

Description

Returns the Euclidean distance between a point p and set of points Yp and the closest point in set Yp to p. Distance between a point and a set is by definition the distance from the point to the closest point in the set. p should be of finite dimension and Yp should be of finite cardinality and p and elements of Yp must have the same dimension.

Usage

dist.point2set(p, Yp)

Arguments

p

A vector (i.e., a point in R^d).

Yp

A set of d-dimensional points.

Value

A list with the elements

distance

Distance from point p to set Yp

ind.cl.point

Index of the closest point in set Yp to the point p

closest.point

The closest point in set Yp to the point p

Author(s)

Elvan Ceyhan

See Also

dist.point2line and dist.point2plane

Examples

## Not run: 
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
dist.point2set(c(1,2),Te)

X2<-cbind(runif(10),runif(10))
dist.point2set(c(1,2),X2)

x<-runif(1)
y<-as.matrix(runif(10))
dist.point2set(x,y)
#this works, because x is a 1D point, and y is treated as a set of 10 1D points
#but will give an error message if y<-runif(10) is used above

## End(Not run)


elvanceyhan/pcds documentation built on June 29, 2023, 8:12 a.m.