【问题标题】:ARcore - How to get distance of one node from other Node?ARcore - 如何获取一个节点与另一个节点的距离?
【发布时间】:2019-03-31 20:58:08
【问题描述】:

我正在寻找在 ARCore sceneform SDK 中找到一个节点与另一个节点的距离的方法。我研究了overlapTestAll()overlapTest(),它们只返回一个相互碰撞的列表节点。我假设此方法通过计算节点之间的距离返回列表。

【问题讨论】:

    标签: java android augmented-reality arcore sceneform


    【解决方案1】:

    以米为单位获取向量之间的距离:

    private float getDistanceBetweenVectorsInMeters(Vector3 to, Vector3 from) 
    {
        // Compute the difference vector between the two hit locations.
        float dx = to.x - from.x;
        float dy = to.y - from.y;
        float dz = to.z - from.z;
    
        // Compute the straight-line distance (distanceMeters)
        return (float) Math.sqrt(dx * dx + dy * dy + dz * dz);
    }
    

    【讨论】:

      【解决方案2】:

      使用getWorldPosition(),然后您可以计算两个x/y/z 位置之间的差异。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-23
        • 1970-01-01
        • 2016-04-03
        相关资源
        最近更新 更多