1

I'm working on an ARKit-based iOS app where I need to accurately determine the direction the device is facing to localize objects in the real world. I'm using:

let config = ARWorldTrackingConfiguration()
config.worldAlignment = .gravityAndHeading

Thus, I would expect the world alignment to behave as given in the gravityAndHeading page.

The AR session is started after verifying that CLLocationManager.headingAccuracy <= 20, and the compass appears to be calibrated.

However, I'm seeing a major inconsistency: When the rear camera is physically pointed toward true North, I would expect:

cameraTransform.columns.2.z ≈ -1 // (i.e. ARKit's -Z pointing North)

But instead, I'm consistently seeing:

cameraTransform.columns.2.z ≈ +0.97 // Implies camera is facing South

Meanwhile, the translation vector behaves as expected: As I physically move North, cameraTransform.columns.3.z becomes more negative, matching the world’s +Z = South assumption.

For example, let's say I have the device in landscapeRight (or landscapeLeft for UIDeviceOrientation). Let's say the device rear camera is pointing towards True North, and I start moving towards True North. I get something like this:

Camera Transform = simd_float4x4(
[
[0.98446155, -0.030119859, 0.172998, 0.0], 
[0.023979114, 0.9990097, 0.037477385, 0.0], 
[-0.17395553, -0.032746706, 0.98420894, 0.0], 
[0.024039675, -0.037087332, -0.22780673, 0.99999994]
])

As you can see, the cameraTransform.columns.2.z is positive despite the rear camera pointing towards True North, while cameraTransform.columns.3.z is correctly positive as the device is moving towards True North. (This behavior is seen in other orientations as well)

So here is my question:

  • Why is cameraTransform.columns.2.z positive when the rear camera is physically facing North?

Any clarity would be deeply appreciated. I've read the documentation and tested with different heading accuracies and AR session resets, but I keep running into this orientation mismatch.

Thanks in advance!

asked Jun 23, 2025 at 4:32
3
  • This is a good old issue from 2017. Commented Jun 23, 2025 at 7:30
  • 1
    I see. Yes, it does seem like a similar issue. However, I am not getting an erratic result. The alignment seems consistent, unfortunately, it is consistently wrong. X and Y are correct (unlike in the linked issue where even X-axis gets misaligned), but only the Z is consistently in the opposite direction. Commented Jun 23, 2025 at 17:13
  • Have you tried eulerAngles? Commented Jul 11, 2025 at 0:11

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.