Generate points from a ellipse

Share:

Description

calculateEllipse generates points from a ellipse with many options, equally spaced, randomly spaced, with noise added to the radius or limited to a segment of angle alpha.

Usage

1
2
calculateEllipse(x, y, a, b, angle = 0, steps = 50, sector = c(0, 360), 
randomDist = FALSE, randomFun = runif, noiseFun = NA, ...)

Arguments

x

center point x

y

center point y

a

axis a

b

axis b

angle

tilt angle

steps

number of points

sector

limited circular sector

randomDist

logical, TRUE = randomly spaced

randomFun

random function for the position of the points in the ellipse

noiseFun

random function for the noise

...

optional parameters to pass to randomFun

Value

points

array n x 2 of point coordinates.

Author(s)

Jose Gama

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# 50 points from an ellipse at c(0,0) with axis (200, 100), angle 45 degrees
a<-calculateEllipse(0,0,200,100,45,50)
plot(a[,1],a[,2],xlim=c(-250,250),ylim=c(-250,250))
par(new=T)
# 10 points from an ellipse at c(0,0) with axis (200, 100), angle 45 degrees,
#points between 0 and 180 # degrees, normal random distribution
b<-calculateEllipse(0,0,200,100,45,10,c(0,90))
plot(b[,1],b[,2],xlim=c(-250,250),ylim=c(-250,250),col='red')
par(new=T)
# 50 points from an ellipse at c(0,0) with axis (200, 100), angle 45 degrees
a<-calculateEllipse(0,0,200,100,45,50, randomDist=TRUE,noiseFun=function(x) 
(x+rnorm(1,mean=0,sd=10)))
plot(a[,1],a[,2],xlim=c(-250,250),ylim=c(-250,250),col='cyan')

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.