22from itertools import product
33import warnings
44import numpy as np
5- import scipy as sp
65from matplotlib import colors
76
87from spatialmath import base as smbase
@@ -574,6 +573,8 @@ def ellipse(E, centre=(0, 0), scale=1, confidence=None, resolution=40, inverted=
574573 so to avoid inverting ``E`` twice to compute the ellipse, we flag that
575574 the inverse is provided using ``inverted``.
576575 """
576+ from scipy .linalg import sqrtm
577+
577578 if E .shape != (2 , 2 ):
578579 raise ValueError ("ellipse is defined by a 2x2 matrix" )
579580
@@ -590,7 +591,7 @@ def ellipse(E, centre=(0, 0), scale=1, confidence=None, resolution=40, inverted=
590591 if not inverted :
591592 E = np .linalg .inv (E )
592593
593- e = s * sp . linalg . sqrtm (E ) @ xy + np .array (centre , ndmin = 2 ).T
594+ e = s * sqrtm (E ) @ xy + np .array (centre , ndmin = 2 ).T
594595 return e
595596
596597
@@ -766,6 +767,8 @@ def ellipsoid(
766767
767768 :seealso: :func:`plot_ellipsoid`, :func:`~matplotlib.pyplot.plot_surface`, :func:`~matplotlib.pyplot.plot_wireframe`
768769 """
770+ from scipy .linalg import sqrtm
771+
769772 if E .shape != (3 , 3 ):
770773 raise ValueError ("ellipsoid is defined by a 3x3 matrix" )
771774
@@ -782,7 +785,7 @@ def ellipsoid(
782785
783786 x , y , z = sphere () # unit sphere
784787 e = (
785- s * sp . linalg . sqrtm (E ) @ np .array ([x .flatten (), y .flatten (), z .flatten ()])
788+ s * sqrtm (E ) @ np .array ([x .flatten (), y .flatten (), z .flatten ()])
786789 + np .c_ [centre ].T
787790 )
788791 return e [0 , :].reshape (x .shape ), e [1 , :].reshape (x .shape ), e [2 , :].reshape (x .shape )
0 commit comments