From 06fc374359e5d1dfe73782d8350283013c52f7a8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 14 Jan 2020 10:22:51 +0100 Subject: [PATCH] avoid overhead length of random quaternion is one, no need to go via fromQuaternion but direct initialization and standardization suffices --- python/damask/orientation.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/damask/orientation.py b/python/damask/orientation.py index 71c8efef9..16f5d66b1 100644 --- a/python/damask/orientation.py +++ b/python/damask/orientation.py @@ -399,11 +399,10 @@ class Rotation: r = np.random.random(3) A = np.sqrt(r[2]) B = np.sqrt(1.0-r[2]) - w = np.cos(2.0*np.pi*r[0])*A - x = np.sin(2.0*np.pi*r[1])*B - y = np.cos(2.0*np.pi*r[1])*B - z = np.sin(2.0*np.pi*r[0])*A - return Rotation.fromQuaternion([w,x,y,z],acceptHomomorph=True) + return Rotation(np.array([np.cos(2.0*np.pi*r[0])*A, + np.sin(2.0*np.pi*r[1])*B, + np.cos(2.0*np.pi*r[1])*B, + np.sin(2.0*np.pi*r[0])*A])).standardize()