问题
I need help in math in general for euler angles and specifically in ARKit.
I looked at many references for calculation of euler angles but I wondered why apple in its tutorial calculated yaw from atan2(r11, r12) as follow:
let yaw = atan2f(camera.transform.columns.0.x, camera.transform.columns.1.x)
If I need to calculate pitch or roll, for example how?
I need to understand yaw and why they not always depends on yaw = camera.eularAngle.y
Please check this code and questions in comments, I'm very confused !
// why based on this?
let tilt = abs(camera.eulerAngles.x)
// why * 0.65 or * 0.75
let threshold1: Float = .pi / 2 * 0.65
let threshold2: Float = .pi / 2 * 0.75
// calculate yaw angle
let yaw = atan2f(camera.transform.columns.0.x, camera.transform.columns.1.x)
var angle: Float = 0
switch tilt {
case 0..<threshold1:
angle = camera.eulerAngles.y
case threshold1..<threshold2:
let relativeInRange = abs((tilt - threshold1) / (threshold2 - threshold1))
let normalizedY = normalize(camera.eulerAngles.y, forMinimalRotationTo: yaw)
angle = normalizedY * (1 - relativeInRange) + yaw * relativeInRange
default:
angle = yaw
}
self.rotation = SCNVector4(0, 1, 0, angle)
Does the order of rotations : rx ry rz OR ry rz rx could be the result of other equations for extracting euler angles from rotation matrix ?? and what's about mobile movements? We don't know what's the order of rotations? ( Note that, I have strong background in transfomation matrix and openGL)
I know atan2 what it means, I know that matrix of y rotation for r12 or column.1.x is should be zero:
| cos a 0 sin a |
| 0 1 0 |
| -sin a 1 cos a |
||
| r11 r12 r13 |
| r21 r22 r23 |
| r31 r32 r33 |
In most references consider z-up so it's the yaw, but in arkit y-up, so what's the difference for calculation ??
I just need to understand,I don't need code to work !! if anyone helps me I will be really really apprciate him.
来源:https://stackoverflow.com/questions/63758384/arkit-calc-euler-angles-from-rotation-matrix-in-yxz-world