Using plot::tube function in MuPAD, I can generate tubes with varying spine but the cross-section is always a circle, although the radius can vary along the spine. For instance:
plot::Tube([cos(t), sin(t), 0], 0.4 + 0.3*sin(t)*cos(t),t = -0.5*PI..0.5*PI,Mesh=[60,12]):
I want to plot tubes with (non-circular) elliptical cross-sections. Is there a way to achieve this in MuPAD?
P.S. I can generate tubes with arbitrary cross-sections using MATLAV, so please avoid including answers that use pure MATLAB commands.
As for your first question whether this can be done with
plot::Tube: I don't think so. Consider the help of this function (emphasis mine):The fact that a tube is defined as an envelope of a collection of spheres suggests that their cross-section is inherently circular.
I'm not familiar with MuPAD, so I don't know the elegant solution to your problem. For your simple example of a semi-circular base line I could put together this kludgy solution using the low-level
plot::Surface, manually constructing the surface:Here
tstands for the angular parameter along the semi-circular base line (toroidal direction), anduis the angle along the cross-section (poloidal direction). A given cross-section at angletlooks like this:I.e. the semimajor axes are
(0.2+0.1*sin(2*t))and(0.2+0.1*cos(2*t))along the cross-section of the tube.You can see that I used a rotation matrix around the
zaxis to construct the surface. This made heavy use of the fact that the base line is a semi-circle. However, in general cases it should be possible to compute the derivative of your parameterized base line (with respect tot), and compute the necessary rotation angle (with parametert) from that.