Learn R Programming

pcds (version 0.1.4)

in.circle: Check whether a point is inside a circle

Description

Checks if the point pt lies in the circle with center cent and radius rad, denoted as C(cent,rad). So, it returns 1 or TRUE if pt is inside the circle, and 0 otherwise.

boundary is a logical argument (default=FALSE) to include boundary or not, so if it is TRUE, the function checks if the point, pt, lies in the closure of the circle (i.e., interior and boundary combined) else it checks if pt lies in the interior of the circle.

Usage

in.circle(pt, cent, rad, boundary = FALSE)

Value

Indicator for the point pt being inside the circle or not, i.e., returns 1 or TRUE

if pt is inside the circle, and 0 otherwise.

Arguments

pt

A 2D point to be checked whether it is inside the circle or not.

cent

A 2D point in Cartesian coordinates which serves as the center of the circle.

rad

A positive real number which serves as the radius of the circle.

boundary

A logical parameter (default=FALSE) to include boundary or not, so if it is TRUE, the function checks if the point, pt, lies in the closure of the circle (i.e., interior and boundary combined) else it checks if pt lies in the interior of the circle.

Author

Elvan Ceyhan

See Also

in.triangle, in.tetrahedron, and on.convex.hull from the interp package for documentation for in.convex.hull

Examples

Run this code
cent<-c(1,1); rad<-1; p<-c(1.4,1.2)
#try also cent<-runif(2); rad<-runif(1); p<-runif(2);

in.circle(p,cent,rad)

p<-c(.4,-.2)
in.circle(p,cent,rad)

p<-c(1,0)
in.circle(p,cent,rad)
in.circle(p,cent,rad,boundary=TRUE)

#for a NA entry point
p<-c(NA,.2)
in.circle(p,cent,rad)

Run the code above in your browser using DataLab