Flip ARFaceAnchor from left-handed to right-handed coordinate system

后端 未结 1 522
感动是毒
感动是毒 2021-01-15 18:49

After some testings by printing faceAnchor.transform.columns.3, digging in SO: ARFaceAnchor have negative Z position? and Apple\'s documentation: ARFaceAnchor,

相关标签:
1条回答
  • 2021-01-15 19:09

    At first, let's see what a default matrix values are.


    Identity matrix

    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  |
     └              ┘
    


    Position Mirroring

    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  |
     └              ┘
    


    Rotation Mirroring

    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  |
     └                    ┘
    
    0 讨论(0)
提交回复
热议问题