drawEllipse: Function to Draw Ellipses

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

This function will draw an ellipse on a plot that already exists.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
drawEllipse(
  a,
  b,
  k = 0,
  Xc = 0,
  Yc = 0,
  deg = T,
  lngth = 100,
  draw = T,
  ret = F,
  ...
)

Arguments

a

the length of the x-axis vertice of the ellipse.

b

the length of the y-axis vertice of the ellipse.

k

the angle between the x-axis in the major vertice for the ellipse.

Xc

the center on the x-axis for the ellipse.

Yc

the center on the y-axis for the ellipse.

deg

if TRUE, assumes k is in degrees; otherwise, k is assumed to be in radians.

lngth

the number of points to use when plotting the ellipse.

draw

if TRUE, draws a polygon in the shape of the ellipse on an existing plot.

ret

if TRUE, returns a matrix with the x and y values for the ellipse.

...

additional parameters for the polygon function.

Value

If ret is set to TRUE, returns the x and y-axis values that were passed into the polygon function.

Examples

1
2
3
4
plot( c(-1,1), c(-1,1), type='n', xlab='X-axis', ylab='Y-axis' )
drawEllipse( .2, .2 )
ex = drawEllipse( .5, .2, Xc = -.5, Yc = .5, k = 20, ret = T, col = 'green')
drawEllipse( .05, .3, Xc = .5, Yc = -.5, k = 290, col = 'red')

rettopnivek/utilityf documentation built on March 1, 2021, 7:05 p.m.