Skip to content

Commit 3e5738c

Browse files
committed
allow T to be an iterable, list or generator
1 parent 6289d3f commit 3e5738c

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎spatialmath/base/transforms3d.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ def trplot(T, axes=None, block=False, dims=None, color='blue', frame=None, # p
16811681
Plot a 3D coordinate frame
16821682
16831683
:param T: SE(3) or SO(3) matrix
1684-
:type T: ndarray(4,4) or ndarray(3,3)
1684+
:type T: ndarray(4,4) or ndarray(3,3) or an iterable returning
16851685
:param axes: the axes to plot into, defaults to current axes
16861686
:type axes: Axes3D reference
16871687
:param block: run the GUI main loop until all windows are closed, default True
@@ -1738,11 +1738,6 @@ def trplot(T, axes=None, block=False, dims=None, color='blue', frame=None, # p
17381738
print('matplotlib is not installed: pip install matplotlib')
17391739
return
17401740

1741-
# check input types
1742-
if isrot(T, check=True):
1743-
T = base.r2t(T)
1744-
elif not ishom(T, check=True):
1745-
raise ValueError("not a valid SE(3) matrix")
17461741

17471742
if axes is None:
17481743
# create an axes
@@ -1762,6 +1757,20 @@ def trplot(T, axes=None, block=False, dims=None, color='blue', frame=None, # p
17621757
else:
17631758
ax = axes
17641759

1760+
# check input types
1761+
if isrot(T, check=True):
1762+
T = base.r2t(T)
1763+
elif ishom(T, check=True):
1764+
pass
1765+
else:
1766+
# assume it is an interable
1767+
for Tk in T:
1768+
trplot(Tk, axes=ax, block=block, dims=dims, color=color, frame=frame,
1769+
textcolor=textcolor, labels=labels, length=length, style=style,
1770+
projection=projection, wtl=wtl, width=width, d1=d1,
1771+
d2=d2, anaglyph=anaglyph, **kwargs)
1772+
return
1773+
17651774
if dims is not None:
17661775
if len(dims) == 2:
17671776
dims = dims * 3

0 commit comments

Comments
 (0)