What are the first two columns in SCNMatrix4

I read the documentation for this structure, but it seems that there is not enough information, m3 is the third column of the matrix, and m4 is the fourth column containing information about the orientation and location of the node in 3D space, respectively, which I know because of some course on Udmen .

Also right now, the only way to extract orientation and other things is:

guard let pointOfView = sceneView.pointOfView else { return } let transform = pointOfView.transform let orientaiton = SCNVector3(-transform.m31, -transform.m32, -transform.m33) 

I assume the API for ARKit is different compared to SceneKit

Apple Documentation Link: https://developer.apple.com/documentation/scenekit/scnmatrix4/1621081-m11

+1
source share
1 answer

SCNMatrix4 is a three-dimensional transformation matrix . Shortly speaking:

 M = T * R * S 

Translation (tx, ty, tz):

  โ”Œ โ” T = | 1 0 0 tx | | 0 1 0 ty | | 0 0 1 tz | | 0 0 0 1 | โ”” โ”˜ 

Scale by (sx, sy, sz):

  โ”Œ โ” S = | sx 0 0 0 | | 0 sy 0 0 | | 0 0 sz 0 | | 0 0 0 1 | โ”” โ”˜ 

Rotation on (rx, ry, rz):

 R = ZYX โ”Œ โ” X = | 1 0 0 0 | | 0 cos(rx) -sin(rx) 0 | | 0 sin(rx) cos(rx) 0 | | 0 0 0 1 | โ”” โ”˜ โ”Œ โ” Y = | cos(ry) 0 sin(ry) 0 | | 0 1 0 0 | | -sin(ry) 0 cos(ry) 0 | | 0 0 0 1 | โ”” โ”˜ โ”Œ โ” Z = | cos(rz) -sin(rz) 0 0 | | sin(rz) cos(rz) 0 0 | | 0 0 1 0 | | 0 0 0 1 | โ”” โ”˜ 

By the way, just decompose SCNMatrix4 using the SceneKit framework:

 let n = SCNNode() n.transform = YOUR_MATRIX let position = n.position let orientation = n.orientation let scale = n.scale 
+4
source

Source: https://habr.com/ru/post/1275505/


All Articles