Merge remote-tracking branch 'origin/multidim-rotation-axes' into development

This commit is contained in:
Martin Diehl 2020-09-16 09:15:32 +02:00
commit 9cdf506612
2 changed files with 11 additions and 2 deletions

View File

@ -434,7 +434,7 @@ class Rotation:
if P == 1: ax[...,0:3] *= -1
if degrees: ax[..., 3] = np.radians(ax[...,3])
if normalize: ax[...,0:3] /= np.linalg.norm(ax[...,0:3],axis=-1)
if normalize: ax[...,0:3] /= np.linalg.norm(ax[...,0:3],axis=-1,keepdims=True)
if np.any(ax[...,3] < 0.0) or np.any(ax[...,3] > np.pi):
raise ValueError('Axis angle rotation angle outside of [0..π].')
if not np.all(np.isclose(np.linalg.norm(ax[...,0:3],axis=-1), 1.0)):
@ -516,7 +516,7 @@ class Rotation:
raise ValueError('P ∉ {-1,1}')
if P == 1: ro[...,0:3] *= -1
if normalize: ro[...,0:3] /= np.linalg.norm(ro[...,0:3],axis=-1)
if normalize: ro[...,0:3] /= np.linalg.norm(ro[...,0:3],axis=-1,keepdims=True)
if np.any(ro[...,3] < 0.0):
raise ValueError('Rodrigues vector rotation angle not positive.')
if not np.all(np.isclose(np.linalg.norm(ro[...,0:3],axis=-1), 1.0)):

View File

@ -686,6 +686,15 @@ class TestRotation:
print(u,c)
assert np.allclose(single(u),c) and np.allclose(single(u),vectorized(u))
@pytest.mark.parametrize('func',[Rotation.from_axis_angle])
def test_normalization_vectorization(self,func):
"""Check vectorized implementation normalization."""
vec = np.random.rand(5,4)
ori = func(vec,normalize=True)
for v,o in zip(vec,ori):
assert np.allclose(func(v,normalize=True).as_quaternion(),o.as_quaternion())
@pytest.mark.parametrize('degrees',[True,False])
def test_Eulers(self,set_of_rotations,degrees):
for rot in set_of_rotations: