A circle is defined by a center and a radius (given as the squared radius due to the inexactness of square roots). In 3 dimensions a circle is a disc and thus have an orientation given by an orthogonal direction. If the radius is 0 the circle is considered degenerate.

## Usage

circle(..., default_dim = 2)

is_circle(x)

as_circle(x)

## Arguments

...

Various input. See the Constructor section.

default_dim

The dimensionality when constructing an empty vector

x

A circle vector or an object to convert to it

## Value

An euclid_circle vector

## Constructors

2 dimensional circles

• Providing one point and one numeric vector will construct circles centered at the point with the squared radius given by the numeric.

• Providing two points will construct circles centered between the two points with a radius of half the distance between the two points.

• Providing three point vectors will construct the unique circle that pass through the three points.

3 dimensional circles

• Providing three point vectors will construct the unique circle that pass through the three points.

• Providing a point, a numeric, and a plane will construct a circle centered on the point with the squared radius given by the numeric and the orientation given by the plane. The point must lie on the plane

• Providing a point, a numeric, and a vector will construct a circle centered on the point with the squared radius given by the numeric and the orientation orthogonal to the vector

• Providing a point, a numeric, and a direction will construct a circle centered on the point with the squared radius given by the numeric and the orientation orthogonal to the direction

• Providing two spheres will construct a circle given by the intersection of the two spheres. The spheres must intersect

• Providing a sphere and a plane will construct a circle given by the intersection of the sphere and the plane. The sphere and plane must intersect.

Other Geometries: direction(), iso_cube(), iso_rect(), line(), plane(), point(), ray(), segment(), sphere(), tetrahedron(), triangle(), vec(), weighted_point()

Other Surfaces: iso_rect(), plane(), triangle()

## Examples

## 2 Dimensions

point1 <- point(runif(5), runif(5))
point2 <- point(runif(5), runif(5))
point3 <- point(runif(5), runif(5))
number <- exact_numeric(1:5)

# Construction with center and radius
circ <- circle(point1, number)
circ
#> <2D circles [5]>
#> [1] <x:0.857, y:0.547, r2:1>  <x:0.402, y:0.0434, r2:2>
#> [3] <x:0.653, y:0.376, r2:3>  <x:0.0793, y:0.601, r2:4>
#> [5] <x:0.123, y:0.624, r2:5>
plot(circ)

# integers and numerics are converted automatically
circle(point1, 1:5)
#> <2D circles [5]>
#> [1] <x:0.857, y:0.547, r2:1>  <x:0.402, y:0.0434, r2:2>
#> [3] <x:0.653, y:0.376, r2:3>  <x:0.0793, y:0.601, r2:4>
#> [5] <x:0.123, y:0.624, r2:5>

# You are free to name the input for readability
circle(center = point1, radius = number)
#> <2D circles [5]>
#> [1] <x:0.857, y:0.547, r2:1>  <x:0.402, y:0.0434, r2:2>
#> [3] <x:0.653, y:0.376, r2:3>  <x:0.0793, y:0.601, r2:4>
#> [5] <x:0.123, y:0.624, r2:5>

# Construction with 2 points
circle(point1, point2)
#> <2D circles [5]>
#> [1] <x:0.918, y:0.763, r2:0.0503> <x:0.576, y:0.184, r2:0.0502>
#> [3] <x:0.53, y:0.642, r2:0.0856>  <x:0.502, y:0.623, r2:0.18>
#> [5] <x:0.224, y:0.529, r2:0.0193>

# Construction with 3 points
circle(point1, point2, point3)
#> <2D circles [5]>
#> [1] <x:0.911, y:0.765, r2:0.0503> <x:0.968, y:-0.301, r2:0.44>
#> [3] <x:0.416, y:0.589, r2:0.102>  <x:0.526, y:0.186, r2:0.371>
#> [5] <x:0.395, y:0.711, r2:0.0818>

plot(circle(point1[1], point1[2], point1[3]))
euclid_plot(point1[1:3], col = "firebrick", pch = 16, cex = 3)

## 3 Dimensions

point1 <- point(runif(5), runif(5), runif(5))
point2 <- point(runif(5), runif(5), runif(5))
point3 <- point(runif(5), runif(5), runif(5))

circ <- circle(point1, point2, point3)

circle(point1, number, as_vec(point2))
#> <3D circles [5]>
#> [1] <x:0.366, y:0.483, z:0.313, r2:1, dx:0.391, dy:0.441, dz:0.0111>
#> [2] <x:0.0281, y:0.116, z:0.169, r2:2, dx:0.258, dy:0.222, dz:0.0182>
#> [3] <x:0.197, y:0.0474, z:0.804, r2:3, dx:0.804, dy:0.0951, dz:0.25>
#> [4] <x:0.0307, y:0.98, z:0.942, r2:4, dx:0.955, dy:0.916, dz:0.162>
#> [5] <x:0.267, y:0.554, z:0.813, r2:5, dx:0.478, dy:0.164, dz:0.124>

# Conversion
as_plane(circ)
#> <3D euclid_planes [5]>
#> [1] <a:0.0152, b:0.0849, c:-0.0104, d:-0.0433>
#> [2] <a:0.0757, b:-0.268, c:-0.0732, d:0.0413>
#> [3] <a:0.414, b:-0.0529, c:0.449, d:-0.44>
#> [4] <a:-0.0205, b:-0.073, c:-0.0184, d:0.0895>
#> [5] <a:-0.0147, b:0.0797, c:-0.0496, d:0.000142>

as_sphere(circ)
#> <3D euclid_spheres [5]>
#> [1] <x:0.227, y:0.487, z:0.146, r2:0.0472>
#> [2] <x:0.426, y:0.137, z:0.503, r2:0.27>
#> [3] <x:0.505, y:0.379, z:0.559, r2:0.265>
#> [4] <x:0.433, y:0.983, z:0.479, r2:0.377>
#> [5] <x:0.971, y:0.525, z:0.559, r2:0.562>