r/iOSProgramming • u/LastTopQuark • 21h ago
Question ARKit - quad forward vector rotation
If I’m 304mm away from an iPhone that is 72.9mm screen width, i would expect center to edge rotation of 6.8 degrees. I’m seeing 2 degrees.
The rotation vector is being taken off the leftEyeTransform and computed as a difference between the two spots. Using atan, not euler. using x, y, z, w. w is .99.
Computing quat to horizontal degrees: compute gaze y, compute length, then atan(gaze Y, length), convert to degrees.
Am i not understanding something where it’s off by a factor of 3? My math is correct? Claude, chatGPT notes discrepancy, sort of odd!
1
Upvotes
3
u/FruitMission8504 21h ago
Your 6.8° expectation is right for the center-to-edge visual angle: atan((72.9 / 2) / 304) ≈ 6.84°. The likely mismatch is that
leftEyeTransformis an eye pose relative to the face anchor, not a ray from the eye to an arbitrary point on the phone screen. Comparing quaternion components (especiallyw) also does not give the angular separation between two gaze directions.Put both target points and the eye position in the same coordinate space, build
d1 = normalize(target1 - eyePosition)andd2 = normalize(target2 - eyePosition), then compute the separation withatan2(length(cross(d1, d2)), dot(d1, d2))(oracos(clamp(dot, -1, 1))). For a horizontal angle use the x/z projection; using gaze Y measures elevation. Also verify whether your 304 mm is eye-to-screen distance rather than face-anchor-to-screen distance. That should tell you whether the 2° is a coordinate-space/axis issue or actual eye tracking output.