DAMASK_EICMD/python/tests/test_Rotation.py

55 lines
1.7 KiB
Python
Raw Normal View History

2019-11-22 01:31:01 +05:30
import numpy as np
from damask import Rotation
class TestRotation:
n = 1000
def test_Eulers(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asQuaternion(),
Rotation.fromEulers(rot.asEulers()).asQuaternion())
2019-11-22 01:31:01 +05:30
def test_AxisAngle(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asEulers(),
Rotation.fromAxisAngle(rot.asAxisAngle()).asEulers())
2019-11-22 01:31:01 +05:30
def test_Matrix(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asAxisAngle(),
Rotation.fromMatrix(rot.asMatrix()).asAxisAngle())
2019-11-22 01:31:01 +05:30
def test_Rodriques(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asMatrix(),
Rotation.fromRodrigues(rot.asRodrigues()).asMatrix())
2019-11-22 01:31:01 +05:30
def test_Homochoric(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asRodrigues(),
Rotation.fromHomochoric(rot.asHomochoric()).asRodrigues())
2019-11-22 01:31:01 +05:30
def test_Cubochoric(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asHomochoric(),
Rotation.fromCubochoric(rot.asCubochoric()).asHomochoric())
2019-11-22 01:31:01 +05:30
def test_Quaternion(self):
for r in range(self.n):
rot = Rotation.fromRandom()
2019-11-22 02:18:54 +05:30
assert np.allclose(rot.asCubochoric(),
Rotation.fromQuaternion(rot.asQuaternion()).asCubochoric())