Ellipse2D is an R6::R6Class() object representing one or more
two-dimensional ellipses. It inherits from Coord2D so its center(s)
can be used with $x / $y / $xyw etc. The semi-axes rx/ry
and orientation angle theta are updated automatically by each
transformation method.
Details
When rx == ry (within floating-point tolerance) the ellipse is a
circle, which can be tested with the $is_circle active binding.
Super class
Coord2D -> Ellipse2D
Active bindings
rxNumeric vector of x-axis semi-radii (in the ellipse local frame).
ryNumeric vector of y-axis semi-radii (in the ellipse local frame).
thetaAn
angle()vector of rotation angles of the ellipse x-axis relative to the global x-axis.is_circleLogical vector;
TRUEfor each ellipse whererx == rywithin floating-point tolerance.
Methods
Ellipse2D$new()
Usage
Ellipse2D$new(xyw, rx, ry, theta)Arguments
xywA matrix with three columns for homogeneous center coordinates (
"x","y","w").rxNumeric vector of x-axis semi-radii.
ryNumeric vector of y-axis semi-radii.
thetaAn
angle()vector (or numeric, interpreted using the default angular unit) of rotation angles.
Ellipse2D$print()
Arguments
nNumber of ellipses to print. If
NULLprint all....Passed to
format.default().
Ellipse2D$transform()
Usage
Ellipse2D$transform(mat = transform2d())Arguments
matA 3x3 matrix representing a post-multiplied affine transformation matrix. The last column must be equal to
c(0, 0, 1). If the last row isc(0, 0, 1)you may need to transpose it to convert it from a pre-multiplied affine transformation matrix to a post-multiplied one. If a 2x2 matrix (such as a 2x2 post-multiplied 2D rotation matrix) we'll quietly add a final column/row equal toc(0, 0, 1).
Examples
# An ellipse
e <- as_ellipse2d(as_coord2d(0, 0), rx = 2, ry = 1, theta = degrees(45))
print(e)
#> <Ellipse2D[1] (theta in degrees)>
#> x y rx ry theta
#> 0 0 2 1 45
e$is_circle
#> [1] FALSE
# A circle (special case)
c1 <- as_ellipse2d(as_coord2d(0.5, 0.5), rx = 0.5)
print(c1)
#> <Ellipse2D[1] (theta in degrees)>
#> x y rx ry theta
#> 0.5 0.5 0.5 0.5 0
c1$is_circle
#> [1] TRUE
