Skip to content

Commit 4fea621

Browse files
committed
2 parents a0b8c2d + 9eda767 commit 4fea621

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎spatialmath/base/animate.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,14 @@ def set_xlabel(self, *args, **kwargs):
680680
def set_ylabel(self, *args, **kwargs):
681681
self.ax.set_ylabel(*args, **kwargs)
682682

683-
def plotvol2(dim, ax=None):
683+
def plotvol2(dim, ax=None, equal=False):
684684
"""
685685
Create 2D plot area
686686
687687
:param ax: axes of initializer, defaults to new subplot
688688
:type ax: AxesSubplot, optional
689+
:param equal: set aspect ratio to 1:1, default False
690+
:type equal: bool
689691
:return: initialized axes
690692
:rtype: AxesSubplot
691693
@@ -701,14 +703,18 @@ def plotvol2(dim, ax=None):
701703
if ax is None:
702704
ax = plt.subplot()
703705
ax.axis(dims)
706+
if equal:
707+
ax.set_aspect('equal')
704708
return ax
705709

706-
def plotvol3(dim, ax=None):
710+
def plotvol3(dim, ax=None, equal=False):
707711
"""
708712
Create 3D plot volume
709713
710714
:param ax: axes of initializer, defaults to new subplot
711715
:type ax: Axes3DSubplot, optional
716+
:param equal: set aspect ratio to 1:1:1, default False
717+
:type equal: bool
712718
:return: initialized axes
713719
:rtype: Axes3DSubplot
714720
@@ -727,6 +733,9 @@ def plotvol3(dim, ax=None):
727733
ax.set_xlim3d(dims[0], dims[1])
728734
ax.set_ylim3d(dims[2], dims[3])
729735
ax.set_zlim3d(dims[4], dims[5])
736+
737+
if equal:
738+
ax.set_aspect('equal')
730739
return ax
731740

732741
def plot_point(pos, marker='bs', text=None, ax=None, color=None, **kwargs):

‎spatialmath/pose3d.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,14 +1342,17 @@ def Tz(cls, z):
13421342
return cls([base.transl(0, 0, _z) for _z in base.getvector(z)], check=False)
13431343

13441344
@classmethod
1345-
def SO3(cls, R, check=True):
1345+
def SO3(cls, R, t=None, check=True):
13461346
if isinstance(R, SO3):
13471347
R = R.A
13481348
elif base.isrot(R, check=check):
13491349
pass
13501350
else:
13511351
raise ValueError('expecting SO3 or rotation matrix')
1352-
return cls(base.r2t(R))
1352+
if t is None:
1353+
return cls(base.r2t(R))
1354+
else:
1355+
return cls(base.rt2tr(R, t))
13531356

13541357
if __name__ == '__main__': # pragma: no cover
13551358

0 commit comments

Comments
 (0)