minimizeoverlap: Define a function that iteratively shift values in a vector...

Description Usage Arguments Examples

Description

Define a function that iteratively shift values in a vector avoid overlap

Usage

1
2
minimizeoverlap(x, maxiterations = 100, radius = 0.5, shift = 0.1,
  minval = -Inf, maxval = Inf)

Arguments

x

vector of values to be spaced out

maxiterations

the maximum number of iterations to try

radius

how big a a radius of repulsion should we give to each value

shift

what is the maximum amount we should shift the value

minval

what is the minimum allowed value after shifting

maxval

what is the maximum allowed value after shifting

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
minval = 0 - 0.5
maxval = 20 + 0.5
plot(1,type='n',ann=F,xaxt='n',yaxt='n',xlim=c(0,40),ylim=c(0,20),xaxs='i',yaxs='i')

# pick vals between 1 and 100
x = runif(10,0,20)
y = minimizeoverlap(x,maxiterations=100,radius=.5,shift=0.1,minval=minval,maxval=maxval)

for (i in 1:length(x))
{
  plotCircle(1,x[i],.5)
  plotCircle(2,y[i],.5)
}

PhanstielLab/Sushi2 documentation built on May 16, 2019, 4:03 a.m.