【问题标题】:ArCore Sceneform, calculate angle between 3 anchor nodes A -> B -> C in degreesArCore Sceneform,计算 3 个锚节点 A -> B -> C 之间的角度(以度为单位)
【发布时间】:2021-09-15 11:02:09
【问题描述】:

我有 3 个锚节点,比如说 A、B、C。 A 与 B 相连,B 与 C 相连,形成一个“开放三角形”。

我需要计算两条线在B点形成的角度。

这怎么可能?

【问题讨论】:

  • 我对 arcore 或 sceneform 都不熟悉,但如果他们提供名为 atan2 的东西并且您知道三个节点的坐标,那么 atan2 应该可以工作。见en.wikipedia.org/wiki/Atan2

标签: math arcore sceneform


【解决方案1】:

我终于设法使用这些说明实现了这一点:

val abLen = Vector3.subtract(pointNodes[0].worldPosition, pointNodes[1].worldPosition).length()
val bcLen = Vector3.subtract(pointNodes[1].worldPosition, pointNodes[2].worldPosition).length()

val prodLen = abLen * bcLen
val dotProd = Vector3.dot(Vector3.subtract(pointNodes[0].worldPosition, pointNodes[1].worldPosition), Vector3.subtract(pointNodes[2].worldPosition, pointNodes[1].worldPosition))
val dp = dotProd / prodLen
val angleInDegrees = acos(dp.toDouble()) * 180 / Math.PI

其中 pointNodes 是一个锚节点数组,包含 3 个锚节点 A 在 0、B 在 1 和 C 在 2。

【讨论】:

    猜你喜欢
    • 2012-04-15
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    相关资源
    最近更新 更多