Message Boards Message Boards

0
|
1662 Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

3D graphics overlaying with show function

Posted 10 months ago

I'd like to combine 3D curve and surface with Show in Mathematica 13.3. It is strange that the curve could not be hiden by the surface effectively even though the curve is behind the surface. The code is given as following,

\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 
    2 \[Pi]}, PlotPoints -> 100, Mesh -> None];
g2 = Table[
   ParametricPlot3D[{x[t] Cos[\[CurlyPhi][[i]]], 
     x[t] Sin[\[CurlyPhi][[i]]], z[t]}, {t, 0, 2 \[Pi]}], {i, 3}];
Show[g2, g1, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, 
 ViewAngle -> 70 °, Boxed -> False, Axes -> False, PlotRange -> All]

The result is shown in the attached figure. Beside that there is no different If the curve is replaced by Mesh method as mesh thickness is set explicitly.

Attachment

Attachments:
POSTED BY: Jianhua Yang
6 Replies

I guess the problem is the mixing of objects of different dimensions. If you use a Tube[] instead of a Line[] it seems to work correctly. I would do it like so:

\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotPoints -> 100, Mesh -> None, Axes -> False];
g2 = ParametricPlot3D[Table[{x[t] Cos[\[CurlyPhi][[i]]], x[t] Sin[\[CurlyPhi][[i]]], 
      z[t]}, {i, 3}], {t, 0, 2 \[Pi]}, PlotStyle -> Automatic] /. Line[p__] :> Tube[p, .05];
Show[g2, g1, Boxed -> False, Axes -> False, PlotRange -> All, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, ViewAngle -> 70 °]

enter image description here

POSTED BY: Henrik Schachner
Posted 10 months ago

Thank you very much for your reply. Yes, it works good! But there is a new problem. If the radius of the tube is two small, it sames that the "curve" is dashed. For example, if to set Line[p__] :> Tube[p, .005], the result is showing in the attached figure. I don't know how to deal with it as the radius of the tube should be fixed in my applying.

enter image description here

POSTED BY: Jianhua Yang
Posted 10 months ago

In Mathematica version 12.3 the rendering is as expected:

enter image description here

POSTED BY: Hans Milton

I see! One possibility would be to make sure that the tube runs completely just inside the big torus:

\[CurlyPhi] = \[Pi] {1/4, 1/2, 3/4};
rTube = .005;  (* radius of tube *)
x[t_] := 2 + Cos[t];
z[t_] := Sin[t];
g1 = RevolutionPlot3D[{x[t], z[t]}, {t, 0, 2 \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotPoints -> 100, Mesh -> None, Axes -> False];
g2 = ParametricPlot3D[Table[{(2 + (1 - rTube) Cos[t]) Cos[\[CurlyPhi][[i]]], (2 + (1 - rTube) Cos[t]) Sin[\[CurlyPhi][[i]]], (1 - rTube) z[t]}, {i, 3}], {t, 0, 2 \[Pi]}] /. Line[p__] :> Tube[p, rTube];
Show[g2, g1, Boxed -> False, Axes -> False, PlotRange -> All, ViewVector -> {{2.8, 0, 0}, {0, 2.5, 0}}, ViewAngle -> 70 °]

Does that help?

POSTED BY: Henrik Schachner

Hello Hans,

In Mathematica version 12.3 the rendering is as expected:

yes, at first I thought so too. But it appears not to be robust. E.g. try

ParametricPlot3D[...,  PlotStyle -> Thickness[.05]]
POSTED BY: Henrik Schachner
Posted 10 months ago

Yes, it is. The problem appears to be related with the view direction from inside to outside of the torus. There is no issue when the view direction in the opposite side.

POSTED BY: Jianhua Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract