Merge branch '353-testing-euler-angles' into 'development'
correctly handling ambiguity if Phi approx pi Closes #353 See merge request damask/DAMASK!866
This commit is contained in:
commit
c277dce816
|
@ -150,6 +150,7 @@ def set_of_quaternions():
|
||||||
specials_scatter /= np.linalg.norm(specials_scatter,axis=1).reshape(-1,1)
|
specials_scatter /= np.linalg.norm(specials_scatter,axis=1).reshape(-1,1)
|
||||||
specials_scatter[specials_scatter[:,0]<0]*=-1
|
specials_scatter[specials_scatter[:,0]<0]*=-1
|
||||||
|
|
||||||
return np.array([s for s in specials] + \
|
return np.vstack((specials,
|
||||||
[s for s in specials_scatter] + \
|
specials_scatter,
|
||||||
[s for s in random_quaternions(n-2*len(specials))])
|
random_quaternions(n-2*len(specials)),
|
||||||
|
))
|
||||||
|
|
|
@ -534,14 +534,15 @@ class TestRotation:
|
||||||
for rot in set_of_rotations:
|
for rot in set_of_rotations:
|
||||||
m = rot.as_Euler_angles()
|
m = rot.as_Euler_angles()
|
||||||
o = backward(forward(m))
|
o = backward(forward(m))
|
||||||
u = np.array([np.pi*2,np.pi,np.pi*2])
|
u = np.pi*np.array([2.,1.,2.])
|
||||||
ok = np.allclose(m,o,atol=atol)
|
ok = np.allclose(m,o,atol=atol)
|
||||||
ok |= np.allclose(np.where(np.isclose(m,u),m-u,m),np.where(np.isclose(o,u),o-u,o),atol=atol)
|
ok |= np.allclose(np.where(np.isclose(m,u),m-u,m),np.where(np.isclose(o,u),o-u,o),atol=atol)
|
||||||
if np.isclose(m[1],0.0,atol=atol) or np.isclose(m[1],np.pi,atol=atol):
|
if np.allclose([m[1],o[1]],0.0,atol=atol):
|
||||||
sum_phi = np.unwrap([m[0]+m[2],o[0]+o[2]])
|
ok |= np.isclose(*np.unwrap([m[0]+m[2],o[0]+o[2]]),atol=atol)
|
||||||
ok |= np.isclose(sum_phi[0],sum_phi[1],atol=atol)
|
if np.allclose([m[1],o[1]],np.pi,atol=atol):
|
||||||
|
ok |= np.isclose(*np.unwrap([m[0]-m[2],o[0]-o[2]]),atol=atol)
|
||||||
assert ok and (np.zeros(3)-1.e-9 <= o).all() \
|
assert ok and (np.zeros(3)-1.e-9 <= o).all() \
|
||||||
and (o <= np.array([np.pi*2.,np.pi,np.pi*2.])+1.e-9).all(), f'{m},{o},{rot.as_quaternion()}'
|
and ( o <= u+1.e-9).all(), f'{m},{o},{rot.as_quaternion()}'
|
||||||
|
|
||||||
@pytest.mark.parametrize('forward,backward',[(Rotation._ax2qu,Rotation._qu2ax),
|
@pytest.mark.parametrize('forward,backward',[(Rotation._ax2qu,Rotation._qu2ax),
|
||||||
(Rotation._ax2om,Rotation._om2ax),
|
(Rotation._ax2om,Rotation._om2ax),
|
||||||
|
|
Loading…
Reference in New Issue