5

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!

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
TubularHell
  • 373
  • 2
  • 6

4 Answers4

6
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]
 ]

enter image description here

Adapted from an example in the docs for Tube:

PieChart3D[{1}, ChartElementFunction -> "TorusSector3D", 
 SectorOrigin -> {Automatic, 1}, BoxRatios -> Automatic]
Michael E2
  • 235,386
  • 17
  • 334
  • 747
5

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]

torus

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
3

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]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
2
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]
cvgmt
  • 72,231
  • 4
  • 75
  • 133
  • 1
    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 – TubularHell Jan 03 '21 at 14:50