Public methods
Method new()
Create a new Ellipse object.
Usage
Ellipse$new(center, rmajor, rminor, alpha, degrees = TRUE)
Arguments
centera point, the center of the rotation
rmajorpositive number, the major radius
rminorpositive number, the minor radius
alphaa number, the angle between the major axis and the
horizontal direction
degreeslogical, whether alpha is given in degrees
Returns
A new Ellipse object.
Examples
Ellipse$new(c(1,1), 3, 2, 30)
Method print()
Show instance of an Ellipse object.
Usage
Ellipse$print(...)
Arguments
...ignored
Method isEqual()
Check whether the reference ellipse equals an ellipse.
Usage
Ellipse$isEqual(ell)
Arguments
ellAn Ellipse object.
Method equation()
The coefficients of the implicit equation of the ellipse.
Usage
Ellipse$equation()
Details
The implicit equation of the ellipse is
Ax<U+00B2> + Bxy + Cy<U+00B2> + Dx + Ey + F = 0. This method returns
A, B, C, D, E and F.
Returns
A named numeric vector.
Method includes()
Check whether a point lies on the reference ellipse.
Usage
Ellipse$includes(M)
Arguments
Ma point
Method contains()
Check whether a point is contained in the reference ellipse.
Usage
Ellipse$contains(M)
Arguments
Ma point
Method matrix()
Returns the 2x2 matrix S associated to the reference
ellipse. The equation of the ellipse is t(M-O) %*% S %*% (M-O) = 1.
Usage
Ellipse$matrix()
Examples
ell <- Ellipse$new(c(1,1), 5, 1, 30)
S <- ell$matrix()
O <- ell$center
pts <- ell$path(4L) # four points on the ellipse
apply(pts, 1L, function(M) t(M-O) %*% S %*% (M-O))
Method path()
Path that forms the reference ellipse.
Usage
Ellipse$path(npoints = 100L)
Arguments
npointsnumber of points of the path
Returns
A matrix with two columns x and y of
length npoints.
Method diameter()
Diameter and conjugate diameter of the reference ellipse.
Usage
Ellipse$diameter(t, conjugate = FALSE)
Arguments
ta number, the diameter only depends on t modulo
pi; the axes correspond to t=0 and t=pi/2
conjugatelogical, whether to return the conjugate diameter as well
Returns
A Line object or a list of two Line objects if
conjugate = TRUE.
Examples
ell <- Ellipse$new(c(1,1), 5, 2, 30)
diameters <- lapply(c(0, pi/3, 2*pi/3), ell$diameter)
plot(NULL, asp = 1, xlim = c(-4,6), ylim = c(-2,4),
xlab = NA, ylab = NA)
draw(ell)
invisible(lapply(diameters, draw))
Method pointFromAngle()
Intersection point of the ellipse with the half-line
starting at the ellipse center and with director angle theta.
Usage
Ellipse$pointFromAngle(theta, degrees = TRUE)
Arguments
thetaa number, the angle, or a numeric vector
degreeslogical, whether theta is given in degrees
Returns
A point of the ellipse if length(theta)==1 or a
two-column matrix of points of the ellipse if
length(theta) > 1 (one point per row).
Method semiMajorAxis()
Semi-major axis of the ellipse.
Usage
Ellipse$semiMajorAxis()
Returns
A segment (Line object).
Method semiMinorAxis()
Semi-minor axis of the ellipse.
Usage
Ellipse$semiMinorAxis()
Returns
A segment (Line object).
Method foci()
Foci of the reference ellipse.
Usage
Ellipse$foci()
Returns
A list with the two foci.
Method tangent()
Tangents of the reference ellipse.
Usage
Ellipse$tangent(t)
Arguments
tan angle, there is one tangent for each value of t
modulo 2*pi; for t = 0, pi/2, pi, -pi/2, these are the
tangents at the vertices of the ellipse
Examples
ell <- Ellipse$new(c(1,1), 5, 2, 30)
tangents <- lapply(c(0, pi/3, 2*pi/3, pi, 4*pi/3, 5*pi/3), ell$tangent)
plot(NULL, asp = 1, xlim = c(-4,6), ylim = c(-2,4),
xlab = NA, ylab = NA)
draw(ell, col = "yellow")
invisible(lapply(tangents, draw, col = "blue"))
Method regressionLines()
Regression lines. The regression line of y on x intersects
the ellipse at its rightmost point and its leftmost point.
The tangents at these points are vertical.
The regression line of x on y intersects the ellipse at its
topmost point and its bottommost point.
The tangents at these points are horizontal.
Usage
Ellipse$regressionLines()
Returns
A list with two Line objects:
the regression line of y on x and the regression line of x on y.
Examples
ell <- Ellipse$new(c(1,1), 5, 2, 30)
reglines <- ell$regressionLines()
plot(NULL, asp = 1, xlim = c(-4,6), ylim = c(-2,4),
xlab = NA, ylab = NA)
draw(ell, lwd = 2)
draw(reglines$YonX, lwd = 2, col = "blue")
draw(reglines$XonY, lwd = 2, col = "green")
Method boundingbox()
Return the smallest rectangle parallel to the axes
which contains the reference ellipse.
Usage
Ellipse$boundingbox()
Returns
A list with two components: the x-limits in x and the
y-limits in y.
Examples
ell <- Ellipse$new(c(2,2), 5, 3, 40)
box <- ell$boundingbox()
plot(NULL, asp = 1, xlim = box$x, ylim = box$y, xlab = NA, ylab = NA)
draw(ell, col = "seaShell", border = "blue")
abline(v = box$x, lty = 2); abline(h = box$y, lty = 2)
Method randomPoints()
Random points on or in the reference ellipse.
Usage
Ellipse$randomPoints(n, where = "in")
Arguments
nan integer, the desired number of points
where"in" to generate inside the ellipse,
"on" to generate on the ellipse
Returns
The generated points in a two columns matrix with n rows.
Examples
ell <- Ellipse$new(c(1,1), 5, 2, 30)
pts <- ell$randomPoints(100)
plot(NULL, type="n", asp=1, xlim = c(-4,6), ylim = c(-2,4),
xlab = NA, ylab = NA)
draw(ell, lwd = 2)
points(pts, pch = 19, col = "blue")
Method clone()
The objects of this class are cloneable with this method.
Usage
Ellipse$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.