From d02617c9616e7fdc309b80500fb70f39a1b9282f Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 15 Sep 2020 13:09:24 -0400 Subject: [PATCH] fixed normalization of multidimensional axes (from_Rodrigues, from_axis_angle) --- python/damask/_rotation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index ac7b3ace8..c023984e6 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -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)):