mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Add Mobject.has_same_shape_as
This commit is contained in:
parent
9018357d20
commit
3738f0a48e
1 changed files with 10 additions and 0 deletions
|
@ -671,6 +671,16 @@ class Mobject(object):
|
|||
return False
|
||||
return True
|
||||
|
||||
def has_same_shape_as(self, mobject: Mobject) -> bool:
|
||||
# Normalize both point sets by centering and making height 1
|
||||
points1, points2 = (
|
||||
(m.get_all_points() - m.get_center()) / m.get_height()
|
||||
for m in (self, mobject)
|
||||
)
|
||||
if len(points1) != len(points2):
|
||||
return False
|
||||
return bool(np.isclose(points1, points2).all())
|
||||
|
||||
# Creating new Mobjects from this one
|
||||
|
||||
def replicate(self, n: int) -> Group:
|
||||
|
|
Loading…
Add table
Reference in a new issue