1

I'm trying to animate a trajectory of a particle on a spherical surface in manim. I made the sphere semi-transparent so it's easy to say when the particle is on the front side and when it is on the back side of the sphere. However after I plot the trajectory, even the parts that are supposed to be behind the sphere are the same color as the ones in front of it.

enter image description here

As you can see this issue is not present in the coordinate axes. The parts of axes that are inside of the sphere have different color, because the semi-transparent surface is between them and camera.

I'm using the following code

S=Sphere(center=(0,0,0), radius=1.09,resolution=(15, 15)).set_opacity(0.4)
S.set_color(GRAY)
self.add(axes,S)
for i in range(100):
   self.play(Create(Traj[i]))

Where Traj is an array consisting of line elements of the trajectory.

Even if I set the sphere opacity to 1, I can still see the whole trajectory, even if most of it should be behind the spehre. How to make the sphere cover the back part of the trajectory?

Dio
  • 111
  • 2
  • Hello! Did you ever solve this problem? – WHermann Jul 22 '22 at 20:05
  • 1
    Hi, no I have not. I did find sort of a bootleg way around it though. I used spherical coordinates to determine which parts of the trajectory should be visible from the camera position and which parts should be behind the sphere. Then I set the opacity of the parts that are behind to 0.5, so it looks as if the sphere is overlaping them. It's not perfect, doesn't work all the time, but it's better than nothing. – Dio Jul 24 '22 at 13:03

0 Answers0