Function Repository Resource:

CurveTube

Source Notebook

Convert a 3D curve into a parametrized tube

Contributed by: Wolfram Staff (original content by Alfred Gray)

ResourceFunction["CurveTube"][c,t,r,θ]

gives the parametrized circular tube with radius r and cross sectional angle θ centered on the curve c with parameter t.

ResourceFunction["CurveTube"][c1,c2,t,r,θ]

gives the parametrized tube whose cross section is similar to c2 with effective radius r and cross sectional angle θ centered on the curve c1 with parameter t.

Details and Options

The parametrization has the form , where and are the normal and the binormal vectors of c1, respectively.
The first curve must be 3D and the second must be 2D.
ResourceFunction["CurveTube"] has the same options as ParametricPlot3D.

Examples

Basic Examples (3) 

Compute the parametrization for a helical tube:

In[1]:=
ResourceFunction["CurveTube"][
 Entity["SpaceCurve", "Helix"][
    EntityProperty["SpaceCurve", "ParametricEquations"]][a, b][
  t], t, r, \[Theta]]
Out[1]=

Plot the tube:

In[2]:=
ParametricPlot3D[
 Evaluate[
  ResourceFunction["CurveTube"][
   Entity["SpaceCurve", "Helix"][
      EntityProperty["SpaceCurve", "ParametricEquations"]][2., .5][t],
    t, .5, \[Theta]]], {t, 0, 4 \[Pi]}, {\[Theta], 0, 2 \[Pi]}]
Out[2]=

Make a tube from a torus knot curve:

In[3]:=
torusknot[a_, b_, c_][p_, q_][
  t_] := {(a + b Cos[q t]) Cos[p t], (a + b Cos[q t]) Sin[p t], c Sin[q t]}
In[4]:=
ParametricPlot3D[
 Evaluate[
  ResourceFunction["CurveTube"][torusknot[8, 3, 5][2, 5][t], t, 1, \[Theta]]], {t, 0, 2 \[Pi]}, {\[Theta], 0, 2 \[Pi]}, PlotPoints -> 60]
Out[4]=

Make a helix tube using a variant of a nephroid as a cross section:

In[5]:=
nephroid[a_][t_] := {a (4 Cos[t] - Cos[4 t]), a (4 Sin[t] - Sin[4 t])}
In[6]:=
ParametricPlot[Evaluate[nephroid[1][t]], {t, 0, 2 \[Pi]}]
Out[6]=
In[7]:=
ct = ResourceFunction["CurveTube"][
   Entity["SpaceCurve", "Helix"][
      EntityProperty["SpaceCurve", "ParametricEquations"]][1, 1/2][t],
    nephroid[1][t], t, r, \[Theta]] // Chop
Out[7]=
In[8]:=
ParametricPlot3D[
 Evaluate[ct /. r -> .15], {t, -2 \[Pi], 2 \[Pi]}, {\[Theta], 0, 2 \[Pi]}, Mesh -> False, PlotRange -> All]
Out[8]=

Properties and Relations (2) 

Take the normal and binormal vectors from the Frenet-Serret system for a helix:

In[9]:=
fss = FullSimplify[
  PowerExpand[
   Rest[FrenetSerretSystem[
      Entity["SpaceCurve", "Helix"][
         EntityProperty["SpaceCurve", "ParametricEquations"]][a, b][
       t], t][[2]]]]]
Out[9]=

The parametrization for the curve tube for a helix is:

In[10]:=
Entity["SpaceCurve", "Helix"][
     EntityProperty["SpaceCurve", "ParametricEquations"]][a, b][t] + r (-Cos[\[Theta]] fss[[1]] + Sin[\[Theta]] fss[[2]]) // FullSimplify
Out[10]=

This is the same as given by CurveTube:

In[11]:=
ResourceFunction["CurveTube"][
 Entity["SpaceCurve", "Helix"][
    EntityProperty["SpaceCurve", "ParametricEquations"]][a, b][
  t], t, r, \[Theta]]
Out[11]=

Something similar can be done with Tube:

In[12]:=
Graphics3D[
 Tube[BSplineCurve[
   Table[Entity["SpaceCurve", "Helix"][
       EntityProperty["SpaceCurve", "ParametricEquations"]][2., .5][
     t], {t, 0, 4 \[Pi], 4 \[Pi]/20}]], .25]]
Out[12]=

Publisher

Enrique Zeleny

Version History

  • 1.0.0 – 21 July 2020

Source Metadata

Related Resources

License Information