SCNMatrix4是3d
transformation matrix
. 简而言之:
M = T * R * S
翻译人(tx、ty、tz):
â â
T = | 1 0 0 tx |
| 0 1 0 ty |
| 0 0 1 tz |
| 0 0 0 1 |
â â
缩放比例(sx、sy、sz):
â â
S = | sx 0 0 0 |
| 0 sy 0 0 |
| 0 0 sz 0 |
| 0 0 0 1 |
â â
旋转(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 |
â â
顺便说一下,使用SceneKit框架分解SCNMatrix4很简单:
let n = SCNNode()
n.transform = YOUR_MATRIX
let position = n.position
let orientation = n.orientation
let scale = n.scale