Skip to content

Commit d7a8c7b

Browse files
committed
tidy up doco and code examples
1 parent 175b5f9 commit d7a8c7b

7 files changed

Lines changed: 47 additions & 36 deletions

File tree

‎spatialmath/DualQuaternion.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ def __init__(self, real=None, dual=None):
301301
>>> d = UnitDualQuaternion(T)
302302
>>> print(d)
303303
>>> type(d)
304-
>>> print(d.norm()) # norm is (1, 0)
305304
306305
The dual number is stored internally as two quaternion, respectively
307306
called ``real`` and ``dual``. For a unit dual quaternion they are

‎spatialmath/geom2d.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ def __str__(self) -> str:
273273
.. runblock:: pycon
274274
275275
>>> from spatialmath import Polygon2
276-
>>> p = Polygon2([[1, 3, 2], [2, 2, 4]])
276+
>>> import numpy as np
277+
>>> p = Polygon2(np.array([[1, 3, 2], [2, 2, 4]]))
277278
>>> print(p)
278279
"""
279280
return f"Polygon2 with {len(self.path)} vertices"

‎spatialmath/geom3d.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,8 @@ def closest_to_point(self, x: ArrayLike3) -> Tuple[R3, float]:
968968
969969
.. runblock:: pycon
970970
971-
>>> from spatialmath import Join
972-
>>> line1 = Join.Join([0, 0, 0], [2, 2, 3])
971+
>>> from spatialmath import Line3
972+
>>> line1 = Line3.Join([0, 0, 0], [2, 2, 3])
973973
>>> line1.closest_to_point([1, 1, 1])
974974
975975
:seealso: meth:`point`

‎spatialmath/pose2d.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131

3232
class SO2(BasePoseMatrix):
3333
"""
34-
SO(2) matrix class
34+
SO(2) matrix class
3535
36-
This subclass represents rotations in 2D space. Internally it is a 2x2 orthogonal matrix belonging
37-
to the group SO(2).
36+
This subclass represents rotations in 2D space. Internally it is a 2x2 orthogonal matrix belonging
37+
to the group SO(2).
3838
3939
.. inheritance-diagram:: spatialmath.pose2d.SO2
4040
:top-classes: collections.UserList

‎spatialmath/pose3d.py‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
:top-classes: collections.UserList
1919
:parts: 1
2020
21-
.. image:: figs/pose-values.png
21+
.. image:: ../figs/pose-values.png
2222
"""
2323
from __future__ import annotations
2424

@@ -286,14 +286,11 @@ def angvec(self, unit: str = "rad") -> Tuple[float, R3]:
286286
287287
:param unit: angular units: 'rad' [default], or 'deg'
288288
:type unit: str
289-
:param check: check that rotation matrix is valid
290-
:type check: bool
291-
:return: :math:`(\theta, {\bf v})`
289+
:return: :math:`(\theta, \hat{\bf v})`
292290
:rtype: float or ndarray(3)
293291
294-
``q.angvec()`` is a tuple :math:`(\theta, v)` containing the rotation
295-
angle and a rotation axis which is equivalent to the rotation of
296-
the unit quaternion ``q``.
292+
``x.angvec()`` is a tuple :math:`(\theta, v)` containing the rotation
293+
angle and a rotation axis.
297294
298295
By default the angle is in radians but can be changed setting `unit='deg'`.
299296
@@ -305,10 +302,11 @@ def angvec(self, unit: str = "rad") -> Tuple[float, R3]:
305302
306303
.. runblock:: pycon
307304
308-
>>> from spatialmath import UnitQuaternion
309-
>>> UnitQuaternion.Rz(0.3).angvec()
305+
>>> from spatialmath import SO3
306+
>>> R = SO3.Rx(0.3)
307+
>>> R.angvec()
310308
311-
:seealso: :func:`~spatialmath.quaternion.AngVec`, :func:`~angvec2r`
309+
:seealso: :meth:`eulervec` :meth:`AngVec` :meth:`~spatialmath.quaternion.UnitQuaternion.angvec` :meth:`~spatialmath.quaternion.AngVec`, :func:`~angvec2r`
312310
"""
313311
return smb.tr2angvec(self.R, unit=unit)
314312

