4
$\begingroup$

enter image description here

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!

$\endgroup$
7
  • 1
    $\begingroup$ Answer is here: mathematica.stackexchange.com/a/37219 $\endgroup$
    – Michael E2
    Commented Aug 11 at 12:51
  • 1
    $\begingroup$ @MichaelE2 Please note that the OP is soild instead of a surface. $\endgroup$
    – cvgmt
    Commented Aug 11 at 14:21
  • $\begingroup$ @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-case`at hand. An STL file specifies only the surface of the solid. $\endgroup$
    – Michael E2
    Commented Aug 11 at 15:37
  • 1
    $\begingroup$ @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. $\endgroup$
    – cvgmt
    Commented Aug 11 at 23:12
  • 1
    $\begingroup$ @MichaelE2 Sure. But the boundary must be Closed instead of only Show the pieces of surfaces ( BoundaryDiscreteGraphics not always work for such Show) $\endgroup$
    – cvgmt
    Commented Aug 12 at 2:02

4 Answers 4

12
$\begingroup$

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["NDSolve`FEM`"];
Needs["OpenCascadeLink`"];
ω = 10;
r = .5;
thickness = .05;
f[t_] := {r*Cos[ω*t], r*Sin[ω*t], t/4};
circles = 
  Table[OpenCascadeCircle[{f[t], f'[t]}, thickness], {t, 
    Subdivide[0, 2   π, 61]}];
s = OpenCascadeShape /@ circles;
loft = OpenCascadeShapeLoft[s, "BuildSolid" -> True];
bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[loft, 
   "ShapeSurfaceMeshOptions" -> {"AngularDeflection" -> 0.15}];
reg = BoundaryMeshRegion[bmesh];
Volume[reg]
Graphics3D[{MaterialShading["Aluminum"], reg}, 
 Lighting -> "ThreePoint", Boxed -> False]

0.245232

enter image description here

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

enter image description here

$\endgroup$
2
  • $\begingroup$ It's always nice to see good usage of OpenCascadeLink. Would you mind if I used this example in the documentation? $\endgroup$
    – user21
    Commented Aug 14 at 6:07
  • 1
    $\begingroup$ @user21 Your are welcome! Thanks! $\endgroup$
    – cvgmt
    Commented Aug 14 at 6:38
2
$\begingroup$
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]

enter image description here

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]}
$\endgroup$
4
  • $\begingroup$ does the is a solid geometry with Volume? I have given the code "Volume" to the geometry "myHelix", why does it indicate wrong? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 5:44
  • $\begingroup$ Is there any method to transfer closed surface into a solid geometry? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 9:24
  • $\begingroup$ How about using the method of "RegionProduct"? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 9:54
  • $\begingroup$ I have used "Volume" for the generated geometry, but why there is no value? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 9:55
2
$\begingroup$

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

helix

Volume@rrr

0.409727

$\endgroup$
5
  • $\begingroup$ 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? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 11:51
  • $\begingroup$ 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 $\endgroup$
    – Rom38
    Commented Aug 10 at 12:01
  • $\begingroup$ Oh, I got it. Thanks very much. Very helpful $\endgroup$
    – Hing Cu
    Commented Aug 10 at 12:06
  • $\begingroup$ 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? $\endgroup$
    – Hing Cu
    Commented Aug 10 at 12:23
  • $\begingroup$ @HingCu, The RegionProduct makes 3D shape from 2D using orthogonal translation mechanism. It does not help you with curved shapes like a helix. $\endgroup$
    – Rom38
    Commented Aug 10 at 14:44
0
$\begingroup$

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]

Spring

$\endgroup$
4
  • $\begingroup$ BoundaryDiscretize Graphics[g1] cannot be improve to a smooth solid if we use Plot Style->Tube $\endgroup$
    – cvgmt
    Commented Aug 11 at 23:33
  • $\begingroup$ With STL files 3d printed jobs for ( r<< R ) are found to be already reasonably smooth solid helices. $\endgroup$
    – Narasimham
    Commented Aug 12 at 1:20
  • $\begingroup$ 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. $\endgroup$
    – Hing Cu
    Commented Aug 12 at 4:20
  • $\begingroup$ and it is easy to be broken of the geometry when it is used in other software $\endgroup$
    – Hing Cu
    Commented Aug 12 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.