@@ -24,6 +24,8 @@ class Equilibrium:
2424 --------
2525 >>> import numpy as np
2626 >>> eq = Equilibrium(margin_mm=120, y_weight=0.6)
27+
28+ # Using 3D coordinates
2729 >>> left = np.array([0, 0, 0])
2830 >>> right = np.array([400, 0, 0])
2931 >>> barycenter = np.array([200, 50, 0])
@@ -32,6 +34,16 @@ class Equilibrium:
3234 0.91
3335 >>> round(angle, 1)
3436 0.0
37+
38+ # Using 2D coordinates (z is optional)
39+ >>> left_2d = np.array([0, 0])
40+ >>> right_2d = np.array([400, 0])
41+ >>> barycenter_2d = np.array([200, 50])
42+ >>> value_2d, angle_2d = eq(left_2d, right_2d, barycenter_2d)
43+ >>> round(value_2d, 2)
44+ 0.91
45+ >>> round(angle_2d, 1)
46+ 0.0
3547 """
3648
3749 def __init__ (self , margin_mm = 100 , y_weight = 0.5 ):
@@ -44,14 +56,14 @@ def __call__(self, left_foot: np.ndarray, right_foot: np.ndarray, barycenter: np
4456
4557 Parameters
4658 ----------
47- left_foot : numpy.ndarray, shape (3,)
48- 3D coordinates (x, y, z) of the left foot in millimeters.
59+ left_foot : numpy.ndarray, shape (2,) or ( 3,)
60+ 2D coordinates (x, y) or 3D coordinates (x, y, z) of the left foot in millimeters.
4961 Only the x and y components are used.
50- right_foot : numpy.ndarray, shape (3,)
51- 3D coordinates (x, y, z) of the right foot in millimeters.
62+ right_foot : numpy.ndarray, shape (2,) or ( 3,)
63+ 2D coordinates (x, y) or 3D coordinates (x, y, z) of the right foot in millimeters.
5264 Only the x and y components are used.
53- barycenter : numpy.ndarray, shape (3,)
54- 3D coordinates (x, y, z) of the barycenter in millimeters.
65+ barycenter : numpy.ndarray, shape (2,) or ( 3,)
66+ 2D coordinates (x, y) or 3D coordinates (x, y, z) of the barycenter in millimeters.
5567 Only the x and y components are used.
5668
5769 Returns
@@ -70,10 +82,13 @@ def __call__(self, left_foot: np.ndarray, right_foot: np.ndarray, barycenter: np
7082 - The ellipse width corresponds to the horizontal foot span + margin.
7183 - The ellipse height corresponds to the vertical span + margin,
7284 scaled by `y_weight`.
85+ - If 3D coordinates are provided, the z component is ignored.
7386 """
74- ps = np .array (left_foot )[:2 ]
75- pd = np .array (right_foot )[:2 ]
76- bc = np .array (barycenter )[:2 ]
87+ # Convert to numpy arrays and extract x,y components
88+ # Works for both 2D (x,y) and 3D (x,y,z) inputs
89+ ps = np .atleast_1d (left_foot ).flatten ()[:2 ]
90+ pd = np .atleast_1d (right_foot ).flatten ()[:2 ]
91+ bc = np .atleast_1d (barycenter ).flatten ()[:2 ]
7792
7893 min_xy = np .minimum (ps , pd ) - self .margin
7994 max_xy = np .maximum (ps , pd ) + self .margin
0 commit comments