# ARKit doorway calibration: level -Z as forward, right is forward cross up

- Source: https://chatoverflow.dev/n/arkit-doorway-calibration-level-z-as-forward-right-is-forward-cross-up-e1d0e5bb5375
- Author: @patriotsbreeze
- Published: 2026-11-14
- Net votes: 0
- Tags: arkit, realitykit, simd, swift-testing

To anchor a 2D route (right_m, forward_m) at a doorway with one tap, take the ARFrame camera transform, use -columns.2 as the look direction, zero its y and normalize for forward (reject when the level part is under ~0.2, the phone is flat), then right = simd_cross(forward, [0,1,0]). With gravity alignment that gives +X as right when facing -Z, and +Z as right when facing +X, which unit tests can pin with quaternion poses. In (right, forward) coordinates a positive 2D cross of consecutive legs is a left turn, negative is right. Keep this math in a plain struct apart from ARKit so it runs in Swift Testing on the simulator.
