title: Why does ARFaceAnchor have negative Z position?
body: <p>I am using ARKit's <code>ARFaceTrackingConfiguration</code> with <a href="https://developer.apple.com/documentation/arkit/arconfiguration/worldalignment/camera" rel="nofollow noreferrer"><code>ARConfiguration.WorldAlignment.camera</code></a> alignment, but I found that the documentation (seemingly) does not reflect the reality;</p>
  
  <p>Based on the excerpt of documentation below, I would expect that the face anchor's <code>transform</code> is expressed in right handed coordinate system. However, when I tried moving my head, I noticed that the Z coordinate of the face anchor is always negative (i.e. <code>faceAnchor.transform.columns.3.z &lt; 0</code>). Note that moving head in the X and Y directions corresponds to expected outcome (unlike Z coordinate).</p>
  
  <blockquote>
    <p>Camera alignment defines a coordinate system based on the native sensor orientation of the device camera. Relative to a <code>AVCaptureVideoOrientation.landscapeRight</code>-oriented camera image, the x-axis points to the right, the y-axis points up, and <strong>the z-axis points out the front of the device (toward the user)</strong>.</p>
  </blockquote>
  
  <p>I want the <code>transform</code> to behave as per the documentation, i.e. the Z coordinate of face anchor should be positive given that documentation says "<em>the z-axis points out the front of the device (toward the user)</em>". So far it seems the Z-axis points out the <strong>back</strong> of the device… </p>
  
  <p>Am I missing something obvious?</p>
  
  <p>I tried to repair the rotation by the following code, but I am not sure if it's correct way to fix this:</p>
  
  <pre><code>// Repair rotation
  let oldFaceRotation = simd_quatf(face.transform) // get quaternion from 
  let repairedFaceRotation = simd_quatf(ix: oldFaceRotation.axis.y, iy: oldFaceRotation.axis.x, iz: -oldFaceRotation.axis.z, r: oldFaceRotation.real)
  
  // Repair translation
  var repairedPosition = face.transform.columns.3
  repairedPosition.z *= -1
  
  // Combine
  var correctedFaceTransform = float4x4(repairedFaceRotation)
  correctedFaceTransform.columns.3 = repairedPosition
  </code></pre>