How do I extract the tube style (including lighting, viewpoint, ...) from KnotData["Trefoil"]

trefoil knot

and apply it to a space curve, such as

ParametricPlot3D[{Cos[θ], Sin[θ], Cos[2 θ]}, {θ, 0, 2 π}] ?


2 Answers 2

(* {Boxed -> False, PlotRange -> {All, All, All}, 
 PlotRangePadding -> {Automatic, Automatic, Automatic}, 
 ViewPoint -> {0, 0.01, 5}} *)

You can see the ViewPoint above. Since the lighting is not mentioned, it has the default value.

Generally, for any Graphics3D, just paste it in the middle of an Options[...] or Options[..., ViewPoint].

thickness = 0.1;
ParametricPlot3D[{Cos[\[Theta]], Sin[\[Theta]], 
   Cos[2 \[Theta]]}, {\[Theta], 0, 2 \[Pi]},
  PlotPoints -> 360,
  PlotStyle -> White,
  PlotRangePadding -> 2 thickness] /. Line[x__] :> Tube[x, thickness]

enter image description here

The tubes are white, actually. The colors result from the defaults for the graphics option Lighting.

  • $\begingroup$ Great. But HOW did you extract the data? Just guess and check? $\endgroup$ Nov 27, 2017 at 23:00
  • $\begingroup$ Graphics3D objects can be inspected. The one created by KnotData["Trefoil"] just contains a GraphicsComplex and the standard color for a GraphicsComplex is White. That's about the color. ParametricPlot3D creates Graphics3D objects containing Line primitives (if you plot curves) and these can be changed into Tube primitives just as above. The thickness was a pure guess. $\endgroup$ Nov 27, 2017 at 23:04
  • 2
    $\begingroup$ Note that PlotStyle -> {White, Tube[thickness]} may be used instead of post-processing the Line objects. $\endgroup$
    – Michael E2
    Nov 27, 2017 at 23:31
  • $\begingroup$ @MichaelE2 Good to know! And it is rendered with VertexNormals! However, do you also see that the ends of the curve are visible this way? $\endgroup$ Nov 27, 2017 at 23:38
  • $\begingroup$ @MichaelE2 I mean: Can something to be done about that? I wrote my own tubification function long time ago, but it would be nice to know if there is a built-in alternative. $\endgroup$ Nov 27, 2017 at 23:45

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.