mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 13:01:00 +00:00
Merge branch 'lighthouse2' into lighthouse-grant
This commit is contained in:
commit
feac46e83b
4 changed files with 65 additions and 33 deletions
|
@ -406,7 +406,6 @@ class IntroScene(PiCreatureScene):
|
|||
|
||||
self.ellipsis = TexMobject("\cdots")
|
||||
self.ellipsis.scale(0.4)
|
||||
|
||||
for i in range(5, max_n1):
|
||||
|
||||
if i == 5:
|
||||
|
@ -421,7 +420,6 @@ class IntroScene(PiCreatureScene):
|
|||
GrowFromPoint(self.rects[i], self.euler_sum[10].get_center(),
|
||||
run_time = 0.5)
|
||||
)
|
||||
|
||||
for i in range(max_n1, max_n2):
|
||||
self.play(
|
||||
GrowFromPoint(self.rects[i], self.euler_sum[10].get_center(),
|
||||
|
@ -935,6 +933,7 @@ class MorphIntoSunScene(PiCreatureScene):
|
|||
max_opacity_spotlight = SPOTLIGHT_FULL,
|
||||
|
||||
)
|
||||
self.wait()
|
||||
|
||||
self.light_source.move_source_to(source_point)
|
||||
|
||||
|
@ -960,7 +959,6 @@ class MorphIntoSunScene(PiCreatureScene):
|
|||
fill_opacity = 1.0,
|
||||
stroke_width = 0.0
|
||||
)
|
||||
|
||||
self.screen.next_to(morty,LEFT)
|
||||
|
||||
self.light_source.set_screen(self.screen)
|
||||
|
|
|
@ -96,6 +96,57 @@ class Arc(VMobject):
|
|||
|
||||
return self
|
||||
|
||||
|
||||
|
||||
class ArcBetweenPoints(Arc):
|
||||
|
||||
def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
|
||||
if angle == 0:
|
||||
raise Exception("Arc with zero curve angle: use Line instead.")
|
||||
|
||||
midpoint = 0.5 * (start_point + end_point)
|
||||
distance_vector = end_point - start_point
|
||||
normal_vector = np.array([-distance_vector[1], distance_vector[0],0])
|
||||
distance = np.linalg.norm(normal_vector)
|
||||
normal_vector /= distance
|
||||
if angle < 0:
|
||||
normal_vector *= -1
|
||||
|
||||
radius = distance/2 / np.sin(0.5 * np.abs(angle))
|
||||
l = distance/2 / np.tan(0.5 * np.abs(angle))
|
||||
arc_center = midpoint + l * normal_vector
|
||||
w = start_point - arc_center
|
||||
if w[0] != 0:
|
||||
start_angle = np.arctan2(w[1],w[0])
|
||||
else:
|
||||
start_angle = np.pi/2
|
||||
|
||||
Arc.__init__(self, angle,
|
||||
radius = radius,
|
||||
start_angle = start_angle,
|
||||
**kwargs)
|
||||
|
||||
self.move_arc_center_to(arc_center)
|
||||
|
||||
class CurvedArrow(ArcBetweenPoints):
|
||||
|
||||
def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
|
||||
# I know this is in reverse, but it works
|
||||
if angle >= 0:
|
||||
ArcBetweenPoints.__init__(self, start_point, end_point, angle = angle, **kwargs)
|
||||
self.add_tip(at_start = True, at_end = False)
|
||||
else:
|
||||
ArcBetweenPoints.__init__(self, end_point, start_point, angle = -angle, **kwargs)
|
||||
self.add_tip(at_start = False, at_end = True)
|
||||
|
||||
|
||||
class CurvedDoubleArrow(ArcBetweenPoints):
|
||||
|
||||
def __init__(self, start_point, end_point, angle = TAU/4, **kwargs):
|
||||
ArcBetweenPoints.__init__(self, start_point, end_point, angle = angle, **kwargs)
|
||||
self.add_tip(at_start = True, at_end = True)
|
||||
|
||||
|
||||
class Circle(Arc):
|
||||
CONFIG = {
|
||||
"color" : RED,
|
||||
|
|
|
@ -29,10 +29,10 @@ NUM_LEVELS = 30
|
|||
NUM_CONES = 7 # in first lighthouse scene
|
||||
NUM_VISIBLE_CONES = 5 # ibidem
|
||||
ARC_TIP_LENGTH = 0.2
|
||||
AMBIENT_FULL = 0.5
|
||||
AMBIENT_DIMMED = 0.2
|
||||
SPOTLIGHT_FULL = 0.9
|
||||
SPOTLIGHT_DIMMED = 0.2
|
||||
AMBIENT_FULL = 0.8
|
||||
AMBIENT_DIMMED = 0.5
|
||||
SPOTLIGHT_FULL = 0.8
|
||||
SPOTLIGHT_DIMMED = 0.5
|
||||
LIGHTHOUSE_HEIGHT = 0.8
|
||||
|
||||
DEGREES = TAU/360
|
||||
|
@ -57,7 +57,7 @@ class LightSource(VMobject):
|
|||
"source_point": VectorizedPoint(location = ORIGIN, stroke_width = 0, fill_opacity = 0),
|
||||
"color": LIGHT_COLOR,
|
||||
"num_levels": 10,
|
||||
"radius": 5,
|
||||
"radius": 10.0,
|
||||
"screen": None,
|
||||
"opacity_function": inverse_quadratic(1,2,1),
|
||||
"max_opacity_ambient": AMBIENT_FULL,
|
||||
|
@ -142,7 +142,9 @@ class LightSource(VMobject):
|
|||
num_levels = self.num_levels,
|
||||
radius = self.radius,
|
||||
screen = new_screen,
|
||||
camera_mob = self.camera_mob
|
||||
camera_mob = self.camera_mob,
|
||||
opacity_function = self.opacity_function,
|
||||
max_opacity = self.max_opacity_spotlight,
|
||||
)
|
||||
self.spotlight.move_source_to(self.get_source_point())
|
||||
|
||||
|
@ -423,7 +425,7 @@ class Spotlight(VMobject):
|
|||
"color" : GREEN, # LIGHT_COLOR,
|
||||
"max_opacity" : 1.0,
|
||||
"num_levels" : 10,
|
||||
"radius" : 5.0,
|
||||
"radius" : 10.0,
|
||||
"screen" : None,
|
||||
"camera_mob": None
|
||||
}
|
||||
|
|
|
@ -120,6 +120,9 @@ class NumberLine(VMobject):
|
|||
result.add(mob)
|
||||
return result
|
||||
|
||||
def get_labels(self):
|
||||
return self.get_number_mobjects()
|
||||
|
||||
def add_numbers(self, *numbers, **kwargs):
|
||||
self.numbers = self.get_number_mobjects(
|
||||
*numbers, **kwargs
|
||||
|
@ -219,29 +222,7 @@ class Axes(VGroup):
|
|||
return graph
|
||||
|
||||
def input_to_graph_point(self, x, graph):
|
||||
if hasattr(graph, "underlying_function"):
|
||||
return self.coords_to_point(x, graph.underlying_function(x))
|
||||
else:
|
||||
#binary search
|
||||
lh, rh = 0, 1
|
||||
while abs(lh - rh) > 0.001:
|
||||
mh = np.mean([lh, rh])
|
||||
hands = [lh, mh, rh]
|
||||
points = map(graph.point_from_proportion, hands)
|
||||
lx, mx, rx = map(self.x_axis.point_to_number, points)
|
||||
if lx <= x and rx >= x:
|
||||
if mx > x:
|
||||
rh = mh
|
||||
else:
|
||||
lh = mh
|
||||
elif lx <= x and rx <= x:
|
||||
return points[2]
|
||||
elif lx >= x and rx >= x:
|
||||
return points[0]
|
||||
elif lx > x and rx < x:
|
||||
lh, rh = rh, lh
|
||||
return points[1]
|
||||
|
||||
return self.coords_to_point(x, graph.underlying_function(x))
|
||||
|
||||
class ThreeDAxes(Axes):
|
||||
CONFIG = {
|
||||
|
|
Loading…
Add table
Reference in a new issue