54
54
Point3D ,
55
55
Point3DLike ,
56
56
Point3DLike_Array ,
57
- Vector3D ,
57
+ Vector3DLike ,
58
58
)
59
59
60
60
from ..animation .animation import Animation
@@ -1204,7 +1204,7 @@ def apply_to_family(self, func: Callable[[Mobject], None]) -> None:
1204
1204
for mob in self .family_members_with_points ():
1205
1205
func (mob )
1206
1206
1207
- def shift (self , * vectors : Vector3D ) -> Self :
1207
+ def shift (self , * vectors : Vector3DLike ) -> Self :
1208
1208
"""Shift by the given vectors.
1209
1209
1210
1210
Parameters
@@ -1275,14 +1275,14 @@ def construct(self):
1275
1275
)
1276
1276
return self
1277
1277
1278
- def rotate_about_origin (self , angle : float , axis : Vector3D = OUT , axes = [] ) -> Self :
1278
+ def rotate_about_origin (self , angle : float , axis : Vector3DLike = OUT ) -> Self :
1279
1279
"""Rotates the :class:`~.Mobject` about the ORIGIN, which is at [0,0,0]."""
1280
1280
return self .rotate (angle , axis , about_point = ORIGIN )
1281
1281
1282
1282
def rotate (
1283
1283
self ,
1284
1284
angle : float ,
1285
- axis : Vector3D = OUT ,
1285
+ axis : Vector3DLike = OUT ,
1286
1286
about_point : Point3DLike | None = None ,
1287
1287
** kwargs ,
1288
1288
) -> Self :
@@ -1350,7 +1350,7 @@ def construct(self):
1350
1350
)
1351
1351
return self
1352
1352
1353
- def flip (self , axis : Vector3D = UP , ** kwargs ) -> Self :
1353
+ def flip (self , axis : Vector3DLike = UP , ** kwargs ) -> Self :
1354
1354
"""Flips/Mirrors an mobject about its center.
1355
1355
1356
1356
Examples
@@ -1470,7 +1470,7 @@ def apply_points_function_about_point(
1470
1470
self ,
1471
1471
func : MultiMappingFunction ,
1472
1472
about_point : Point3DLike | None = None ,
1473
- about_edge : Vector3D | None = None ,
1473
+ about_edge : Vector3DLike | None = None ,
1474
1474
) -> Self :
1475
1475
if about_point is None :
1476
1476
if about_edge is None :
@@ -1500,7 +1500,7 @@ def center(self) -> Self:
1500
1500
return self
1501
1501
1502
1502
def align_on_border (
1503
- self , direction : Vector3D , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1503
+ self , direction : Vector3DLike , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1504
1504
) -> Self :
1505
1505
"""Direction just needs to be a vector pointing towards side or
1506
1506
corner in the 2d plane.
@@ -1517,7 +1517,7 @@ def align_on_border(
1517
1517
return self
1518
1518
1519
1519
def to_corner (
1520
- self , corner : Vector3D = DL , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1520
+ self , corner : Vector3DLike = DL , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1521
1521
) -> Self :
1522
1522
"""Moves this :class:`~.Mobject` to the given corner of the screen.
1523
1523
@@ -1545,7 +1545,7 @@ def construct(self):
1545
1545
return self .align_on_border (corner , buff )
1546
1546
1547
1547
def to_edge (
1548
- self , edge : Vector3D = LEFT , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1548
+ self , edge : Vector3DLike = LEFT , buff : float = DEFAULT_MOBJECT_TO_EDGE_BUFFER
1549
1549
) -> Self :
1550
1550
"""Moves this :class:`~.Mobject` to the given edge of the screen,
1551
1551
without affecting its position in the other dimension.
@@ -1577,12 +1577,12 @@ def construct(self):
1577
1577
def next_to (
1578
1578
self ,
1579
1579
mobject_or_point : Mobject | Point3DLike ,
1580
- direction : Vector3D = RIGHT ,
1580
+ direction : Vector3DLike = RIGHT ,
1581
1581
buff : float = DEFAULT_MOBJECT_TO_MOBJECT_BUFFER ,
1582
- aligned_edge : Vector3D = ORIGIN ,
1582
+ aligned_edge : Vector3DLike = ORIGIN ,
1583
1583
submobject_to_align : Mobject | None = None ,
1584
1584
index_of_submobject_to_align : int | None = None ,
1585
- coor_mask : Vector3D = np .array ([1 , 1 , 1 ]),
1585
+ coor_mask : Vector3DLike = np .array ([1 , 1 , 1 ]),
1586
1586
) -> Self :
1587
1587
"""Move this :class:`~.Mobject` next to another's :class:`~.Mobject` or Point3D.
1588
1588
@@ -1604,13 +1604,18 @@ def construct(self):
1604
1604
self.add(d, c, s, t)
1605
1605
1606
1606
"""
1607
+ np_direction = np .asarray (direction )
1608
+ np_aligned_edge = np .asarray (aligned_edge )
1609
+
1607
1610
if isinstance (mobject_or_point , Mobject ):
1608
1611
mob = mobject_or_point
1609
1612
if index_of_submobject_to_align is not None :
1610
1613
target_aligner = mob [index_of_submobject_to_align ]
1611
1614
else :
1612
1615
target_aligner = mob
1613
- target_point = target_aligner .get_critical_point (aligned_edge + direction )
1616
+ target_point = target_aligner .get_critical_point (
1617
+ np_aligned_edge + np_direction
1618
+ )
1614
1619
else :
1615
1620
target_point = mobject_or_point
1616
1621
if submobject_to_align is not None :
@@ -1619,8 +1624,8 @@ def construct(self):
1619
1624
aligner = self [index_of_submobject_to_align ]
1620
1625
else :
1621
1626
aligner = self
1622
- point_to_align = aligner .get_critical_point (aligned_edge - direction )
1623
- self .shift ((target_point - point_to_align + buff * direction ) * coor_mask )
1627
+ point_to_align = aligner .get_critical_point (np_aligned_edge - np_direction )
1628
+ self .shift ((target_point - point_to_align + buff * np_direction ) * coor_mask )
1624
1629
return self
1625
1630
1626
1631
def shift_onto_screen (self , ** kwargs ) -> Self :
@@ -1766,22 +1771,22 @@ def stretch_to_fit_depth(self, depth: float, **kwargs) -> Self:
1766
1771
"""Stretches the :class:`~.Mobject` to fit a depth, not keeping width/height proportional."""
1767
1772
return self .rescale_to_fit (depth , 2 , stretch = True , ** kwargs )
1768
1773
1769
- def set_coord (self , value , dim : int , direction : Vector3D = ORIGIN ) -> Self :
1774
+ def set_coord (self , value , dim : int , direction : Vector3DLike = ORIGIN ) -> Self :
1770
1775
curr = self .get_coord (dim , direction )
1771
1776
shift_vect = np .zeros (self .dim )
1772
1777
shift_vect [dim ] = value - curr
1773
1778
self .shift (shift_vect )
1774
1779
return self
1775
1780
1776
- def set_x (self , x : float , direction : Vector3D = ORIGIN ) -> Self :
1781
+ def set_x (self , x : float , direction : Vector3DLike = ORIGIN ) -> Self :
1777
1782
"""Set x value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
1778
1783
return self .set_coord (x , 0 , direction )
1779
1784
1780
- def set_y (self , y : float , direction : Vector3D = ORIGIN ) -> Self :
1785
+ def set_y (self , y : float , direction : Vector3DLike = ORIGIN ) -> Self :
1781
1786
"""Set y value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
1782
1787
return self .set_coord (y , 1 , direction )
1783
1788
1784
- def set_z (self , z : float , direction : Vector3D = ORIGIN ) -> Self :
1789
+ def set_z (self , z : float , direction : Vector3DLike = ORIGIN ) -> Self :
1785
1790
"""Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)"""
1786
1791
return self .set_coord (z , 2 , direction )
1787
1792
@@ -1794,8 +1799,8 @@ def space_out_submobjects(self, factor: float = 1.5, **kwargs) -> Self:
1794
1799
def move_to (
1795
1800
self ,
1796
1801
point_or_mobject : Point3DLike | Mobject ,
1797
- aligned_edge : Vector3D = ORIGIN ,
1798
- coor_mask : Vector3D = np .array ([1 , 1 , 1 ]),
1802
+ aligned_edge : Vector3DLike = ORIGIN ,
1803
+ coor_mask : Vector3DLike = np .array ([1 , 1 , 1 ]),
1799
1804
) -> Self :
1800
1805
"""Move center of the :class:`~.Mobject` to certain Point3D."""
1801
1806
if isinstance (point_or_mobject , Mobject ):
@@ -2114,7 +2119,7 @@ def get_extremum_along_dim(
2114
2119
else :
2115
2120
return np .max (values )
2116
2121
2117
- def get_critical_point (self , direction : Vector3D ) -> Point3D :
2122
+ def get_critical_point (self , direction : Vector3DLike ) -> Point3D :
2118
2123
"""Picture a box bounding the :class:`~.Mobject`. Such a box has
2119
2124
9 'critical points': 4 corners, 4 edge center, the
2120
2125
center. This returns one of them, along the given direction.
@@ -2143,11 +2148,11 @@ def get_critical_point(self, direction: Vector3D) -> Point3D:
2143
2148
2144
2149
# Pseudonyms for more general get_critical_point method
2145
2150
2146
- def get_edge_center (self , direction : Vector3D ) -> Point3D :
2151
+ def get_edge_center (self , direction : Vector3DLike ) -> Point3D :
2147
2152
"""Get edge Point3Ds for certain direction."""
2148
2153
return self .get_critical_point (direction )
2149
2154
2150
- def get_corner (self , direction : Vector3D ) -> Point3D :
2155
+ def get_corner (self , direction : Vector3DLike ) -> Point3D :
2151
2156
"""Get corner Point3Ds for certain direction."""
2152
2157
return self .get_critical_point (direction )
2153
2158
@@ -2158,9 +2163,9 @@ def get_center(self) -> Point3D:
2158
2163
def get_center_of_mass (self ) -> Point3D :
2159
2164
return np .apply_along_axis (np .mean , 0 , self .get_all_points ())
2160
2165
2161
- def get_boundary_point (self , direction : Vector3D ) -> Point3D :
2166
+ def get_boundary_point (self , direction : Vector3DLike ) -> Point3D :
2162
2167
all_points = self .get_points_defining_boundary ()
2163
- index = np .argmax (np .dot (all_points , np . array ( direction ). T ))
2168
+ index = np .argmax (np .dot (all_points , direction ))
2164
2169
return all_points [index ]
2165
2170
2166
2171
def get_midpoint (self ) -> Point3D :
@@ -2217,19 +2222,19 @@ def length_over_dim(self, dim: int) -> float:
2217
2222
dim ,
2218
2223
) - self .reduce_across_dimension (min , dim )
2219
2224
2220
- def get_coord (self , dim : int , direction : Vector3D = ORIGIN ):
2225
+ def get_coord (self , dim : int , direction : Vector3DLike = ORIGIN ) -> float :
2221
2226
"""Meant to generalize ``get_x``, ``get_y`` and ``get_z``"""
2222
2227
return self .get_extremum_along_dim (dim = dim , key = direction [dim ])
2223
2228
2224
- def get_x (self , direction : Vector3D = ORIGIN ) -> float :
2229
+ def get_x (self , direction : Vector3DLike = ORIGIN ) -> float :
2225
2230
"""Returns x Point3D of the center of the :class:`~.Mobject` as ``float``"""
2226
2231
return self .get_coord (0 , direction )
2227
2232
2228
- def get_y (self , direction : Vector3D = ORIGIN ) -> float :
2233
+ def get_y (self , direction : Vector3DLike = ORIGIN ) -> float :
2229
2234
"""Returns y Point3D of the center of the :class:`~.Mobject` as ``float``"""
2230
2235
return self .get_coord (1 , direction )
2231
2236
2232
- def get_z (self , direction : Vector3D = ORIGIN ) -> float :
2237
+ def get_z (self , direction : Vector3DLike = ORIGIN ) -> float :
2233
2238
"""Returns z Point3D of the center of the :class:`~.Mobject` as ``float``"""
2234
2239
return self .get_coord (2 , direction )
2235
2240
@@ -2300,7 +2305,7 @@ def match_depth(self, mobject: Mobject, **kwargs) -> Self:
2300
2305
return self .match_dim_size (mobject , 2 , ** kwargs )
2301
2306
2302
2307
def match_coord (
2303
- self , mobject : Mobject , dim : int , direction : Vector3D = ORIGIN
2308
+ self , mobject : Mobject , dim : int , direction : Vector3DLike = ORIGIN
2304
2309
) -> Self :
2305
2310
"""Match the Point3Ds with the Point3Ds of another :class:`~.Mobject`."""
2306
2311
return self .set_coord (
@@ -2324,7 +2329,7 @@ def match_z(self, mobject: Mobject, direction=ORIGIN) -> Self:
2324
2329
def align_to (
2325
2330
self ,
2326
2331
mobject_or_point : Mobject | Point3DLike ,
2327
- direction : Vector3D = ORIGIN ,
2332
+ direction : Vector3DLike = ORIGIN ,
2328
2333
) -> Self :
2329
2334
"""Aligns mobject to another :class:`~.Mobject` in a certain direction.
2330
2335
@@ -2431,7 +2436,7 @@ def family_members_with_points(self) -> list[Self]:
2431
2436
2432
2437
def arrange (
2433
2438
self ,
2434
- direction : Vector3D = RIGHT ,
2439
+ direction : Vector3DLike = RIGHT ,
2435
2440
buff : float = DEFAULT_MOBJECT_TO_MOBJECT_BUFFER ,
2436
2441
center : bool = True ,
2437
2442
** kwargs ,
@@ -2464,7 +2469,7 @@ def arrange_in_grid(
2464
2469
rows : int | None = None ,
2465
2470
cols : int | None = None ,
2466
2471
buff : float | tuple [float , float ] = MED_SMALL_BUFF ,
2467
- cell_alignment : Vector3D = ORIGIN ,
2472
+ cell_alignment : Vector3DLike = ORIGIN ,
2468
2473
row_alignments : str | None = None , # "ucd"
2469
2474
col_alignments : str | None = None , # "lcr"
2470
2475
row_heights : Iterable [float | None ] | None = None ,
0 commit comments