I used this code of user Henrik Schumacher to try render a realistic looking rope. The result using ParametricPlot3D is here: enter image description here

In fact not very realistic. The trefoil knot is wrapped with 4 helix tubes.

  1. How to achieve a better result?
  2. Is it possible to use only one tube with some texture on it or one tube with non-circle cross section?

I do not even know if it is possible to have Tube for example with a triangle cross section. Is it?

And another thing... if you look at the picture carefully you will see a grain noise on it. I used parameters PlotPoints -> 300, PerformanceGoal -> "Quality" but there were no difference. If I used only one helix, than there were no grain noise. What causes this noise?


I just added PlotStyle -> Directive[Opacity[0.99]] (for a placebo effect ;-)) to ParametricPlot3D and the grain noise disappeared. So I think it is a bug in Mathematica.

enter image description here


The code

(*Trefoil knot parametric equations*)
\[Gamma]=t\[Function]{Sin[2 \[Pi] t]+ 2 Sin[2 2 \[Pi] t],Cos[2 \[Pi] t]-2 Cos[2 2 \[Pi] t],-Sin[3 2 \[Pi] t]};

(*unit tangent vector*)T=t\[Function]Evaluate[\[Gamma]'[t]/Sqrt[\[Gamma]'[t].\[Gamma]'[t]]];
(*curvature vector*)\[Kappa]=t\[Function]Evaluate[T'[t]/Sqrt[\[Gamma]'[t].\[Gamma]'[t]]];
(*compute Bishop frame*)u0=Automatic;
sol=NDSolve[Evaluate@Thread[Flatten[{A'[t][[1]]-Sqrt[\[Gamma]'[t].\[Gamma]'[t]] (A[t][[2]] A[t][[2]].\[Kappa][t]+A[t][[3]] A[t][[3]].\[Kappa][t]),A'[t][[2]]+Sqrt[\[Gamma]'[t].\[Gamma]'[t]] (A[t][[1]] A[t][[2]].\[Kappa][t]),A'[t][[3]]+Sqrt[\[Gamma]'[t].\[Gamma]'[t]] (A[t][[1]] A[t][[3]].\[Kappa][t]),A[0]-Orthogonalize[{T[0],u0,Cross[T[0],u0]}]}]==0],Evaluate[Flatten[A[t]]],{t,a,b},InterpolationOrder->All][[1]]//Quiet;
If[(Norm[\[Gamma][a]-\[Gamma][b]]<10^-8)&&(Norm[\[Gamma]'[a]-\[Gamma]'[b]]<10^-8),\[Omega]-=ArcTan@@LinearSolve[Transpose[frame[b]],Transpose[frame[a]]][[2,2;;3]]/(b-a)/(2 Pi);];
frame1=t\[Function]{frame[t][[1]],frame[t][[2]] Cos[2 Pi \[Omega] t]+frame[t][[3]] Sin[2 Pi \[Omega] t],-frame[t][[2]] Sin[2 Pi \[Omega] t]+frame[t][[3]] Cos[2 Pi \[Omega] t]};
frame2=t\[Function]{frame[t][[1]],frame[t][[2]] Cos[2 Pi \[Omega] t+2\[Pi]/4]+frame[t][[3]] Sin[2 Pi \[Omega] t+2\[Pi]/4],-frame[t][[2]] Sin[2 Pi \[Omega] t+2\[Pi]/4]+frame[t][[3]] Cos[2 Pi \[Omega] t+2\[Pi]/4]};
frame3=t\[Function]{frame[t][[1]],frame[t][[2]] Cos[2 Pi \[Omega] t+4\[Pi]/4]+frame[t][[3]] Sin[2 Pi \[Omega] t+4\[Pi]/4],-frame[t][[2]] Sin[2 Pi \[Omega] t+4\[Pi]/4]+frame[t][[3]] Cos[2 Pi \[Omega] t+4\[Pi]/4]};
frame4=t\[Function]{frame[t][[1]],frame[t][[2]] Cos[2 Pi \[Omega] t+6\[Pi]/4]+frame[t][[3]] Sin[2 Pi \[Omega] t+6\[Pi]/4],-frame[t][[2]] Sin[2 Pi \[Omega] t+6\[Pi]/4]+frame[t][[3]] Cos[2 Pi \[Omega] t+6\[Pi]/4]};
\[Delta]1=t\[Function]\[Gamma][t]+r frame1[t][[2]];
\[Delta]2=t\[Function]\[Gamma][t]+r frame2[t][[2]];
\[Delta]3=t\[Function]\[Gamma][t]+r frame3[t][[2]];
\[Delta]4=t\[Function]\[Gamma][t]+r frame4[t][[2]];


How to achieve for example this? Only one textured tube, no computationally intensive wrapping with helices needed. The image downloaded form https://www.pngwave.com.

enter image description here


If you cannot see the noise on the first image here is the same plot magnified inside Mathematica to see the noise. To reproduce just use my code without PlotStyle->Directive[Opacity[0.99]].

enter image description here

  • 2
    $\begingroup$ Would you please share the precise code that you used to generate the plots? Computing VertexNormals should resolve the problem, but it has to be done manually. $\endgroup$ Commented Jul 17, 2020 at 5:19
  • $\begingroup$ It is basically your code... just slight adjustments and using ParametricPlot3D instead of Graphics3D. Concerning the VertexNormals what problem you want to resolve? The grain noise? It is only secondary problem for me, as Opacity[0.99] resolved the problem for me. I am more interested in other ways how to achieve more realistically looking rope. I will add the code to my question. $\endgroup$ Commented Jul 17, 2020 at 14:30
  • $\begingroup$ @Henrik Schumacher: How to copy code from mathematica that when pasted it will give me nice ω instead of cumbersome \[Omega]? $\endgroup$ Commented Jul 17, 2020 at 14:44
  • $\begingroup$ Do you have the editor buttons installed? It allows you to replace symbols with something more readable. $\endgroup$
    – Tim Laska
    Commented Jul 17, 2020 at 14:59
  • $\begingroup$ Your "EDIT 2" looks like you forgot the code? $\endgroup$
    – Michael E2
    Commented Jul 17, 2020 at 15:02


Your Answer

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

Browse other questions tagged or ask your own question.