Skip to content

Commit cbaf873

Browse files
committed
for multivalued case return ndarray rather than list
1 parent b4a34f0 commit cbaf873

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

spatialmath/quaternion.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,13 +2218,7 @@ def angdist(self, other, metric=3):
22182218
if not isinstance(other, UnitQuaternion):
22192219
raise TypeError('bad operand')
22202220

2221-
def metric3(p, q):
2222-
x = base.norm(p - q)
2223-
y = base.norm(p + q)
2224-
if x >= y:
2225-
return 2 * math.atan(y / x)
2226-
else:
2227-
return 2 * math.atan(x / y)
2221+
22282222

22292223
if metric == 0:
22302224
measure = lambda p, q: 1 - abs(np.dot(p, q))
@@ -2233,6 +2227,15 @@ def metric3(p, q):
22332227
elif metric == 2:
22342228
measure = lambda p, q: math.acos(abs(np.dot(p, q)))
22352229
elif metric == 3:
2230+
2231+
def metric3(p, q):
2232+
x = base.norm(p - q)
2233+
y = base.norm(p + q)
2234+
if x >= y:
2235+
return 2 * math.atan(y / x)
2236+
else:
2237+
return 2 * math.atan(x / y)
2238+
22362239
measure = metric3
22372240
elif metric == 4:
22382241
measure = lambda p, q: math.acos(2 * np.dot(p, q) ** 2 - 1)
@@ -2241,7 +2244,7 @@ def metric3(p, q):
22412244
if len(ad) == 1:
22422245
return ad[0]
22432246
else:
2244-
return ad
2247+
return np.array(ad)
22452248

22462249
def SO3(self):
22472250
"""

0 commit comments

Comments
 (0)