Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何将ARPLANEACHOR转换为二维直线(平行投影)_Ios_Arkit_Scnnode_Aranchor - Fatal编程技术网

Ios 如何将ARPLANEACHOR转换为二维直线(平行投影)

Ios 如何将ARPLANEACHOR转换为二维直线(平行投影),ios,arkit,scnnode,aranchor,Ios,Arkit,Scnnode,Aranchor,我使用ARKit扫描ARSCNView中的垂直平面。我想以后把它们画成二维线(从上面平行投影)ARPlaneAnchor没有起点和终点,只有中心点和宽度(ARPlaneAnchor.extent) 我还尝试了使用SCNNode及其boundingBox对象,但直接坐标与扫描平面不同 如何将ARPlaneAnchor或SCNNode转换为二维直线(二维坐标)?您应该能够使用中心点和高度/宽度来计算估计的平面边缘位置,并从那里开始。只需注意,center是相对于飞机的锚的 假设你的飞机是垂直的,就像

我使用
ARKit
扫描
ARSCNView
中的垂直平面。我想以后把它们画成二维线(从上面平行投影)
ARPlaneAnchor
没有起点和终点,只有中心点和宽度(
ARPlaneAnchor.extent

我还尝试了使用
SCNNode
及其
boundingBox
对象,但直接坐标与扫描平面不同


如何将
ARPlaneAnchor
SCNNode
转换为二维直线(二维坐标)?

您应该能够使用中心点和高度/宽度来计算估计的平面边缘位置,并从那里开始。只需注意,
center
是相对于飞机的锚的

假设你的飞机是垂直的,就像你注意到的,这样的事情应该让你开始:

    let centerLocal = verticalPlane.center
    let centerWorld = centerLocal + verticalPlane.transform.translation
    let extents = verticalPlane.extent
    let upperLeft = centerWorld + SIMD3<Float>(-extents.x / 2, 0, extents.z / 2)
    let bottomRight = centerWorld + SIMD3<Float>(extents.x / 2, 0, -extents.z / 2)
让centerLocal=verticalPlane.center
让centerWorld=centerLocal+verticalPlane.transform.translation
设范围=垂直平面。范围
让左上方=centerWorld+SIMD3(-extents.x/2,0,extents.z/2)
设bottomRight=centerWorld+SIMD3(extents.x/2,0,-extents.z/2)
我使用的扩展:

extension float4x4 {
    // Treats matrix as a transform matrix and grabs the 
    // translation component of the transform.       
    var translation: SIMD3<Float> {
        let translation = columns.3
        return SIMD3<Float>(translation.x, translation.y, translation.z)
    }
}
extension float4x4{
//将矩阵视为变换矩阵并获取
//转换的转换组件。
var转换:SIMD3{
让翻译=列
返回SIMD3(translation.x、translation.y、translation.z)
}
}

可以使用超类属性“ARAnchor.transform”获取平面的方向。然后,给定中心坐标、平面宽度和方向,您应该能够找到直线的二维起点和终点