(09-06-2023, 04:28 PM)Jens Noritzsch Wrote: Hm, if I hold my iPhone in landscape orientation with the display facing to me, the angles are exactly as expected. This is the difficulty with Euler angles: the axes could be arbitrary — and they quickly start to mix…

If you would like to have different labels, you could simply exchange these with a text editor in the .phyphox file (“views” block).

Hallo Jens, thanks for replying! I might be wrong, but according to Android's notes here:

,%20float[])]SensorManager | Android Developers
the output of the experiment doesn't agree with that.

As far as I know, with the phone flat and screen facing up, roll is defined about the phone's y-axis (the long axis), pitch is about the x-axis (short axis) and yaw is about the z-axis (out of the screen). As these angles defines the rotation of the phone's axes with respect to the global reference frame (i.e., gravity and magnetic North), with the phone kept vertical then roll is around the phone's z-axis, pitch around the phone's x-axis and yaw around the phone's y-axis. Basically, pitch and roll are about the horizontal axes and yaw is around gravity irrespectively of the phone's orientation (either flat or vertical).

I had a look to the xml code (thanks for the hint!) and it looks like euler angles are derived from a quaternion/rotation vector (rather than directly from SensorManager.getOrientation)...which is fine!

But, assuming that the scalar part of the quaternion in the code is referred to as "q1" (as it is used for compute the variable named "direct" that should be the magnitude of the 3D rotation), then the formulas that output Euler angles look wrong. Quaternion multiplication formulas look wrong too. I tried to fix it according to standard math and what I got is some much conistent angles except for the fact that now rotation about the phone's y-axis is pitch and about x-axis is roll, which is strange as android tells the opposite. I could solve this just replacing roll with pitch as output name in the formula but I'd like to understand.

Attitude-euler_mod.phyphox (Size: 9.87 KB / Downloads: 73)

I'm attaching the xml I modified (using Notepad++). I wish I could contact the developer of the experiment but I couldn't find any reference.

Thanks for the support Jens!