mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 21:44:19 +08:00
middle of massive restructure, everything still broken
This commit is contained in:
32
helpers.py
32
helpers.py
@ -93,6 +93,38 @@ def random_color():
|
||||
color.set_rgb([1 - 0.5 * random() for x in range(3)])
|
||||
return color
|
||||
|
||||
|
||||
################################################
|
||||
|
||||
def straight_path(start_points, end_points, alpha):
|
||||
return (1-alpha)*start_points + alpha*end_points
|
||||
|
||||
def path_along_arc(arc_angle):
|
||||
"""
|
||||
If vect is vector from start to end, [vect[:,1], -vect[:,0]] is
|
||||
perpendicualr to vect in the left direction.
|
||||
"""
|
||||
if arc_angle == 0:
|
||||
return straight_path
|
||||
def path(start_points, end_points, alpha):
|
||||
vects = end_points - start_points
|
||||
centers = start_points + 0.5*vects
|
||||
if arc_angle != np.pi:
|
||||
for i, b in [(0, -1), (1, 1)]:
|
||||
centers[:,i] += 0.5*b*vects[:,1-i]/np.tan(arc_angle/2)
|
||||
return centers + np.dot(
|
||||
start_points-centers,
|
||||
np.transpose(rotation_about_z(alpha*arc_angle))
|
||||
)
|
||||
return path
|
||||
|
||||
def clockwise_path():
|
||||
return path_along_arc(np.pi)
|
||||
|
||||
def counterclockwise_path():
|
||||
return path_along_arc(-np.pi)
|
||||
|
||||
|
||||
################################################
|
||||
|
||||
def to_cammel_case(name):
|
||||
|
Reference in New Issue
Block a user