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.

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.

See also

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.6, y:0.289, r2:1>    <x:0.645, y:0.559, r2:2> 
#> [3] <x:0.801, y:0.469, r2:3>  <x:0.941, y:0.338, r2:4> 
#> [5] <x:0.929, y:0.0998, r2:5>
plot(circ)


# integers and numerics are converted automatically
circle(point1, 1:5)
#> <2D circles [5]>
#> [1] <x:0.6, y:0.289, r2:1>    <x:0.645, y:0.559, r2:2> 
#> [3] <x:0.801, y:0.469, r2:3>  <x:0.941, y:0.338, r2:4> 
#> [5] <x:0.929, y:0.0998, r2:5>

# You are free to name the input for readability
circle(center = point1, radius = number)
#> <2D circles [5]>
#> [1] <x:0.6, y:0.289, r2:1>    <x:0.645, y:0.559, r2:2> 
#> [3] <x:0.801, y:0.469, r2:3>  <x:0.941, y:0.338, r2:4> 
#> [5] <x:0.929, y:0.0998, r2:5>

# Construction with 2 points
circle(point1, point2)
#> <2D circles [5]>
#> [1] <x:0.544, y:0.298, r2:0.00312> <x:0.467, y:0.679, r2:0.0462> 
#> [3] <x:0.631, y:0.411, r2:0.0321>  <x:0.953, y:0.231, r2:0.0115> 
#> [5] <x:0.654, y:0.169, r2:0.0804> 

# Construction with 3 points
circle(point1, point2, point3)
#> <2D circles [5]>
#> [1] <x:0.585, y:0.548, r2:0.0675> <x:0.548, y:0.8, r2:0.0672>  
#> [3] <x:0.506, y:0.776, r2:0.181>  <x:0.576, y:0.188, r2:0.155> 
#> [5] <x:0.679, y:0.271, r2:0.0916>

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.796, y:0.0135, z:0.947, r2:1, dx:0.653, dy:0.921, dz:0.382>
#> [2] <x:0.161, y:0.912, z:0.569, r2:2, dx:0.489, dy:0.736, dz:0.192> 
#> [3] <x:0.125, y:0.982, z:0.783, r2:3, dx:0.501, dy:0.479, dz:0.0157>
#> [4] <x:0.9, y:0.756, z:0.731, r2:4, dx:0.227, dy:0.0219, dz:0.0796> 
#> [5] <x:0.986, y:0.419, z:0.433, r2:5, dx:0.122, dy:0.395, dz:0.631> 

# Conversion
as_plane(circ)
#> <3D euclid_planes [5]>
#> [1] <a:-0.135, b:0.129, c:0.242, d:-0.123>     
#> [2] <a:-0.14, b:0.0388, c:-0.14, d:0.0671>     
#> [3] <a:-0.0296, b:0.156, c:-0.117, d:-0.0582>  
#> [4] <a:0.0446, b:0.0273, c:-0.0768, d:-0.00463>
#> [5] <a:0.058, b:0.202, c:0.278, d:-0.262>      

as_sphere(circ)
#> <3D euclid_spheres [5]>
#> [1] <x:1.01, y:0.575, z:0.766, r2:0.393>  <x:0.206, y:0.525, z:0.417, r2:0.175>
#> [3] <x:0.634, y:0.85, z:0.478, r2:0.369>  <x:2.01, y:-1.19, z:0.687, r2:5.02>  
#> [5] <x:0.581, y:0.26, z:0.633, r2:0.229>