将纬度和经度转换为Swift中的SCNVector3

时间:2017-07-23 02:33:20

标签: swift scenekit

我试图将经度和经度转换为SCNVector3格式。我发现了这篇文章:http://www.mathworks.com/help/aeroblks/llatoecefposition.html

但不确定如何前进。有任何想法吗。

更新:

 let resturant = Resturant(latitude: 29.963221, longitude: -95.498958)

 let x =  ((self.sceneView.bounds.width/360.0) * (CGFloat(180.0 + resturant.latitude)));
        let y =  ((self.sceneView.bounds.height/180.0) * (CGFloat(90.0 - resturant.longitude)));

        let cube = SCNBox(width: 0.2, height: 0.2, length: 0.2, chamferRadius: 0)
        let material = SCNMaterial()
        material.diffuse.contents = UIColor.red

        cube.materials = [material]

        let node = SCNNode(geometry: cube)
        node.position = SCNVector3(x,2,-5)

        scene.rootNode.addChildNode(node)

        // Set the scene to the view
        sceneView.scene = scene

0 个答案:

没有答案