‎spatialmath/quaternion.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ def inv(self) -> UnitQuaternion:
14731473
14741474
.. runblock:: pycon
14751475
1476-
>>> from spatialmath import UnitQuaternio
1476+
>>> from spatialmath import UnitQuaternion
14771477
>>> print(UQ.Rx(0.3).inv())
14781478
>>> print(UQ.Rx(0.3).inv() * UQ.Rx(0.3))
14791479
>>> print(UQ.Rx([0.3, 0.6]).inv())
@@ -1606,7 +1606,7 @@ def __mul__(
16061606
>>> q = UQ.Rx(0.3)
16071607
>>> q *= UQ.Rx(0.4))
16081608
>>> print(q)
1609-
>>> print(UQ.Rx(0.3) * UQ.Rx([0.4, 0.6])
1609+
>>> print(UQ.Rx(0.3) * UQ.Rx([0.4, 0.6]))
16101610
>>> print(UQ.Rx([0.3, 0.6]) * UQ.Rx(0.3))
16111611
>>> print(UQ.Rx([0.3, 0.6]) * UQ.Rx([0.3, 0.6]))
16121612
@@ -1900,7 +1900,7 @@ def interp(
19001900

19011901
def interp1(self, s: float = 0, shortest: Optional[bool] = False) -> UnitQuaternion:
19021902
"""
1903-
Interpolate a unit quaternions
1903+
Interpolate a unit quaternion
19041904
19051905
:param shortest: Take the shortest path along the great circle
19061906
:param s: interpolation coefficient, range 0 to 1, or number of steps
@@ -1926,7 +1926,7 @@ def interp1(self, s: float = 0, shortest: Optional[bool] = False) -> UnitQuatern
19261926
>>> q.interp1(0) # this is identity
19271927
>>> q.interp1(1) # this is q
19281928
>>> q.interp1(0.5) # this is in between
1929-
>>> qi = q.interp1(q2, 11) # in 11 steps
1929+
>>> qi = q.interp1(11) # in 11 steps
19301930
>>> len(qi)
19311931
>>> qi[0] # this is q1
19321932
>>> qi[5] # this is in between

‎spatialmath/twist.py‎

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def isprismatic(self):
9696
.. runblock:: pycon
9797
9898
>>> from spatialmath import Twist3
99-
>>> x = Twist3.Prismatic([1,2,3])
99+
>>> x = Twist3.UnitPrismatic([1,2,3])
100100
>>> x.isprismatic
101-
>>> x = Twist3.Revolute([1,2,3], [4,5,6])
101+
>>> x = Twist3.UnitRevolute([1,2,3], [4,5,6])
102102
>>> x.isprismatic
103103
104104
"""
@@ -122,9 +122,9 @@ def isrevolute(self):
122122
.. runblock:: pycon
123123
124124
>>> from spatialmath import Twist3
125-
>>> x = Twist3.Prismatic([1,2,3])
125+
>>> x = Twist3.UnitPrismatic([1,2,3])
126126
>>> x.isrevolute
127-
>>> x = Twist3.Revolute([1,2,3], [0,0,0])
127+
>>> x = Twist3.UnitRevolute([1,2,3], [0,0,0])
128128
>>> x.isrevolute
129129
130130
"""
@@ -150,7 +150,7 @@ def isunit(self):
150150
>>> from spatialmath import Twist3
151151
>>> S = Twist3([1,2,3,4,5,6])
152152
>>> S.isunit()
153-
>>> S = Twist3.Revolute([1,2,3], [4,5,6])
153+
>>> S = Twist3.UnitRevolute([1,2,3], [4,5,6])
154154
>>> S.isunit()
155155
156156
"""
@@ -264,11 +264,11 @@ def __ne__(left, right): # lgtm[py/not-named-self] pylint: disable=no-self-argu
264264
265265
.. runblock:: pycon
266266
267-
>>> from spatialmath import Twist2
268-
>>> S1 = Twist([1,2,3,4,5,6])
269-
>>> S2 = Twist([1,2,3,4,5,6])
267+
>>> from spatialmath import Twist3
268+
>>> S1 = Twist3([1,2,3,4,5,6])
269+
>>> S2 = Twist3([1,2,3,4,5,6])
270270
>>> S1 != S2
271-
>>> S2 = Twist([1,2,3,4,5,7])
271+
>>> S2 = Twist3([1,2,3,4,5,7])
272272
>>> S1 != S2
273273
274274
:seealso: :func:`__ne__`
@@ -375,10 +375,11 @@ def isvalid(v, check=True):
375375
376376
.. runblock:: pycon
377377
378-
>>> from spatialmath import Twist3, base
378+
>>> from spatialmath import Twist3
379+
>>> from spatialmath.base import skewa
379380
>>> import numpy as np
380381
>>> Twist3.isvalid([1, 2, 3, 4, 5, 6])
381-
>>> a = smb.skewa([1, 2, 3, 4, 5, 6])
382+
>>> a = skewa([1, 2, 3, 4, 5, 6])
382383
>>> a
383384
>>> Twist3.isvalid(a)
384385
>>> Twist3.isvalid(np.random.rand(4,4))
@@ -653,12 +654,19 @@ def RPY(cls, *pos, **kwargs):
653654
- ``Twist3.RPY(⍺, β, 𝛾)`` as above but the angles are provided as three
654655
scalars.
655656
656-
657+
Foo bar!
658+
657659
Example:
658660
659661
.. runblock:: pycon
660662
661-
>>> from spatialmath import SE3
663+
>>> from spatialmath import Twist3
664+
>>> Twist3.Rx(0.3)
665+
>>> Twist3.Rx([0.3, 0.4])
666+
667+
.. runblock:: pycon
668+
669+
>>> from spatialmath import Twist3
662670
>>> Twist3.RPY(0.1, 0.2, 0.3)
663671
>>> Twist3.RPY([0.1, 0.2, 0.3])
664672
>>> Twist3.RPY(0.1, 0.2, 0.3, order='xyz')
@@ -688,6 +696,7 @@ def Tx(cls, x):
688696
689697
.. runblock:: pycon
690698
699+
>>> from spatialmath import Twist3
691700
>>> Twist3.Tx(2)
692701
>>> Twist3.Tx([2,3])
693702
@@ -713,6 +722,7 @@ def Ty(cls, y):
713722
714723
.. runblock:: pycon
715724
725+
>>> from spatialmath import Twist3
716726
>>> Twist3.Ty(2)
717727
>>> Twist3.Ty([2, 3])
718728
@@ -738,6 +748,7 @@ def Tz(cls, z):
738748
739749
.. runblock:: pycon
740750
751+
>>> from spatialmath import Twist3
741752
>>> Twist3.Tz(2)
742753
>>> Twist3.Tz([2, 3])
743754
@@ -1110,7 +1121,7 @@ def __mul__(
11101121
operation so the result will be a matrix
11111122
#. Any other input combinations result in a ValueError.
11121123
1113-
For pose composition the ``left`` and ``right`` operands may be a sequence
1124+
For pose composition the ``left`` and ``right`` operands may be a sequence
11141125
11151126
========= ========== ==== ================================
11161127
len(left) len(right) len operation
@@ -1666,6 +1677,7 @@ def Tx(cls, x):
16661677
16671678
.. runblock:: pycon
16681679
1680+
>>> from spatialmath import Twist2
16691681
>>> Twist2.Tx(2)
16701682
>>> Twist2.Tx([2,3])
16711683
@@ -1691,6 +1703,7 @@ def Ty(cls, y):
16911703
16921704
.. runblock:: pycon
16931705
1706+
>>> from spatialmath import Twist2
16941707
>>> Twist2.Ty(2)
16951708
>>> Twist2.Ty([2, 3])
16961709
@@ -1733,7 +1746,7 @@ def __mul__(
17331746
operation so the result will be a matrix
17341747
#. Any other input combinations result in a ValueError.
17351748
1736-
For pose composition the ``left`` and ``right`` operands may be a sequence
1749+
For pose composition the ``left`` and ``right`` operands may be a sequence
17371750
17381751
========= ========== ==== ================================
17391752
len(left) len(right) len operation

0 commit comments

Comments
 (0)