{{Short description|Family of geometric shapes}} {{One source|date=January 2022}} [[File:Supertorus_table.png|thumb|400px|right|Supertoroids with {{math|1=''a'' = ''b'' = 2}}, and different combinations for the parameters {{mvar|s}} and {{mvar|t}}.]]
In [[geometry]] and [[computer graphics]], a '''supertoroid''' or '''supertorus''' is usually understood to be a family of [[doughnut]]-like [[surface (geometry)|surfaces]] (technically, a [[topology|topological]] [[torus (mathematics)|torus]]) whose shape is defined by mathematical formulas similar to those that define the [[superellipsoid]]s. The plural of "supertorus" is either '''supertori''' or '''supertoruses'''.
The family was described and named by [[Alan H.Barr|Alan Barr]] in 1994.<ref name=barr>Alan H. Barr (1981) ''Superquadrics and Angle-Preserving Transformations''. IEEE Computer Graphics and Applications, volume 1 issue 1. pp. 11-23.</ref>
Barr's supertoroids have been fairly popular in computer graphics as a convenient model for many objects, such as smooth frames for rectangular things. One quarter of a supertoroid can provide a smooth and seamless 90-degree joint between two superquadric [[cylinder (geometry)|cylinder]]s. However, they are not [[algebraic surface]]s (except in special cases).
==Formulas== Alan Barr's supertoroids are defined by parametric equations similar to the [[trigonometry|trigonometric]] equations of the torus, except that the [[sine]] and [[cosine]] terms are raised to arbitrary [[exponentiation|powers]]. Namely, the generic point {{math|''P''(''u'', ''v'')}} of the surface is given by <math display=block> P(u,v) = \left(\begin{array}{c} X(u,v)\\ Y(u,v)\\ Z(u,v) \end{array}\right) = \left(\begin{array}{c} (a + C_{u}^{s}) C_{v}^{t}\\ (b + C_{u}^{s}) S_{v}^{t}\\ S_{u}^{s} \end{array}\right) </math> where <math display=block>\begin{align} C_\theta^\varepsilon &= \operatorname{sgn}(\cos \theta) \, \left| \, \cos\theta \, \right|^\varepsilon, \\ S_\theta^\varepsilon &= \operatorname{sgn}(\sin \theta) \ \left| \, \sin\theta \ \right|^\varepsilon, \end{align}</math> {{math|sgn}} is the [[sign function]], and the parameters {{mvar|u, v}} range from 0 to 360 degrees (0 to 2''π'' [[radian]]s).
In these formulas, the parameter {{math|''s'' > 0}} controls the "squareness" of the vertical sections, {{math|''t'' > 0}} controls the squareness of the horizontal sections, and {{math|''a'', ''b'' ≥ 1}} are the major radii in the {{mvar|x}} and {{mvar|y}} directions. With {{math|1=''s'' = ''t'' = 1}} and {{math|1=''a'' = ''b'' = ''R''}} one obtains the ordinary torus with major radius {{mvar|R}} and minor radius 1, with the center at the origin and [[symmetry|rotational symmetry]] about the {{mvar|z}}-axis.
In general, the supertorus defined as above spans the [[interval (mathematics)|intervals]]: <math display=block>\begin{array}{rcccl} -(a+1) &\leq& x &\leq& +(a+1) \\[4pt] -(b+1) &\leq& y &\leq& +(b+1) \\[4pt] -1 &\leq& z &\leq& +1 \end{array}</math> The whole shape is symmetric about the planes {{math|1=''x'' = 0}}, {{math|1=''y'' = 0}}, and {{math|1=''z'' = 0}}. The hole runs in the {{mvar|z}} direction and spans the intervals <math display=block>\begin{array}{rcccl} -(a-1) &\leq& x &\leq& +(a-1) \\[4pt] -(b-1) &\leq& y &\leq& +(b-1) \\[4pt] -\infty &\leq& z &\leq& +\infty \end{array}</math>
A curve of constant {{mvar|u}} on this surface is a horizontal [[Lamé curve]] with exponent {{tmath|\tfrac 2 t,}} scaled in {{mvar|x}} and {{mvar|y}} and displaced in {{mvar|z}}. A curve of constant {{mvar|v}}, projected on the plane {{math|1=''x'' = 0}} or {{math|1=''y'' = 0}}, is a Lamé curve with exponent {{tmath|\tfrac 2 s,}} scaled and horizontally shifted. If {{math|1=''v'' = 0}}, the curve is planar and spans the intervals: <math display=block>\begin{array}{rcccl} a-1 &\leq& x &\leq& a+1 \\[4pt] -1 &\leq& z &\leq& +1 \end{array}</math> and similarly if {{math|1=''v'' = 90°, 180°, 270°}}. The curve is also planar if {{math|1=''a'' = ''b''}}.
In general, if {{math|''a'' ≠ ''b''}} and {{mvar|v}} is not a multiple of 90 degrees, the curve of constant {{mvar|v}} will not be planar; and, conversely, a vertical plane section of the supertorus will not be a Lamé curve.
The basic supertoroid shape defined above is often modified by non-uniform scaling to yield supertoroids of specific width, length, and vertical thickness.
==Plotting code==
The following [[GNU Octave]] code generates plots of a supertorus:
<syntaxhighlight lang="matlab"> function supertoroid(epsilon,a) n=50; d=.1; etamax=pi; etamin=-pi; wmax=pi; wmin=-pi; deta=(etamax-etamin)/n; dw=(wmax-wmin)/n; k=0; l=0; for i=1:n+1 eta(i)=etamin+(i-1)*deta; for j=1:n+1 w(j)=wmin+(j-1)*dw; x(i,j)=a(1)*(a(4)+sign(cos(eta(i)))*abs(cos(eta(i)))^epsilon(1))*sign(cos(w(j)))*abs(cos(w(j)))^epsilon(2); y(i,j)=a(2)*(a(4)+sign(cos(eta(i)))*abs(cos(eta(i)))^epsilon(1))*sign(sin(w(j)))*abs(sin(w(j)))^epsilon(2); z(i,j)=a(3)*sign(sin(eta(i)))*abs(sin(eta(i)))^epsilon(1); endfor; endfor; mesh(x,y,z); endfunction; </syntaxhighlight>
==See also== * [[Superellipsoid]] * [[Superegg]] * [[Superquadric]]
==References== {{Reflist}}
[[Category:Surfaces]] [[Category:Computer graphics]]