Re: The different results given by scipy and https://quaternions.online/ when converting Euler angles to Quaternion representation.
Hongyi Zhao <[email protected]> Wed, 28 Oct 2020 17:49:30 +0800
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <CAGP6POKZk6_fmUWUEAUqdX841WMm2XvJQ0LcsSYFxiP3yZAoYw@mail.gmail.com> |
On Wed, Oct 28, 2020 at 4:29 PM Guillaume Gay <[email protected]> wrote: > > Hi, Hongyi, > > > This seems to have to do first with extrinsic vs intrinsic order, (the > website seems to assume intrinsic angles). Thus with "XYZ" as first > argument, the result are still different but that difference is > consistent (which is not the case for e.g. `r = R.from_euler('xyz', [30, > 45, 30], degrees=True)` which gives different values all together on > your website / with scipy. > > > r = R.from_euler('XYZ', [90, 45, 30], degrees=True) > > r.as_quat() > > array([0.70105738, 0.09229596, 0.43045933, 0.56098553]) I also find another website located at <https://www.onlineconversion.com/quaternions.htm> for doing the similar job. The results given by this website is as follows for the Euler angles in degrees [90, 45, 30]: 0.560985526796931 0.43045933457687935 -0.560985526796931 0.43045933457687935 As you can see, this result is different from the ones obtained by both extrinsic and intrinsic order of scipy shown as following: extrinsic: [0.7010573846499779, 0.5609855267969309, 0.4304593345768794, -0.09229595564125723] intrinsic: [0.560985526796931, 0.7010573846499778, 0.09229595564125731, 0.43045933457687935] The codes used by me is as following: from scipy.spatial.transform import Rotation as R from squaternion import Quaternion euler_angle = [90, 45, 30] q = Quaternion.from_euler(euler_angle[0], euler_angle[1], euler_angle[2], degrees=True) extrinsic_r = R.from_euler('xyz', euler_angle[:], degrees=True) intrinsic_r = R.from_euler('XYZ', euler_angle[:], degrees=True) extrinsic_quat = extrinsic_r.as_quat() intrinsic_quat = intrinsic_r.as_quat() sq_quat = [] sq_quat.extend([q.w, q.x, q.y, q.z]) ex_quat = [extrinsic_quat[3]] ex_quat.extend(extrinsic_quat[:3]) in_quat = [intrinsic_quat[3]] in_quat.extend(intrinsic_quat[:3]) print(sq_quat) print(ex_quat) print(in_quat) Regards, HY > > the result is now a permutation away from what the website says. > > > I'd test with 'obvious' cases to get to the bottom of that, but I mostly > think one should trust scipy to do "the right thing" as it has had more > scrutiny than the website. > > > Hope this helps > > > Le 27/10/2020 à 14:19, Hongyi Zhao a écrit : > > Hi, > > > > I try to convert between Euler angle and Quaternion representations. > > But I obtained different results when using scipy and the online > > converter (https://quaternions.online/). See following for detailed > > info: > > > > The results obtained from scipy: > > > > In [14]: from scipy.spatial.transform import Rotation as R > > > > In [15]: r = R.from_euler('xyz', [90, 45, 30], degrees=True) > > In [17]: r.as_quat() > > Out[17]: array([ 0.56098553, 0.43045933, -0.09229596, 0.70105738]) > > > > The results given by the online converter (https://quaternions.online/): > > > > w: 0.561 > > x: 0.701 > > y: 0.092 > > z: 0.430 > > > > Any hints for this problem will be highly appreciated? > > > > Regards, > > HY > _______________________________________________ > SciPy-User mailing list > [email protected] > https://mail.python.org/mailman/listinfo/scipy-user -- Assoc. Prof. Hongyi Zhao <[email protected]> Theory and Simulation of Materials, Xingtai Polytechnic College NO. 552 North Gangtie Road, Xingtai, China _______________________________________________ SciPy-User mailing list [email protected] https://mail.python.org/mailman/listinfo/scipy-user