Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace DEGREES -> DEG
Browse files Browse the repository at this point in the history
3b1b committed Dec 12, 2024
1 parent d8e06c6 commit 8cc5195
Showing 13 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/source/documentation/constants.rst
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ Mathematical constant
PI = np.pi
TAU = 2 * PI
DEGREES = TAU / 360
DEG = TAU / 360
Text
----
12 changes: 6 additions & 6 deletions docs/source/getting_started/example_scenes.rst
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ InteractiveDevlopment
self.play(ReplacementTransform(square, circle))
self.wait()
self.play(circle.animate.stretch(4, 0))
self.play(Rotate(circle, 90 * DEGREES))
self.play(Rotate(circle, 90 * DEG))
self.play(circle.animate.shift(2 * RIGHT).scale(0.25))

text = Text("""
@@ -221,7 +221,7 @@ TexTransformExample
self.play(
TransformMatchingTex(
lines[0].copy(), lines[1],
path_arc=90 * DEGREES,
path_arc=90 * DEG,
),
**play_kw
)
@@ -599,8 +599,8 @@ SurfaceExample
# Set perspective
frame = self.camera.frame
frame.set_euler_angles(
theta=-30 * DEGREES,
phi=70 * DEGREES,
theta=-30 * DEG,
phi=70 * DEG,
)

surface = surfaces[0]
@@ -624,8 +624,8 @@ SurfaceExample
self.play(
Transform(surface, surfaces[2]),
# Move camera frame during the transition
frame.animate.increment_phi(-10 * DEGREES),
frame.animate.increment_theta(-20 * DEGREES),
frame.animate.increment_phi(-10 * DEG),
frame.animate.increment_theta(-20 * DEG),
run_time=3
)
# Add ambient rotation
10 changes: 5 additions & 5 deletions example_scenes.py
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ def construct(self):
# to go to a non-equal substring from the target,
# use the key map.
key_map={"+": "-"},
path_arc=90 * DEGREES,
path_arc=90 * DEG,
),
)
self.wait()
@@ -203,7 +203,7 @@ def construct(self):
TransformMatchingStrings(
lines[2].copy(), lines[3],
key_map={"2": R"\sqrt"},
path_arc=-30 * DEGREES,
path_arc=-30 * DEG,
),
)
self.wait(2)
@@ -616,8 +616,8 @@ def construct(self):
self.play(
Transform(surface, surfaces[2]),
# Move camera frame during the transition
self.frame.animate.increment_phi(-10 * DEGREES),
self.frame.animate.increment_theta(-20 * DEGREES),
self.frame.animate.increment_phi(-10 * DEG),
self.frame.animate.increment_theta(-20 * DEG),
run_time=3
)
# Add ambient rotation
@@ -666,7 +666,7 @@ def construct(self):
self.play(ReplacementTransform(square, circle))
self.wait()
self.play(circle.animate.stretch(4, 0))
self.play(Rotate(circle, 90 * DEGREES))
self.play(Rotate(circle, 90 * DEG))
self.play(circle.animate.shift(2 * RIGHT).scale(0.25))

text = Text("""
4 changes: 2 additions & 2 deletions manimlib/animation/indication.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
from manimlib.constants import FRAME_X_RADIUS, FRAME_Y_RADIUS
from manimlib.constants import ORIGIN, RIGHT, UP
from manimlib.constants import SMALL_BUFF
from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.constants import TAU
from manimlib.constants import GREY, YELLOW
from manimlib.mobject.geometry import Circle
@@ -395,7 +395,7 @@ def interpolate_submobject(


class TurnInsideOut(Transform):
def __init__(self, mobject: Mobject, path_arc: float = 90 * DEGREES, **kwargs):
def __init__(self, mobject: Mobject, path_arc: float = 90 * DEG, **kwargs):
super().__init__(mobject, path_arc=path_arc, **kwargs)

def create_target(self) -> Mobject:
4 changes: 2 additions & 2 deletions manimlib/animation/transform.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import numpy as np

from manimlib.animation.animation import Animation
from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.constants import OUT
from manimlib.mobject.mobject import Group
from manimlib.mobject.mobject import Mobject
@@ -314,7 +314,7 @@ def init_path_func(self) -> None:


class CyclicReplace(Transform):
def __init__(self, *mobjects: Mobject, path_arc=90 * DEGREES, **kwargs):
def __init__(self, *mobjects: Mobject, path_arc=90 * DEG, **kwargs):
super().__init__(Group(*mobjects), path_arc=path_arc, **kwargs)

def create_target(self) -> Mobject:
8 changes: 4 additions & 4 deletions manimlib/camera/camera_frame.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import numpy as np
from scipy.spatial.transform import Rotation

from manimlib.constants import DEGREES, RADIANS
from manimlib.constants import DEG, RADIANS
from manimlib.constants import FRAME_SHAPE
from manimlib.constants import DOWN, LEFT, ORIGIN, OUT, RIGHT, UP
from manimlib.constants import PI
@@ -26,7 +26,7 @@ def __init__(
frame_shape: tuple[float, float] = FRAME_SHAPE,
center_point: Vect3 = ORIGIN,
# Field of view in the y direction
fovy: float = 45 * DEGREES,
fovy: float = 45 * DEG,
euler_axes: str = "zxz",
# This keeps it ordered first in a scene
z_index=-1,
@@ -181,7 +181,7 @@ def reorient(
Shortcut for set_euler_angles, defaulting to taking
in angles in degrees
"""
self.set_euler_angles(theta_degrees, phi_degrees, gamma_degrees, units=DEGREES)
self.set_euler_angles(theta_degrees, phi_degrees, gamma_degrees, units=DEG)
if center is not None:
self.move_to(np.array(center))
if height is not None:
@@ -209,7 +209,7 @@ def increment_gamma(self, dgamma: float, units=RADIANS):
self.increment_euler_angles(dgamma=dgamma, units=units)
return self

def add_ambient_rotation(self, angular_speed=1 * DEGREES):
def add_ambient_rotation(self, angular_speed=1 * DEG):
self.add_updater(lambda m, dt: m.increment_theta(angular_speed * dt))
return self

5 changes: 3 additions & 2 deletions manimlib/constants.py
Original file line number Diff line number Diff line change
@@ -61,9 +61,10 @@
# Angles
PI: float = np.pi
TAU: float = 2 * PI
DEGREES: float = TAU / 360
DEG: float = TAU / 360
DEGREES = DEG # Many older animations use teh full name
# Nice to have a constant for readability
# when juxtaposed with expressions like 30 * DEGREES
# when juxtaposed with expressions like 30 * DEG
RADIANS: float = 1

# Related to Text
6 changes: 3 additions & 3 deletions manimlib/mobject/coordinate_systems.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
import itertools as it

from manimlib.constants import BLACK, BLUE, BLUE_D, BLUE_E, GREEN, GREY_A, WHITE, RED
from manimlib.constants import DEGREES, PI
from manimlib.constants import DEG, PI
from manimlib.constants import DL, UL, DOWN, DR, LEFT, ORIGIN, OUT, RIGHT, UP
from manimlib.constants import FRAME_X_RADIUS, FRAME_Y_RADIUS
from manimlib.constants import MED_SMALL_BUFF, SMALL_BUFF
@@ -307,7 +307,7 @@ def get_graph_label(

point = self.input_to_graph_point(x, graph)
angle = self.angle_of_tangent(x, graph)
normal = rotate_vector(RIGHT, angle + 90 * DEGREES)
normal = rotate_vector(RIGHT, angle + 90 * DEG)
if normal[1] < 0:
normal *= -1
label.next_to(point, normal, buff=buff)
@@ -474,7 +474,7 @@ def __init__(
),
length=height,
)
self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
self.y_axis.rotate(90 * DEG, about_point=ORIGIN)
# Add as a separate group in case various other
# mobjects are added to self, as for example in
# NumberPlane below
4 changes: 2 additions & 2 deletions manimlib/mobject/geometry.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
from manimlib.constants import DL, DOWN, DR, LEFT, ORIGIN, OUT, RIGHT, UL, UP, UR
from manimlib.constants import GREY_A, RED, WHITE, BLACK
from manimlib.constants import MED_SMALL_BUFF, SMALL_BUFF
from manimlib.constants import DEGREES, PI, TAU
from manimlib.constants import DEG, PI, TAU
from manimlib.mobject.mobject import Mobject
from manimlib.mobject.types.vectorized_mobject import DashedVMobject
from manimlib.mobject.types.vectorized_mobject import VGroup
@@ -983,7 +983,7 @@ def __init__(
):
# Defaults to 0 for odd, 90 for even
if start_angle is None:
start_angle = (n % 2) * 90 * DEGREES
start_angle = (n % 2) * 90 * DEG
start_vect = rotate_vector(radius * RIGHT, start_angle)
vertices = compass_directions(n, start_vect)
super().__init__(*vertices, **kwargs)
4 changes: 2 additions & 2 deletions manimlib/mobject/matrix.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import numpy as np

from manimlib.constants import DOWN, LEFT, RIGHT, ORIGIN
from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.mobject.numbers import DecimalNumber
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.types.vectorized_mobject import VGroup
@@ -196,7 +196,7 @@ def swap_entries_for_ellipses(
dots.set_width(hdots_width)
self.swap_entry_for_dots(row[col_index], dots)
if use_vdots and use_hdots:
rows[row_index][col_index].rotate(-45 * DEGREES)
rows[row_index][col_index].rotate(-45 * DEG)
return self

def get_mob_matrix(self) -> VMobjectMatrixType:
4 changes: 2 additions & 2 deletions manimlib/mobject/mobject_update_utils.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import inspect

from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.constants import RIGHT
from manimlib.mobject.mobject import Mobject
from manimlib.utils.simple_functions import clip
@@ -71,7 +71,7 @@ def always_shift(

def always_rotate(
mobject: Mobject,
rate: float = 20 * DEGREES,
rate: float = 20 * DEG,
**kwargs
) -> Mobject:
mobject.add_updater(
8 changes: 4 additions & 4 deletions manimlib/mobject/types/vectorized_mobject.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
from manimlib.constants import GREY_A, GREY_C, GREY_E
from manimlib.constants import BLACK
from manimlib.constants import DEFAULT_STROKE_WIDTH
from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.constants import ORIGIN, OUT
from manimlib.constants import PI
from manimlib.constants import TAU
@@ -490,7 +490,7 @@ def add_cubic_bezier_curve_to(
v1 = handle1 - last
v2 = anchor - handle2
angle = angle_between_vectors(v1, v2)
if self.use_simple_quadratic_approx and angle < 45 * DEGREES:
if self.use_simple_quadratic_approx and angle < 45 * DEG:
quad_approx = [last, find_intersection(last, v1, anchor, -v2), anchor]
else:
quad_approx = get_quadratic_approximation_of_cubic(
@@ -616,7 +616,7 @@ def subdivide_curves_by_condition(

def subdivide_sharp_curves(
self,
angle_threshold: float = 30 * DEGREES,
angle_threshold: float = 30 * DEG,
recurse: bool = True
) -> Self:
def tuple_to_subdivisions(b0, b1, b2):
@@ -656,7 +656,7 @@ def set_points_smoothly(
self.make_smooth(approx=approx)
return self

def is_smooth(self, angle_tol=1 * DEGREES) -> bool:
def is_smooth(self, angle_tol=1 * DEG) -> bool:
angles = np.abs(self.get_joint_angles()[0::2])
return (angles < angle_tol).all()

4 changes: 2 additions & 2 deletions manimlib/scene/interactive_scene.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
from manimlib.constants import DL, DOWN, DR, LEFT, ORIGIN, RIGHT, UL, UP, UR
from manimlib.constants import FRAME_WIDTH, FRAME_HEIGHT, SMALL_BUFF
from manimlib.constants import PI
from manimlib.constants import DEGREES
from manimlib.constants import DEG
from manimlib.constants import MANIM_COLORS, WHITE, GREY_A, GREY_C
from manimlib.mobject.geometry import Line
from manimlib.mobject.geometry import Rectangle
@@ -625,7 +625,7 @@ def copy_frame_positioning(self):
angles = frame.get_euler_angles()

call = f"reorient("
theta, phi, gamma = (angles / DEGREES).astype(int)
theta, phi, gamma = (angles / DEG).astype(int)
call += f"{theta}, {phi}, {gamma}"
if any(center != 0):
call += f", {tuple(np.round(center, 2))}"

0 comments on commit 8cc5195

Please sign in to comment.