TransWikia.com

Graphics3D: Background object erroneously placed in front of foreground object

Mathematica Asked on August 5, 2021

I want to plot the trajectory of a particle running on sphere together with the particle sitting on top of the last point of the trajectory. The problem is that in the resulting plot, it appears as if the trajectory is on top of the particle (using Version 12.0 on Windows 10). Is there a way to fix this rendering problem?

enter image description here

I have tried out adding Tube[] around Line[...]. This fixes the rendering problem, but it becomes very slow for long trajectories with 10k points (30s instead of 1s) and does not look as nice compared to the line due to the 3d shadow (Glow[] does not help due to the changing color of the trajectory).

Interestingly, another fix would be to increase the particle size, but I would prefer the current small particle size.

trajectory = Table[{0, Cos[[Phi]], Sin[[Phi]]}, {[Phi], 0, 2 [Pi], 0.01 2[Pi]}];
indexlist = Rescale[Range@Length@trajectory];
radius = 0.02;
is = 500;
position = (1.0 + 2 radius) {0, 0, 1};
plotSphere = ParametricPlot3D[{Sin[[Theta]] Cos[[Phi]], 
Sin[[Theta]] Sin[[Phi]], Cos[[Theta]]}
, {[Theta], 0, [Pi]}
, {[Phi], 0, 2 [Pi]}
, PlotStyle -> Opacity[0.1], Mesh -> None];
plotTrajectory = Graphics3D[{AbsoluteThickness[3], 
Line[trajectory,VertexColors -> (ColorData[{"Rainbow", "Reversed"}] /@ indexlist)]}];
plotParticle = Graphics3D[{Black, Sphere[position, radius]}, Lighting -> "Neutral"];

plotSide = Show[plotSphere, plotTrajectory, plotParticle
,ViewVertical -> {0.0037389442854121563, -0.5530970308584409,0.8331084531747398}
,ViewPoint -> {0.020825187867626407,-3.1406594298819064,0.07368214256857401}
,ImageSize -> is
,AxesLabel -> {"x", "y", "z"}
];
plotTop = Show[plotSphere, plotTrajectory, plotParticle
,ViewVertical -> {-0.005783614409904662, 0.7410236422288278, 0.6714540278100057}
,ViewPoint -> {-0.012799348794737526,-0.4847344374282649,3.1039447648002514`}
,ImageSize -> is
,AxesLabel -> {"x", "y", "z"}
];

plot = Grid[{{"side view", "top view (problem)"}, {plotSide, plotTop}}]
Export[FileNameJoin[{$HomeDirectory, "Desktop","sphere_render_problem.png"}], plot] 

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP