After some testings by printing faceAnchor.transform.columns.3, digging in SO: ARFaceAnchor have negative Z position? and Apple\'s documentation: ARFaceAnchor,
At first, let's see what a default matrix values are.
Here's an Identity 4x4 matrix with default values.
If you need additional info on elements of 4x4 matrices read this post.
// 0 1 2 3
┌ ┐
| 1 0 0 0 | x
| 0 1 0 0 | y
| 0 0 1 0 | z
| 0 0 0 1 |
└ ┘
To flip entity's Z axis and X axis, in order to reorient axis from Face tracking environment to World tracking environment, use the following form of 4x4 transform matrix.
// 0 1 2 3
┌ ┐
| -1 0 0 0 | x
| 0 1 0 0 | y
| 0 0 -1 0 | z
| 0 0 0 1 |
└ ┘
In 4x4 transform matrices rotation is a combination of scale and skew. To choose a right rotation's direction, clockwise (CW) or counter-clockwise (CCW) use + or - for cos expressions.
Here's a positive Z rotation expression (CCW).
Positive +cos(a):
┌ ┐
| cos -sin 0 0 |
| sin cos 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
└ ┘
And here's a negative Z rotation expression (CW).
Negative -cos(a):
┌ ┐
|-cos -sin 0 0 |
| sin -cos 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
└ ┘