@@ -118,6 +118,7 @@ def trplot(self, end, start=None, **kwargs):
118118 :seealso: :func:`run`
119119
120120 """
121+ self .trajectory = None
121122 if not isinstance (end , (np .ndarray , np .generic )) and isinstance (end , Iterable ):
122123 try :
123124 if len (end ) == 1 :
@@ -143,7 +144,7 @@ def trplot(self, end, start=None, **kwargs):
143144 self .start = start
144145
145146 # draw axes at the origin
146- base .trplot (self .start , axes = self , ** kwargs )
147+ base .trplot (self .start , ax = self , ** kwargs )
147148
148149 def run (
149150 self ,
@@ -280,8 +281,9 @@ def _draw(self, T):
280281
281282 class _Line :
282283 def __init__ (self , anim , h , xs , ys , zs ):
283- # form 4x2 matrix, columns are first/last point in homogeneous form
284- self .p = np .vstack ([xs , ys , zs , [1 , 1 ]])
284+ # form 4xN matrix, columns are first/last point in homogeneous form
285+ p = np .vstack ([xs , ys , zs ])
286+ self .p = np .vstack ([p , np .ones ((p .shape [1 ],))])
285287 self .h = h
286288 self .type = "line"
287289 self .anim = anim
@@ -311,6 +313,7 @@ def plot(self, x, y, z, *args, **kwargs):
311313
312314 (h ,) = self .ax .plot (x , y , z , * args , ** kwargs )
313315 self .displaylist .append (Animate ._Line (self , h , x , y , z ))
316+ return h
314317
315318 # ------------------- quiver()
316319
@@ -416,8 +419,9 @@ def text(self, x, y, z, *args, **kwargs):
416419
417420 # ------------------- scatter()
418421
419- def scatter (self , ** kwargs ):
420- pass
422+ def scatter (self , xs , ys , zs , s = 0 , ** kwargs ):
423+ h = self .plot (xs , ys , zs , '.' , markersize = 0 , ** kwargs )
424+ self .displaylist .append (Animate ._Line (self , h , xs , ys , zs ))
421425
422426 # ------------------- wrappers for Axes primitives
423427
@@ -503,6 +507,8 @@ def __init__(self, axes=None, dims=None, labels=("X", "Y"), **kwargs):
503507 axes .set_xlim (dims [0 :2 ])
504508 axes .set_ylim (dims [2 :4 ])
505509 # ax.set_aspect('equal')
510+ else :
511+ axes .autoscale (enable = True , axis = 'both' )
506512
507513 self .ax = axes
508514
@@ -544,7 +550,7 @@ def trplot2(self, end, start=None, **kwargs):
544550 self .start = start
545551
546552 # draw axes at the origin
547- base .trplot2 (self .start , axes = self , block = False , ** kwargs )
553+ base .trplot2 (self .start , ax = self , block = False , ** kwargs )
548554
549555 def run (
550556 self , movie = None , axes = None , repeat = False , interval = 50 , nframes = 100 , ** kwargs
@@ -641,10 +647,18 @@ def _draw(self, T):
641647
642648 # ------------------- plot()
643649
650+ def set_aspect (self , * args , ** kwargs ):
651+ self .ax .set_aspect (* args , ** kwargs )
652+
653+ def autoscale (self , * args , ** kwargs ):
654+ #self.ax.autoscale(*args, **kwargs)
655+ pass
656+
644657 class _Line :
645658 def __init__ (self , anim , h , xs , ys ):
646- # form 3x2 matrix, columns are first/last point in homogeneous form
647- self .p = np .vstack ([xs , ys , [1 , 1 ]])
659+ # form 3xN matrix, columns are first/last point in homogeneous form
660+ p = np .vstack ([xs , ys ])
661+ self .p = np .vstack ([p , np .ones ((p .shape [1 ],))])
648662 self .h = h
649663 self .type = "line"
650664 self .anim = anim
@@ -671,6 +685,7 @@ def plot(self, x, y, *args, **kwargs):
671685
672686 (h ,) = self .ax .plot (x , y , * args , ** kwargs )
673687 self .displaylist .append (Animate2 ._Line (self , h , x , y ))
688+ return h
674689
675690 # ------------------- quiver()
676691
@@ -755,8 +770,9 @@ def text(self, x, y, *args, **kwargs):
755770
756771 # ------------------- scatter()
757772
758- def scatter (self , ** kwargs ):
759- pass
773+ def scatter (self , x , y , s = 0 , ** kwargs ):
774+ h = self .plot (x , y , '.' , markersize = 0 , ** kwargs )
775+ self .displaylist .append (Animate2 ._Line (self , h , x , y ))
760776
761777 # ------------------- wrappers for Axes primitives
762778
@@ -791,8 +807,11 @@ def set_ylabel(self, *args, **kwargs):
791807 # plotvol3(2)
792808 # tranimate(attitude())
793809
794- # from spatialmath import base
810+ from spatialmath import base
795811
796- # T = base.rpy2r(0.3, 0.4, 0.5)
812+ T = base .rpy2r (0.3 , 0.4 , 0.5 )
797813 # base.tranimate(T, wait=True)
814+
815+ T = base .rot2 (2 )
816+ base .tranimate2 (T , wait = True )
798817 pass
0 commit comments