need to handle special case of Re() = 0
ensuring that the real part is positive seems to be a good idea on first sight, but it would be easier to simply acknowledge that qu = -qu
This commit is contained in:
parent
80b8693a66
commit
98723cb0ed
|
@ -105,8 +105,10 @@ class Rotation:
|
||||||
Rotation to check for equality.
|
Rotation to check for equality.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
ambiguous = np.isclose(self.quaternion[...,0],0)
|
||||||
return np.prod(self.shape,dtype=int) == np.prod(other.shape,dtype=int) \
|
return np.prod(self.shape,dtype=int) == np.prod(other.shape,dtype=int) \
|
||||||
and np.allclose(self.quaternion,other.quaternion)
|
and ( np.allclose(self.quaternion,other.quaternion) \
|
||||||
|
or np.allclose(self.quaternion[ambiguous],-1*other.quaternion[ambiguous]))
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -786,6 +786,12 @@ class TestRotation:
|
||||||
def test_equal(self):
|
def test_equal(self):
|
||||||
assert Rotation.from_random(rng_seed=1) == Rotation.from_random(rng_seed=1)
|
assert Rotation.from_random(rng_seed=1) == Rotation.from_random(rng_seed=1)
|
||||||
|
|
||||||
|
def test_equal_ambiguous(self):
|
||||||
|
qu = np.random.rand(10,4)
|
||||||
|
qu[:,0] = 0.
|
||||||
|
qu/=np.linalg.norm(qu,axis=1,keepdims=True)
|
||||||
|
assert Rotation(qu) == Rotation(-qu)
|
||||||
|
|
||||||
def test_inversion(self):
|
def test_inversion(self):
|
||||||
r = Rotation.from_random()
|
r = Rotation.from_random()
|
||||||
assert r == ~~r
|
assert r == ~~r
|
||||||
|
|
Loading…
Reference in New Issue