# How to use Mathematica to plot following helix solid geometry?

So, can you provide a method to plot this geometry in mathematica? It is soild instead of a surface. I need it to be printed out from mathematica as stl. document.

I have tried with Code "RegionProduct" method, but I do not know why it cannot work. So, can you provide me a method to form in mathematica?

Thanks very much!

• Answer is here: mathematica.stackexchange.com/a/37219 Commented Aug 11 at 12:51
• @MichaelE2 Please note that the OP is soild instead of a surface. Commented Aug 11 at 14:21
• @cvgmt How to plot a solid? How to make a solid in Graphics3D? For instance,Export["/tmp/foo.stl", ParametricPlot3D[{Sin[u] Cos[v], Sin[u] Sin[v], Cos[u]}, {u, 0, Pi}, {v, -Pi, Pi + 3 Pi/4}]] In other words, I don't see the significant distinction between a solid and the boundary of a solid for the use-caseat hand. An STL file specifies only the surface of the solid. Commented Aug 11 at 15:37
• @MichaelE2 Before I post my answer,I have read the author's comment in another answer,the solid should get the Volume, that is why I deliberate seal the two end to get a real solid. Commented Aug 11 at 23:12
• @MichaelE2 Sure. But the boundary must be Closed instead of only Show the pieces of surfaces ( BoundaryDiscreteGraphics not always work for such Show) Commented Aug 12 at 2:02

## Method-1

• We build several circles along the helix curve with normal be the tangent of the curve, and then using OpenCascadeShapeLoft to thread the circles to get the solid.
Clear["Global*"];
Needs["NDSolveFEM"];
Needs["OpenCascadeLink"];
ω = 10;
r = .5;
thickness = .05;
f[t_] := {r*Cos[ω*t], r*Sin[ω*t], t/4};
circles =
Subdivide[0, 2   π, 61]}];
loft = OpenCascadeShapeLoft[s, "BuildSolid" -> True];
"ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.15}];
reg = BoundaryMeshRegion[bmesh];
Volume[reg]
Lighting -> "ThreePoint", Boxed -> False]


0.245232

## Method-2

• Another way is directly construct a BoundaryMeshRegion from the data of the plot.
• In the plot, we set MaxRecursion -> 0.
• In the plot,we set two meshs to as the the boundary of such tube and construct two polygons to seal the two openings of the tube.
ω = 10;
r = .5;
thickness = .05;
f[t_] := {r*Cos[ω*t], r*Sin[ω*t], t/4};
{tangent, normal, binormal} =
Last[FrenetSerretSystem[f[t], t]] // Simplify;
F[t_, θ_] :=
f[t] + thickness*{Cos[θ], Sin[θ]} . {normal, binormal};
plot = ParametricPlot3D[
F[t, θ], {θ, 0, 2  π}, {t, 0, 2  π},
MaxRecursion -> 0, PlotPoints -> {40, 800},
MeshFunctions -> {#5 &}, Mesh -> {{0, 2  π}},
MeshStyle -> Directive@{Thick, Red}, Boxed -> False, Axes -> False,
Method -> {"BoundaryOffset" -> False}];
pts = Cases[plot, GraphicsComplex[pts_, rest__] :> pts, -1][[1]];
polys = Cases[plot, GraphicsGroup[data_] :> data, -1][[1, 1]];
lines = Cases[plot, _Line, -1];
reg = BoundaryMeshRegion[pts,
Polygon[Join[lines /. Line[pts_] :> Rest@pts, First@First@polys]]]
Volume[reg]


0.245702

• It's always nice to see good usage of OpenCascadeLink. Would you mind if I used this example in the documentation? Commented Aug 14 at 6:07
• @user21 Your are welcome! Thanks! Commented Aug 14 at 6:38
myHelix =ParametricPlot3D[{Sin[u], Cos[u], u/20}, {u, 0, 40},
Boxed -> False, Axes -> False,
PlotStyle -> Gray, PlotRange -> All] /.
Line[pts_, rest___] :> Tube[pts, 0.1, rest]


Export[".../myHelix.stl", myHelix, "STL"]


If you want a SOLID form:

ParametricPlot3D[{Sin[u], Cos[u], u/20}, {u, 0, 40},
Boxed -> False, Axes -> False,
PlotStyle -> Lighter[Gray], PlotRange -> All] /.
Line[pts_, rest___] :> {EdgeForm[None],
Cylinder[Partition[pts, 2, 1], 0.1]}

• does the is a solid geometry with Volume? I have given the code "Volume" to the geometry "myHelix", why does it indicate wrong? Commented Aug 10 at 5:44
• Is there any method to transfer closed surface into a solid geometry? Commented Aug 10 at 9:24
• How about using the method of "RegionProduct"? Commented Aug 10 at 9:54
• I have used "Volume" for the generated geometry, but why there is no value? Commented Aug 10 at 9:55

The simplest way making such a helix is using pack of joint Regions.

pts = N@Table[{Sin[u], Cos[u], u/10}, {u, 0, 15, 0.1}];
br = BooleanRegion[Or,
Table[
Cylinder[pts[[i;;i+1]], 0.1],
{i, 1, Length@pts - 1}]
];
rrr=Region@br


Volume@rrr


0.409727

• but here are some gaps seems. Does it OK? Will it cause any break or deformation when I import this helix.stl file into other software? Commented Aug 10 at 11:51
• This is the result of usage of the discrete approach. Generally, you can make it smoother setting the step of u smaller. It is not a break because the most part of helix is connected. This is like a set of scratches on the outer surface of the spring Commented Aug 10 at 12:01
• Oh, I got it. Thanks very much. Very helpful Commented Aug 10 at 12:06
• Then, can the method of using "RegionProdut" be OK? I have tried, but the circle disk cannot sweep along the helix curve; I do not know why. Does it mean this method does not work? Commented Aug 10 at 12:23
• @HingCu, The RegionProduct makes 3D shape from 2D using orthogonal translation mechanism. It does not help you with curved shapes like a helix. Commented Aug 10 at 14:44

Simplest:

 R = 5; r = 0.3;
g1 = ParametricPlot3D[{R Sin[t], R Cos[t], t/8}, {t, 0, 10 Pi},
PlotStyle -> {Green, Tube[r]}, PlotRange -> All]

Export[Drive\Path\"FEDER.stl", g1]


• BoundaryDiscretize Graphics[g1] cannot be improve to a smooth solid if we use Plot Style->Tube` Commented Aug 11 at 23:33
• With STL files 3d printed jobs for ( r<< R ) are found to be already reasonably smooth solid helices. Commented Aug 12 at 1:20
• can you add volume actions? since originally, I do it in this way, but I find in the center, the helix is hollow in the center. Commented Aug 12 at 4:20
• and it is easy to be broken of the geometry when it is used in other software Commented Aug 12 at 4:29