A community-maintained Python framework for creating mathematical animations.
Fix wrong angle ranges in `Sphere` documentation and add more examples (#3973)
Xiuyuan (Jack) Yuan46177d247e88
diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.pyindex 48297a67d..f2698de7e 100644--- a/manim/mobject/three_d/three_dimensions.py+++ b/manim/mobject/three_d/three_dimensions.py@@ -379,13 +379,7 @@ class Sphere(Surface):class ExampleSphere(ThreeDScene):def construct(self):self.set_camera_orientation(phi=PI / 6, theta=PI / 6)- sphere1 = Sphere(- center=(3, 0, 0),- radius=1,- resolution=(20, 20),- u_range=[0.001, PI - 0.001],- v_range=[0, TAU]- )+ sphere1 = Sphere(center=(3, 0, 0), radius=1, resolution=(20, 20))sphere1.set_color(RED)self.add(sphere1)sphere2 = Sphere(center=(-1, -3, 0), radius=2, resolution=(18, 18))@@ -394,6 +388,57 @@ class Sphere(Surface):sphere3 = Sphere(center=(-1, 2, 0), radius=2, resolution=(16, 16))sphere3.set_color(BLUE)self.add(sphere3)++ This example shows that overlapping spheres can intersect with rough transitions.++ .. manim:: ExampleSphereOverlap+ :save_last_frame:++ class ExampleSphereOverlap(ThreeDScene):+ def construct(self):+ self.set_camera_orientation(phi=PI / 4, theta=PI / 4)+ sphere1 = Sphere(center=(0, 0, 0), radius=1, resolution=(20, 20))+ sphere1.set_color(RED)+ self.add(sphere1)+ sphere2 = Sphere(center=(-0.5, -1, 0.5), radius=1.2, resolution=(20, 20))+ sphere2.set_color(GREEN)+ self.add(sphere2)+ sphere3 = Sphere(center=(1, -1, 0), radius=1.1, resolution=(20, 20))+ sphere3.set_color(BLUE)+ self.add(sphere3)++ In this example, by modifying ``u_range`` (the range of the azimuthal angle) and+ ``v_range`` (the range of the polar angle), it is possible to obtain a portion of a+ sphere:++ .. manim:: ExamplePartialSpheres+ :save_last_frame:++ class ExamplePartialSpheres(ThreeDScene):+ def construct(self):+ self.set_camera_orientation(phi=PI / 4)+ sphere1 = Sphere(+ center=(-3, 0, 0),+ resolution=(10, 20),+ u_range=[TAU / 4, 3 * TAU / 4],+ )+ sphere1.set_color(RED)+ self.add(sphere1)+ sphere2 = Sphere(+ center=(0, 0, 0),+ resolution=(20, 10),+ v_range=[0, TAU / 4],+ )+ sphere2.set_color(GREEN)+ self.add(sphere2)+ sphere3 = Sphere(+ center=(3, 0, 0),+ resolution=(5, 10),+ u_range=[3 * TAU / 4, TAU],+ v_range=[TAU / 4, TAU / 2],+ )+ sphere3.set_color(BLUE)+ self.add(sphere3)"""def __init__(