mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Replace DEGREES -> DEG
This commit is contained in:
parent
d8e06c614d
commit
8cc51956dd
13 changed files with 38 additions and 37 deletions
|
@ -74,7 +74,7 @@ Mathematical constant
|
|||
|
||||
PI = np.pi
|
||||
TAU = 2 * PI
|
||||
DEGREES = TAU / 360
|
||||
DEG = TAU / 360
|
||||
|
||||
Text
|
||||
----
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -190,7 +190,7 @@ class TexTransformExample(Scene):
|
|||
# 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 @@ class TexTransformExample(Scene):
|
|||
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 @@ class SurfaceExample(ThreeDScene):
|
|||
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 @@ class InteractiveDevelopment(Scene):
|
|||
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("""
|
||||
|
|
|
@ -14,7 +14,7 @@ from manimlib.animation.transform import Transform
|
|||
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 @@ class WiggleOutThenIn(Animation):
|
|||
|
||||
|
||||
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:
|
||||
|
|
|
@ -5,7 +5,7 @@ import inspect
|
|||
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 @@ class ApplyComplexFunction(ApplyMethod):
|
|||
|
||||
|
||||
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:
|
||||
|
|
|
@ -6,7 +6,7 @@ import warnings
|
|||
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 @@ class CameraFrame(Mobject):
|
|||
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 @@ class CameraFrame(Mobject):
|
|||
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 @@ class CameraFrame(Mobject):
|
|||
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
|
||||
|
||||
|
|
|
@ -61,9 +61,10 @@ RIGHT_SIDE: Vect3 = FRAME_X_RADIUS * RIGHT
|
|||
# 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
|
||||
|
|
|
@ -7,7 +7,7 @@ import numpy as np
|
|||
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 @@ class CoordinateSystem(ABC):
|
|||
|
||||
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 @@ class Axes(VGroup, CoordinateSystem):
|
|||
),
|
||||
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
|
||||
|
|
|
@ -7,7 +7,7 @@ import numpy as np
|
|||
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 @@ class RegularPolygon(Polygon):
|
|||
):
|
||||
# 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)
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
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 @@ class Matrix(VMobject):
|
|||
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:
|
||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
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(
|
||||
|
|
|
@ -7,7 +7,7 @@ import numpy as np
|
|||
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 @@ class VMobject(Mobject):
|
|||
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 @@ class VMobject(Mobject):
|
|||
|
||||
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 @@ class VMobject(Mobject):
|
|||
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()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from manimlib.config import manim_config
|
|||
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 @@ class InteractiveScene(Scene):
|
|||
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))}"
|
||||
|
|
Loading…
Add table
Reference in a new issue