Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Display a dashed tube in 3D graphics
ResourceFunction["DashedTube"][{{x1,y1,z1},{x2,y2,z2},…}] represents a 3D dashed tube around the line joining a sequence of points. | |
ResourceFunction["DashedTube"][{pt1,pt2,…},r] represents a dashed tube of radius r. | |
ResourceFunction["DashedTube"][{pt1,pt2,…},r,dash] specifies a dashing dash of a tube. | |
ResourceFunction["DashedTube"][{pt1,pt2,…},{r1,r2,…}] specifies a different tube radius at the position of each of the points pti. | |
ResourceFunction["DashedTube"][{{pt11,pt12,…},{pt21,…},…},…] represents a collection of dashed tubes. | |
ResourceFunction["DashedTube"][curve,…] represents a dashed tube around the specified 3D curve. |
| Line[…] | piecewise line segments |
| BezierCurve[…] | composite Bezier curve |
| BSplineCurve[…] | B-spline curve |
| VertexColors | Automatic | vertex colors to be interpolated |
| "Each" | False | whether to apply styling to each dashed segment separately |
| PlotPoints | 30 | initial number of sampling points of the input curve |
| MaxIterations | 20 | maximum number of subdivisions during the sampling |
Create a simple dashed tube:
| In[1]:= |
| Out[1]= | ![]() |
A dashed tube along a curve:
| In[2]:= |
| Out[2]= | ![]() |
A dashed tube with radius 0.1:
| In[3]:= |
| Out[3]= | ![]() |
A dashed tube with dashing {0.2,0.05}:
| In[4]:= |
| Out[4]= | ![]() |
Add an Arrow:
| In[5]:= |
| Out[5]= | ![]() |
Differently styled dashed tubes:
| In[6]:= |
| In[7]:= |
| Out[7]= | ![]() |
Gradient coloring:
| In[8]:= |
| In[9]:= |
| Out[9]= | ![]() |
Gradient coloring for each segment independently:
| In[10]:= |
| In[11]:= | ![]() |
| Out[11]= | ![]() |
Single dashed tube segment:
| In[12]:= |
| Out[12]= | ![]() |
Multiple connected dashed tube segments:
| In[13]:= |
| Out[13]= | ![]() |
DashedTube can take a line or curve argument:
| In[14]:= | ![]() |
| Out[14]= | ![]() |
Multiple disconnected dashed tube segments:
| In[15]:= |
| In[16]:= | ![]() |
| Out[16]= | ![]() |
Use standard coordinates:
| In[17]:= | ![]() |
| Out[17]= | ![]() |
Use Scaled coordinates:
| In[18]:= | ![]() |
| Out[18]= | ![]() |
Dashed tubes with different radii:
| In[19]:= |
| In[20]:= |
| Out[20]= | ![]() |
Radii can also be specified at vertices:
| In[21]:= | ![]() |
| Out[21]= | ![]() |
Dashed tubes with scaled radii:
| In[22]:= |
| In[23]:= |
| Out[23]= | ![]() |
Use uniform dashing specified by 0.1:
| In[24]:= |
| Out[24]= | ![]() |
Use non-uniform dashing {0.25,0.1}:
| In[25]:= |
| Out[25]= | ![]() |
Use more complicated dashing {0.25,0.1,0.05}:
| In[26]:= |
| Out[26]= | ![]() |
Dashing can also be specified outside DashedTube using Dashed, Dotted, DotDashed, Dashing, and AbsoluteDashing primitives:
| In[27]:= | ![]() |
| Out[27]= | ![]() |
AbsoluteDashing[s] is internally automatically replaced with s:
| In[28]:= | ![]() |
| Out[28]= | ![]() |
When both the external modifier such as Dashed and the explicit dashing specification inside DashedTube is used, the latter gets precedence:
| In[29]:= | ![]() |
| Out[29]= | ![]() |
Colored dashed tubes:
| In[30]:= |
| In[31]:= |
| Out[31]= | ![]() |
Different properties can be specified for the front and back faces using FaceForm:
| In[32]:= | ![]() |
| Out[32]= | ![]() |
Dashed tube caps can be specified using CapForm:
| In[33]:= | ![]() |
| Out[33]= | ![]() |
Joining of dashed tube segments can be specified using JoinForm:
| In[34]:= | ![]() |
| Out[34]= | ![]() |
Colors can be specified at vertices using VertexColors:
| In[35]:= |
| Out[35]= | ![]() |
Specify color gradient over the tube:
| In[36]:= | ![]() |
| Out[36]= | ![]() |
Use the same gradient for each segment separately:
| In[37]:= | ![]() |
| Out[37]= | ![]() |
By default, the styling as well as Arrow are applied to the DashedTube globally:
| In[38]:= | ![]() |
| Out[38]= | ![]() |
To apply the styling and arrows to each segment separately, set "Each" to True:
| In[39]:= | ![]() |
| Out[39]= | ![]() |
To apply an arrow to each segment of a DashedTube that has a global styling, use a simple replacement:
| In[40]:= | ![]() |
| In[41]:= |
| Out[41]= | ![]() |
For some combinations of curves and dashing specifications, the sampling process may introduce aliasing artifacts or cusps:
| In[42]:= | ![]() |
| Out[42]= | ![]() |
Increase the initial number of sampling points:
| In[43]:= | ![]() |
| Out[43]= | ![]() |
Manual setting of the sampling number may lead to excessive number of resulting points that make up the tube segments:
| In[44]:= |
| Out[44]= |
For some combinations of curves and dashing specifications, the sampling process may introduce aliasing artifacts or cusps:
| In[45]:= | ![]() |
| Out[45]= | ![]() |
Increase the number of division steps in the sampling process to adaptively find an optimum number of sampling points:
| In[46]:= | ![]() |
| Out[46]= | ![]() |
The number of points that make up the tube segments is chosen to be minimum and still sufficient:
| In[47]:= |
| Out[47]= |
Plot a parametric space curve and replace the curve with a dashed tube:
| In[48]:= |
| Out[48]= | ![]() |
DashedTube can be used with Arrow for dashed 3D arrows:
| In[49]:= | ![]() |
| Out[49]= | ![]() |
Define a 3D coordinate system with dashed axes:
| In[50]:= | ![]() |
| Out[50]= | ![]() |
When no dashing is specified, the DashedTube gives identical results to Tube:
| In[51]:= | ![]() |
| Out[51]= | ![]() |
Use Arrow with DashedTube to get a dashed 3D arrow:
| In[52]:= |
| Out[52]= | ![]() |
Use Dashing specification outside DashedTube to set its dashing:
| In[53]:= |
| Out[53]= | ![]() |
Use dashing primitives Dashed, Dotted, and DotDashed to specify the dashing:
| In[54]:= | ![]() |
| Out[54]= | ![]() |
One can readily mimic the action of DashedTube, provided the uniformity of the dashing is not an issue:
| In[55]:= | ![]() |
| In[56]:= | ![]() |
| Out[56]= | ![]() |
DashedTube tries to keep the dashing uniform:
| In[57]:= | ![]() |
| Out[57]= | ![]() |
In some cases, aliasing artifacts may occur:
| In[58]:= |
| Out[58]= | ![]() |
Increase the number of sampling iterations:
| In[59]:= | ![]() |
| Out[59]= | ![]() |
From the way how the built-in arrows are handled, undesired behavior may occur when DashedTube is used with Arrow:
| In[60]:= | ![]() |
| Out[60]= | ![]() |
This effect can be mitigated by removing several last segments from the dashed tube:
| In[61]:= | ![]() |
| In[62]:= |
| Out[62]= | ![]() |
When Arrow is used together with VertexColors and "Each"→True, the color gradients are ignored and only the last color is used for each segment:
| In[63]:= |
| In[64]:= |
| Out[64]= | ![]() |
DashedTube makes no difference between the dashing specified using absolute and standard units:
| In[65]:= | ![]() |
| Out[65]= | ![]() |
Compare this with the default behavior for Line:
| In[66]:= |
| Out[66]= | ![]() |
When JoinForm is set to "Miter", the result may not be discernible from that for "Bevel":
| In[67]:= | ![]() |
| Out[67]= | ![]() |
The reason is that the dashed tube consists of many points and the joints are effectively smooth, resulting in no visible cusp:
| In[68]:= |
| In[69]:= |
| Out[69]= | ![]() |
When only the essential points are retained, one recovers the expected behavior:
| In[70]:= | ![]() |
| In[71]:= | ![]() |
| Out[71]= | ![]() |
The external dashing specification has to be in the same List with DashedTube, otherwise it is ignored:
| In[72]:= | ![]() |
| Out[72]= | ![]() |
Flatten the whole list:
| In[73]:= | ![]() |
| Out[73]= | ![]() |
Alternatively, put the Dashing construct into each sublist:
| In[74]:= | ![]() |
| Out[74]= | ![]() |
Dashed tube curves with interpolated radii:
| In[75]:= | ![]() |
| Out[75]= | ![]() |
Using random radii:
| In[76]:= |
| In[77]:= | ![]() |
| Out[77]= | ![]() |
Create a curve composed of balls:
| In[78]:= |
| In[79]:= | ![]() |
| Out[79]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License