mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 13:34:19 +08:00
Changed all files to (mostly) conform to PEP8
This commit is contained in:
@ -6,6 +6,7 @@ from utils.space_ops import rotation_matrix
|
||||
|
||||
STRAIGHT_PATH_THRESHOLD = 0.01
|
||||
|
||||
|
||||
def straight_path(start_points, end_points, alpha):
|
||||
"""
|
||||
Same function as interpolate, but renamed to reflect
|
||||
@ -15,27 +16,31 @@ def straight_path(start_points, end_points, alpha):
|
||||
"""
|
||||
return interpolate(start_points, end_points, alpha)
|
||||
|
||||
def path_along_arc(arc_angle, axis = OUT):
|
||||
|
||||
def path_along_arc(arc_angle, axis=OUT):
|
||||
"""
|
||||
If vect is vector from start to end, [vect[:,1], -vect[:,0]] is
|
||||
If vect is vector from start to end, [vect[:,1], -vect[:,0]] is
|
||||
perpendicular to vect in the left direction.
|
||||
"""
|
||||
if abs(arc_angle) < STRAIGHT_PATH_THRESHOLD:
|
||||
return straight_path
|
||||
if np.linalg.norm(axis) == 0:
|
||||
axis = OUT
|
||||
unit_axis = axis/np.linalg.norm(axis)
|
||||
unit_axis = axis / np.linalg.norm(axis)
|
||||
|
||||
def path(start_points, end_points, alpha):
|
||||
vects = end_points - start_points
|
||||
centers = start_points + 0.5*vects
|
||||
centers = start_points + 0.5 * vects
|
||||
if arc_angle != np.pi:
|
||||
centers += np.cross(unit_axis, vects/2.0)/np.tan(arc_angle/2)
|
||||
rot_matrix = rotation_matrix(alpha*arc_angle, unit_axis)
|
||||
return centers + np.dot(start_points-centers, rot_matrix.T)
|
||||
centers += np.cross(unit_axis, vects / 2.0) / np.tan(arc_angle / 2)
|
||||
rot_matrix = rotation_matrix(alpha * arc_angle, unit_axis)
|
||||
return centers + np.dot(start_points - centers, rot_matrix.T)
|
||||
return path
|
||||
|
||||
|
||||
def clockwise_path():
|
||||
return path_along_arc(-np.pi)
|
||||
|
||||
|
||||
def counterclockwise_path():
|
||||
return path_along_arc(np.pi)
|
||||
return path_along_arc(np.pi)
|
||||
|
Reference in New Issue
Block a user