randomPoints: Distanced random points

Description Usage Arguments Value Author(s) See Also Examples

View source: R/randomPoints.R

Description

Arranges points in square randomly, but with certain minimal distance to each other

Usage

1
randomPoints(xmin, xmax, ymin, ymax, number, mindist, plot = TRUE, ...)

Arguments

xmin

Minimum x coordinate

xmax

Upper limit x values

ymin

Ditto for y

ymax

And yet again: Ditto.

number

How many points should be randomly + uniformly distributed

mindist

Minimum DIstance each point should have to others

plot

Plot the result? DEFAULT: TRUE

...

Further arguments passed to plot

Value

data.frame with x and y coordinates.

Author(s)

Berry Boessenkool, [email protected], 2011/2012

See Also

distance, the package RandomFields ( https://cran.r-project.org/package=RandomFields)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
P <- randomPoints(xmin=200,xmax=700, ymin=300,ymax=680, number=60,mindist=10, asp=1)
rect(xleft=200, ybottom=300, xright=700, ytop=680, col=NA, border=1)

format( round(P,4), trim=FALSE)

for(i in 1:10)
{
rp <- randomPoints(xmin=0,xmax=20, ymin=0,ymax=20, number=20, mindist=3, plot=FALSE)
plot(rp, las=1, asp=1, pch=16)
abline(h=0:30*2, v=0:30*2, col=8); box()
for(i in 1:nrow(rp))
    berryFunctions::circle(rp$x[i],rp$y[i], r=3, col=rgb(1,0,0,alpha=0.2), border=NA)
}

brry/OSMscale documentation built on April 18, 2018, 8:23 p.m.