Skip to content

Commit 6289d3f

Browse files
committed
use style option rather than 2 boolean options
1 parent 9fd44ba commit 6289d3f

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎spatialmath/base/transforms3d.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,18 +1699,19 @@ def trplot(T, axes=None, block=False, dims=None, color='blue', frame=None, # p
16991699
:type labels: 3-tuple of strings
17001700
:param length: length of coordinate frame axes, default 1
17011701
:type length: float
1702-
:param arrow: show arrow heads, default True
1703-
:type arrow: bool
1702+
:param style: axis style: 'arrow' [default], 'line', 'rgb' (Rviz style)
1703+
:type style: str
17041704
:param wtl: width-to-length ratio for arrows, default 0.2
17051705
:type wtl: float
1706-
:param rviz: show Rviz style arrows, default False
1707-
:type rviz: bool
17081706
:param projection: 3D projection: ortho [default] or persp
17091707
:type projection: str
17101708
:param width: width of lines, default 1
17111709
:type width: float
17121710
:param d1: distance of frame axis label text from origin, default 1.15
17131711
:type d2: distance of frame label text from origin, default 0.05
1712+
:param anaglyph: 3D anaglyph display, a pair of single letter color codes
1713+
for left then right lens.
1714+
:type anaglyph: True (for red-cyan glasses) or str
17141715
:return: axes containing the frame
17151716
:rtype: Axes3DSubplot
17161717
:raises ValueError: bad arguments
@@ -1776,17 +1777,17 @@ def trplot(T, axes=None, block=False, dims=None, color='blue', frame=None, # p
17761777

17771778
# draw the axes
17781779

1779-
if rviz:
1780-
ax.plot([o[0], x[0]], [o[1], x[1]], [o[2], x[2]], color='red', linewidth=5 * width)
1781-
ax.plot([o[0], y[0]], [o[1], y[1]], [o[2], y[2]], color='lime', linewidth=5 * width)
1782-
ax.plot([o[0], z[0]], [o[1], z[1]], [o[2], z[2]], color='blue', linewidth=5 * width)
1783-
elif arrow:
1780+
if style == 'rgb':
1781+
ax.plot([o[0], x[0]], [o[1], x[1]], [o[2], x[2]], color='red', linewidth=width)
1782+
ax.plot([o[0], y[0]], [o[1], y[1]], [o[2], y[2]], color='lime', linewidth=width)
1783+
ax.plot([o[0], z[0]], [o[1], z[1]], [o[2], z[2]], color='blue', linewidth=width)
1784+
elif style == 'arrow':
17841785
ax.quiver(o[0], o[1], o[2], x[0] - o[0], x[1] - o[1], x[2] - o[2], arrow_length_ratio=wtl, linewidth=width, facecolor=color, edgecolor=color)
17851786
ax.quiver(o[0], o[1], o[2], y[0] - o[0], y[1] - o[1], y[2] - o[2], arrow_length_ratio=wtl, linewidth=width, facecolor=color, edgecolor=color)
17861787
ax.quiver(o[0], o[1], o[2], z[0] - o[0], z[1] - o[1], z[2] - o[2], arrow_length_ratio=wtl, linewidth=width, facecolor=color, edgecolor=color)
17871788
# plot an invisible point at the end of each arrow to allow auto-scaling to work
17881789
ax.scatter(xs=[o[0], x[0], y[0], z[0]], ys=[o[1], x[1], y[1], z[1]], zs=[o[2], x[2], y[2], z[2]], s=[20, 0, 0, 0])
1789-
else:
1790+
elif style == 'line':
17901791
ax.plot([o[0], x[0]], [o[1], x[1]], [o[2], x[2]], color=color, linewidth=width)
17911792
ax.plot([o[0], y[0]], [o[1], y[1]], [o[2], y[2]], color=color, linewidth=width)
17921793
ax.plot([o[0], z[0]], [o[1], z[1]], [o[2], z[2]], color=color, linewidth=width)

0 commit comments

Comments
 (0)