Skip to Main Content Skip to Search
Product Documentation

plot::Tubegeneralized tubular plots (canal surfaces)

plot::Tube([x(t), y(t), z(t)], r(t), t = t_min..t_max) draws a tube around [x(t), y(t), z(t)] with radius r(t).

→ Examples

Call:

plot::Tube([x, y, z], <r>, t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

Parameters:

x, y, z

the spine curve coordinates: real-valued expressions in t and the animation parameter. 
x, y, z are equivalent to the attributes XFunction, YFunction, ZFunction.

r

the tube radius: a real-valued expression in t and the animation parameter. Default is the constant 1/10
r is equivalent to the attribute RadiusFunction.

t

the curve parameter: an (indexed) identifier.
t is equivalent to the attribute UName.

`t_{min}` .. `t_{max}`

the range of the curve parameter: real-valued expressions in the animation parameter.
`t_{min}` .. `t_{max}` is equivalent to the attributes URange, UMin, UMax.

See Also:

plot, plot::copy, plot::Curve3d, plot::Surface

Details:

Example 1

A torus can be drawn as a tube around a circle:

plot(plot::Tube([cos(t), sin(t), 0], 0.4,
     t = 0..2*PI))

MuPAD graphics

Varying the diameter of the tube, we deform the torus into a cyclide:

plot(plot::Tube([cos(t), sin(t), 0], 0.4 + 0.3*cos(t),
     t = 0..2*PI))

MuPAD graphics

Example 2

All surfaces of revolution are special cases of canal surfaces:

plot(plot::Scene3d(plot::XRotate(sin(u), u = 0..10)),
     plot::Scene3d(plot::ZRotate(sin(u), u = 0..10)),
     plot::Scene3d(plot::Tube([u, 0, 0], sin(u), u = 0..10)),
     plot::Scene3d(plot::Tube([0, 0, sin(u)], u, u = 0..10)),
     Width = 180 * unit::mm)

MuPAD graphics

The last image shows that the defaults for the mesh are not always adequate and should be changed:

plot(plot::Tube([0, 0, sin(u)], u, u = 0..10,
                Mesh = [20, 20]))

MuPAD graphics

Example 3

The famous Klein bottle can be obtained from a “drop silhouette” by using an appropriate radius parametrization:

plot(plot::Tube([6*cos(u)*(sin(u) - 1), 0, 14*sin(u)],
                4 - 2*cos(u), u = -PI..PI))

MuPAD graphics

Example 4

Re-using the cyclide from above, we demonstrate coloring a canal surface:

color := (t, phi) -> RGB::fromHSV([(t+sin(4*phi))*180/PI, 1, 1]):
plot(plot::Tube([sin(t), cos(t), 0], 0.4 + 0.3*cos(t), t=0..2*PI,
                FillColorFunction = color))

MuPAD graphics

Example 5

Yet another variation of the cyclide, we use a non-constant AngleRange to “slice” it:

plot(plot::Tube([sin(t), cos(t), 0], 0.4 - 0.3*sin(t), t=0..2*PI,
                AngleRange = 0 .. 2*PI*sin(abs(t-PI/2)/2)),
     Axes = None, CameraDirection = [14, 1, 5])

MuPAD graphics

Combining more than one tubular plot with identical spine curves but different angle ranges, we can achieve a braid-like effect:

braid := i ->
   plot::Tube([sin(u), cos(u), 0], 0.2, u=0..2*PI,
              AngleRange = i*PI/3 + 3*u .. i*PI/3 + 3*u + 1/2,
              Color = RGB::EmeraldGreen, Mesh = [60, 2]):
torus := plot::Tube([sin(u), cos(u), 0], 0.18, u=0..2*PI,
                    Color = RGB::BlueLight,
                    Name = "Torus"):
plot(braid(i) $ i = 0..5,
     torus,
     ULinesVisible = FALSE, VLinesVisible = FALSE,
     FillColorType = Flat,
     Axes = None, CameraDirection = [0, 7, 10])

 

MuPAD graphics

Example 6

The spine curve, the radius function, color functions etc. can be animated as usual:

plot(plot::Tube([sin(t)*sin(a), cos(t)*cos(a), sin(a)],
                0.4 - 0.3*sin(t-a),
                t = 0..2*PI, a = 0..2*PI,
                Frames = 20, TimeRange = 0..5))

MuPAD graphicsimage

Example 7

Note that in the presence of a sharp bend (in relation to the tube diameter), the surface plotted my plot::Tube may self-intersect:

plot(plot::Tube([x, 0, x^2], 1.2, x = -1.4..1.4,
                Mesh = [20, 10]),
     Axes = None, CameraDirection = [-3, 1, 2])

MuPAD graphics

This effect is unavoidable. Sharp bends also cause another effect which can be avoided by increasing the mesh density: The tube might not follow the curve quickly enough:

plot(plot::Tube([sin(x^2), x, 0], x = -5..0))

MuPAD graphics

In this situation, you can set USubmesh to a positive value to request additional function evaluations:

plot(plot::Tube([sin(x^2), x, 0], x = -5..0, USubmesh = 5))

MuPAD graphics

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS