Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add PiCreature.get_look_at_spot

Grant Sandersonaa5ac955571c
diff --git a/manimlib/for_3b1b_videos/pi_creature.py b/manimlib/for_3b1b_videos/pi_creature.py
index 429868e98..fa3864d33 100644
--- a/manimlib/for_3b1b_videos/pi_creature.py
+++ b/manimlib/for_3b1b_videos/pi_creature.py
@@ -3,7 +3,6 @@ import warnings
import numpy as np
-from manimlib.animation.transform import Transform
from manimlib.constants import *
from manimlib.mobject.mobject import Mobject
from manimlib.mobject.geometry import Circle
@@ -14,6 +13,7 @@ from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.utils.config_ops import digest_config
from manimlib.utils.space_ops import get_norm
+from manimlib.utils.space_ops import normalize
pi_creature_dir_maybe = os.path.join(MEDIA_DIR, "designs", "PiCreature")
if os.path.exists(pi_creature_dir_maybe):
@@ -197,10 +197,11 @@ class PiCreature(SVGMobject):
return self
def get_looking_direction(self):
- return np.sign(np.round(
- self.pupils.get_center() - self.eyes.get_center(),
- decimals=2
- ))
+ vect = self.pupils.get_center() - self.eyes.get_center()
+ return normalize(vect)
+
+ def get_look_at_spot(self):
+ return self.eyes.get_center() + self.get_looking_direction()
def is_flipped(self):
return self.eyes.submobjects[0].get_center()[0] > \