Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions spatialmath/base/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ def __init__(

:param ax: the axes to plot into, defaults to current axes
:type ax: Axes3D reference
:param dim: dimension of plot volume as [xmin, xmax, ymin, ymax,
zmin, zmax]. If dims is [min, max] those limits are applied
to the x-, y- and z-axes.
:type dim: array_like(6) or array_like(2)
:param dim: dimension of plot volume, using the same shorthand as
``plotvol3``: a scalar ``A`` gives ``[-A,A]`` on every axis, a
2-vector ``[A,B]`` gives ``[A,B]`` on every axis, and a 6-vector
gives ``[xmin, xmax, ymin, ymax, zmin, zmax]`` explicitly.
:type dim: scalar, array_like(2) or array_like(6)
:param projection: 3D projection: ortho [default] or persp
:type projection: str
:param labels: labels for the axes, defaults to X, Y and Z
Expand Down Expand Up @@ -105,13 +106,9 @@ def __init__(
# # ax.set_aspect('equal')
ax = smb.plotvol3(ax=ax, dim=dim)
if dim is not None:
dim = list(np.ndarray.flatten(np.array(dim)))
if len(dim) == 2:
dim = dim * 3
elif len(dim) != 6:
raise ValueError(
f"dim must have 2 or 6 elements, got {dim}. See docstring for details."
)
# same shorthand as plotvol3: scalar A -> [-A,A]*3, [A,B] -> [A,B]*3,
# or a full [xmin,xmax,ymin,ymax,zmin,zmax]
dim = smb.expand_dims(dim, nd=3)
ax.set_xlim(dim[0:2])
ax.set_ylim(dim[2:4])
ax.set_zlim(dim[4:])
Expand Down
8 changes: 5 additions & 3 deletions spatialmath/base/transforms3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3402,8 +3402,8 @@ def tranimate(T: Union[SO3Array, SE3Array], **kwargs) -> str:

Examples:

>>> tranimate(transl(1,2,3)@trotx(1), frame='A', arrow=False, dims=[0, 5])
>>> tranimate(transl(1,2,3)@trotx(1), frame='A', arrow=False, dims=[0, 5], movie='spin.mp4')
>>> tranimate(transl(1,2,3)@trotx(1), frame='A', arrow=False, dim=[0, 5])
>>> tranimate(transl(1,2,3)@trotx(1), frame='A', arrow=False, dim=[0, 5], movie='spin.mp4')

.. note:: For Jupyter this works with the ``notebook`` and ``TkAgg``
backends.
Expand All @@ -3419,7 +3419,9 @@ def tranimate(T: Union[SO3Array, SE3Array], **kwargs) -> str:

:seealso: `trplot`, `plotvol3`
"""
dim = kwargs.pop("dims", None)
# accept dim (matches Animate/plotvol2/plotvol3), keep dims as an
# alias for backward compatibility with the previous docstring/API
dim = kwargs.pop("dim", kwargs.pop("dims", None))
ax = kwargs.pop("ax", None)
anim = Animate(dim=dim, ax=ax, **kwargs)
anim.trplot(T, **kwargs)
Expand Down
Loading