Function Repository Resource:

Circle3D

Source Notebook

Represent a circle in 3D

Contributed by: Erik Mahieu

ResourceFunction["Circle3D"][]

represents a circle in 3D of radius 1, centered at the origin and perpendicular to the x-axis.

ResourceFunction["Circle3D"][{ry,rz}]

represents an ellipse in 3D with semiaxes lengths ry and rz, centered at the origin and perpendicular to the x-axis.

ResourceFunction["Circle3D"][{x,y,z},{ry,rz},ψ,ζ]

represents a circle in 3D with semiaxes lengths ry and rz, centered at {x,y,z} and rotated by angles ψ and ζ around 3D vectors parallel to y- and z-axes respectively.

Details and Options

ResourceFunction["Circle3D"] can be used as a 3D graphics primitive and be used in Graphics3D.
ResourceFunction["Circle3D"] takes the Line-primitives generated by the ellipse ParametricPlot3D[{0,aSin[t],bCos[t]},{t,-π,π}], translates and rotates them as specified by the function’s parameters {x,y,z},ψ,ζ.

Examples

Basic Examples (2) 

A unit circle in 3D:

In[1]:=
Graphics3D[{Red, ResourceFunction["Circle3D"][]}]
Out[1]=

An ellipse in 3D:

In[2]:=
Graphics3D[{Blue, ResourceFunction["Circle3D"][{1.75, .75}]}]
Out[2]=

Scope (1) 

We can use a Manipulate to explore all the parameters of the function Circle3D:

In[3]:=
Manipulate[
 Graphics3D[{Red, Thickness[.01], ResourceFunction["Circle3D"][{x, y, z}, {a, b}, \[Psi], \[Zeta]]}, Axes -> True, PlotRange -> 2, ImageSize -> Small],
 {{a, 1.5, "semi-major axis"}, .1, 2, ImageSize -> Tiny},
 {{b, 1, "semi-minor axis"}, .1, 2, ImageSize -> Tiny},
 {{\[Psi], 0, "y-axis rotation"}, -\[Pi], \[Pi], ImageSize -> Tiny},
 {{\[Zeta], 0, "z-axis rotation"}, -\[Pi], \[Pi], ImageSize -> Tiny},
 {{x, 0, Subscript["x", "center"]}, -1, 1, ImageSize -> Tiny}, {{y, 0, Subscript["y", "center"]}, -1, 1, ImageSize -> Tiny}, {{z, 0, Subscript["z", "center"]}, -1, 1, ImageSize -> Tiny}, ControlPlacement -> Left]
Out[3]=

Neat Examples (1) 

The Line primitives generated by Circle3D can be transformed to Tube:

In[4]:=
Graphics3D[{Green, ResourceFunction["Circle3D"][{1, .5, .25}, {1.5, .75}, 30 °, -45 °]} /. Line -> (Tube[#, .075] &), Axes -> True]
Out[4]=

Publisher

Erik Mahieu

Version History

  • 1.0.0 – 14 October 2019

License Information