Skip to contents

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

rx

Numeric vector of x-axis semi-radii (in the ellipse local frame).

ry

Numeric vector of y-axis semi-radii (in the ellipse local frame).

theta

An angle() vector of rotation angles of the ellipse x-axis relative to the global x-axis.

is_circle

Logical vector; TRUE for each ellipse where rx == ry within floating-point tolerance.

Methods

Inherited methods


Ellipse2D$new()

Usage

Ellipse2D$new(xyw, rx, ry, theta)

Arguments

xyw

A matrix with three columns for homogeneous center coordinates ("x", "y", "w").

rx

Numeric vector of x-axis semi-radii.

ry

Numeric vector of y-axis semi-radii.

theta

An angle() vector (or numeric, interpreted using the default angular unit) of rotation angles.


Ellipse2D$print()

Usage

Ellipse2D$print(n = NULL, ...)

Arguments

n

Number of ellipses to print. If NULL print all.

...

Passed to format.default().


Ellipse2D$transform()

Usage

Ellipse2D$transform(mat = transform2d())

Arguments

mat

A 3x3 matrix representing a post-multiplied affine transformation matrix. The last column must be equal to c(0, 0, 1). If the last row is c(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 to c(0, 0, 1).


Ellipse2D$clone()

The objects of this class are cloneable with this method.

Usage

Ellipse2D$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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