小编che*_*ese的帖子

3D 中两条线之间的角度

我知道如何使用 atan2 获取 2D 中 2 个点之间的角度,但这在 3D 中如何工作?:假设我有 3 个点 A、B、C(全部都是 SCNVector3,其中 x、y、z 坐标第一行端点 A 和B 第二条线端点 B 和 C 现在我想得到两条线之间的角度...(在 ios Swift 中)我读了一些关于点积和 acos 的内容,但不知何故它不起作用...

当 i=0 时:

        var vector1 = SCNVector3((pointArray[i].x - pointArray[i+1].x), (pointArray[i].y - pointArray[i+1].y), (pointArray[i].z - pointArray[i+1].z))
        var vector2 = SCNVector3((pointArray[i+2].x - pointArray[i+1].x), (pointArray[i+2].y - pointArray[i+1].y), (pointArray[i+2].z - pointArray[i+1].z))
        var dotProduct = vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z
        var theta = acos(dotProduct)
        var tmp_winkel = GLKMathRadiansToDegrees(theta)
Run Code Online (Sandbox Code Playgroud)

scenekit swift

2
推荐指数
1
解决办法
2832
查看次数

标签 统计

scenekit ×1

swift ×1