Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

changes to how the sectors are redrawn

Ben Hambrecht5b395853b719
diff --git a/active_projects/basel.py b/active_projects/basel.py
index 5b20dfc71..d08b7be37 100644
--- a/active_projects/basel.py
+++ b/active_projects/basel.py
@@ -1492,8 +1492,8 @@ class TwoLightSourcesScene(PiCreatureScene):
)
- ls1 = LightSource(radius = 20)
- ls2 = LightSource().deepcopy()
+ ls1 = LightSource(radius = 20, num_levels = 50)
+ ls2 = ls1.deepcopy()
#print "==="
#print ls1.get_source_point()
ls1.move_source_to(A)
@@ -1521,7 +1521,7 @@ class TwoLightSourcesScene(PiCreatureScene):
self.wait()
- ls3 = LightSource().deepcopy()
+ ls3 = ls1.deepcopy()
ls3.move_to(np.array([6,3.5,0]))
new_indicator = indicator.copy()
@@ -1589,6 +1589,70 @@ class TwoLightSourcesScene(PiCreatureScene):
+ # draw lines to complete the geometric picture
+ # and label the lengths
+
+ line_a = VMobject()
+ line_a.set_points_as_corners([B,C])
+ line_b = VMobject()
+ line_b.set_points_as_corners([A,C])
+ line_c = VMobject()
+ line_c.set_points_as_corners([A,B])
+ line_h = VMobject()
+ line_h.set_points_as_corners([H,C])
+
+ label_a = TexMobject("a")
+ label_a.next_to(line_a, LEFT, buff = 0.5)
+ label_b = TexMobject("b")
+ label_b.next_to(line_b, DOWN, buff = 0.5)
+ label_h = TexMobject("h")
+ label_h.next_to(line_h.get_center(), RIGHT, buff = 0.5)
+
+ self.play(
+ ShowCreation(line_a),
+ Write(label_a)
+ )
+
+ self.play(
+ ShowCreation(line_b),
+ Write(label_b)
+ )
+
+ self.play(
+ ShowCreation(line_c),
+ )
+
+ self.play(
+ ShowCreation(line_h),
+ Write(label_h)
+ )
+
+
+ # state the IPT
+ theorem_location = np.array([3.,2.,0.])
+ theorem = TexMobject("{1\over a^2} + {1\over b^2} = {1\over h^2}")
+ theorem_name = TextMobject("Inverse Pythagorean Theorem")
+ buffer = 1.2
+ theorem_box = Rectangle(width = buffer*theorem.get_width(),
+ height = buffer*theorem.get_height())
+
+ theorem.move_to(theorem_location)
+ theorem_box.move_to(theorem_location)
+ theorem_name.next_to(theorem_box,UP)
+
+ self.play(
+ Write(theorem),
+ )
+
+ self.play(
+ ShowCreation(theorem_box),
+ Write(theorem_name),
+ )
+
+
+
+
+
diff --git a/topics/light.py b/topics/light.py
index 35c2fb203..67f1458c3 100644
--- a/topics/light.py
+++ b/topics/light.py
@@ -346,11 +346,9 @@ class AmbientLight(VMobject):
def move_source_to(self,point):
- # Note: Best to rewrite in terms of VectorizedPoint source_point
- old_source_point = self.get_source_point()
- #self.source_point.set_location(np.array(point))
-
- self.shift(point - old_source_point)
+ #old_source_point = self.get_source_point()
+ #self.shift(point - old_source_point)
+ self.move_to(point)
return self
@@ -522,6 +520,8 @@ class Spotlight(VMobject):
def move_source_to(self,point):
self.source_point.set_location(np.array(point))
+ #self.source_point.move_to(np.array(point))
+ #self.move_to(point)
self.update_sectors()
return self
@@ -532,9 +532,12 @@ class Spotlight(VMobject):
for submob in self.submobject_family():
if type(submob) == AnnularSector:
lower_angle, upper_angle = self.viewing_angles(self.screen)
- dr = submob.outer_radius - submob.inner_radius
+ #dr = submob.outer_radius - submob.inner_radius
+ dr = self.radius / self.num_levels
new_submob = self.new_sector(submob.inner_radius,dr,lower_angle,upper_angle)
submob.points = new_submob.points
+ submob.set_fill(opacity = 10 * self.opacity_function(submob.outer_radius))
+ print "new opacity:", self.opacity_function(submob.outer_radius)