我不确定如何将场景中的worldTransform转换为从相机计算的CLLocation(纬度,经度,海拔高度),我不知道如何在swift中实现它 . 我使用了ARKit CoreLocation,似乎在内部使用了一些逻辑来通过LocationNode进行GPS - > worldTransform转换 .

Here is the algorithm I am thinking of for worldTransform -> GPS :

0)获取当前摄像机位置的CLLocation:这个是好的,我们只是实现了一些CLLocation委托

1)转换相机空间中的节点:这里我不知道是否应该使用ARCamera() . projectionMatrix(如果是这样的话,如何从sceneView获取相机参考.ARCamera与相应节点之间的关系是什么?)或使用sceneView.pointOfView(实际摄像机节点) . 我怎样才能计算ViewMatrix以便我可以做nodeTransform_camera_space = ViewMatrix * nodeTransform_world_space

2)从nodeTransform_camera_space计算(deltaLatitude,deltaLongitude,deltaAltitude) . 这里依赖于一些三角函数,我不知道如何进行计算 .

3)应用delta:result = CLLocation((纬度deltaLatitude,经度deltaLongitude),高度deltaAltitude)

And the inverse algorithm GPS -> worldTransform :

0)获取当前摄像机位置的CLLocation:这个是好的,我们只是实现了一些CLLocation委托

1)获取sceneView.pointOfView

2)计算摄像机CLLocation和节点CLLocation之间的(deltaLatitude,deltaLongitude,deltaAltitude)并找到给出1)的nodeTransform_camera_space?

3)将节点放回世界坐标:nodeTransform_world_space =(nodeTransform_camera_space)^( - 1)* nodeTransform_camera_space?

Also if we want to store/retrieve 1-axis orientation to some server (around the gravity vector) (with transform -> GPS we lose the orientation info) :

0)从正北(0°)获取设备轴承 . 我不知道如何使用CoreLocation .

1)根据worldTransform.orientation和0)计算设备轴承?

2)将轴承存放到某个服务器

然后

3)从某个服务器获取方位

4)计算worldTransform.orientation给出3)和设备轴承?

最后,我想知道lat,lon应该在数据库中存储多少位数以达到1米的精度?谢谢你的帮助 .