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
source share