Using the Tube function to create a torus from an equation for the curve

I've been searching for an answer for this for a while now, but I can't find anything that deals with using the Tube function to generate a torus from the equation of the torus.

The equation of my torus is z^2==1 - (Sqrt[x^2 + y^2] - 3 I want to use Tube and Graphics3D to show this torus. I would have thought that

Tube[z^2==1 - (Sqrt[x^2 + y^2] - 3, 1]


the second argument being the radius of the tube, would suffice, but I when I evaluate this in Graphics3D:

 Graphics3D[Tube[z^2 == 1 - (Sqrt[x^2 + y^2] - 3)^2, 1]]


I get the following error:

Coordinate False should be a triple of numbers, or a Scaled form.

Why? What am I doing incorrectly here? Thanks!

• Appropriate username! Apr 25, 2022 at 0:15

Here is the torus using Graphics3D and Tube:

Graphics3D[Tube[Table[3 {Cos[p], Sin[p], 0}, {p, 0, 2 Pi, Pi/30}], 1],
Axes -> True]


• Ah, the need to parametrise was what I was missing. Many thanks! Jan 3, 2021 at 15:18
Graphics3D[
Tube[
BSplineCurve[
{{-3/2, 0, 1/2}, {-3/2, -3/2, 1/2}, {0, -3/2, 1/2},
{3/2, -3/2, 1/2}, {3/2, 0, 1/2}, {3/2, 3/2, 1/2},
{0, 3/2, 1/2}, {-3/2, 3/2, 1/2}, {-3/2, 0, 1/2}},
SplineDegree -> 2,
SplineWeights -> {1, 1/Sqrt[2], 1, 1/Sqrt[2], 1, 1/Sqrt[2], 1,  1/Sqrt[2], 1},
SplineKnots -> {0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4}],
1/2]
]


Adapted from an example in the docs for Tube:

PieChart3D[{1}, ChartElementFunction -> "TorusSector3D",
SectorOrigin -> {Automatic, 1}, BoxRatios -> Automatic]

• For those interested, there is a BSplineSurface-based torus on site in this answer by @J.M.. Jan 4, 2021 at 0:20

You can also use Tube as a styling directive with ParametricPlot3D:

ParametricPlot3D[3 {Cos[p], Sin[p], 0}, {p, 0, 2 Pi},
PlotStyle -> Tube[1], PlotRangePadding -> Scaled[.15]]


ImplicitRegion[
z^2 == 1 - (Sqrt[x^2 + y^2] - 3)^2, {x, y, z}] // Region

ContourPlot3D[
z^2 == 1 - (Sqrt[x^2 + y^2] - 3)^2, {x, -4, 4}, {y, -4, 4}, {z, -4,
4}, Boxed -> False, Axes -> False]

• Thank you! This is a much easier way to do it. My question relates to an exercise in my Mathematica course whereby I have to use Graphics3D and Tube in conjunction to achieve the required shape. Any ideas on this? Thanks Jan 3, 2021 at 14:50