Learn R Programming

conicfit (version 1.0.4)

calculateEllipse: Generate points from a ellipse

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

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.

Examples

Run this code
## 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)

Run the code above in your browser using DataLab