We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ad98b0e commit 470962cCopy full SHA for 470962c
spatialmath/quaternion.py
@@ -77,6 +77,9 @@ def __init__(self, s: Any = None, v=None, check: Optional[bool] = True):
77
"""
78
super().__init__()
79
80
+ if s is None and smb.isvector(v, 4):
81
+ v,s = (s,v)
82
+
83
if v is None:
84
# single argument
85
if super().arghandler(s, check=False):
@@ -979,6 +982,11 @@ def __init__(
979
982
980
983
981
984
985
+ # handle: UnitQuaternion(v)`` constructs a unit quaternion with specified elements
986
+ # from ``v`` which is a 4-vector given as a list, tuple, or ndarray(4)
987
988
989
990
991
992
if super().arghandler(s, check=check):
tests/test_quaternion.py
@@ -70,6 +70,9 @@ def test_constructor(self):
70
qcompare(UnitQuaternion(2, [0, 0, 0]), np.r_[1, 0, 0, 0])
71
qcompare(UnitQuaternion(-2, [0, 0, 0]), np.r_[1, 0, 0, 0])
72
73
+ qcompare(UnitQuaternion([1, 2, 3, 4]), UnitQuaternion(v = [1, 2, 3, 4]))
74
+ qcompare(UnitQuaternion(s = 1, v = [2, 3, 4]), UnitQuaternion(v = [1, 2, 3, 4]))
75
76
# from R
qcompare(UnitQuaternion(np.eye(3)), [1, 0, 0, 0])
@@ -753,6 +756,9 @@ def test_constructor(self):
753
756
nt.assert_array_almost_equal(Quaternion(2, [0, 0, 0]).vec, [2, 0, 0, 0])
754
757
nt.assert_array_almost_equal(Quaternion(-2, [0, 0, 0]).vec, [-2, 0, 0, 0])
755
758
759
+ qcompare(Quaternion([1, 2, 3, 4]), Quaternion(v = [1, 2, 3, 4]))
760
+ qcompare(Quaternion(s = 1, v = [2, 3, 4]), Quaternion(v = [1, 2, 3, 4]))
761
762
# pure
763
v = [5, 6, 7]
764
nt.assert_array_almost_equal(
0 commit comments