I am pretty new to Quaternions so please bear with me. I want to draw random Quaternion samples so that their Euler angle equivalent would range within [-30, +30]
degrees on each axis. Currently, I know how to sample Quaternions from the full range ([-180, +180]
) using the code below but I don't know how to modify the code so that I can get samples within the range [-30, +30]
. Can anyone help me with that?
I'm not sure if this is helpful to answer this question but here's a piece of information: I eventually want to convert the sampled Quaternion to Euler angles an apply the Euler rotation in some 3D shapes. The order of rotation in the software I'm using to do this is XYZ
meaning that it first rotates the 3D shape along the X
axis, then Y
axis and then Z
axis.
import numpy as np
def sample_Quaternion():
r = np.random.uniform(0, 1 - 0.001, 3)
while np.linalg.norm(r) > 1:
r = np.random.uniform(0, 1 - 0.001, 3) # Just to keep the L2 norm within [0, 1.0)
w = [np.sqrt(1 - (r[0]*r[0] + r[1]*r[1] + r[2]*r[2]))]
r = np.concatenate(r, w) # the output of this would represent (x, y, z, w)
return r