我正在尝试为CLLocation编写一个类别,以将轴承返回到另一个CLLocation.
我相信我对公式做错了(计算不是我的强项).返回的轴承始终关闭.
我一直在看这个问题并尝试应用被接受为正确答案的更改及其引用的网页:
计算两个CLLocationCoordinate2D之间的方位
http://www.movable-type.co.uk/scripts/latlong.html
谢谢你的任何指示.我已经尝试将其他问题的反馈结合起来,而我仍然没有得到任何东西.
谢谢
这是我的类别 -
----- CLLocation + Bearing.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface CLLocation (Bearing)
-(double) bearingToLocation:(CLLocation *) destinationLocation;
-(NSString *) compassOrdinalToLocation:(CLLocation *) nwEndPoint;
@end
Run Code Online (Sandbox Code Playgroud)
--------- CLLocation + Bearing.m
#import "CLLocation+Bearing.h"
double DegreesToRadians(double degrees) {return degrees * M_PI / 180;};
double RadiansToDegrees(double radians) {return radians * 180/M_PI;};
@implementation CLLocation (Bearing)
-(double) bearingToLocation:(CLLocation *) destinationLocation {
double lat1 = DegreesToRadians(self.coordinate.latitude);
double lon1 = DegreesToRadians(self.coordinate.longitude);
double lat2 = DegreesToRadians(destinationLocation.coordinate.latitude);
double lon2 = DegreesToRadians(destinationLocation.coordinate.longitude);
double dLon = lon2 …Run Code Online (Sandbox Code Playgroud) 我有2个物体,当我移动一个物体时,我想从另一个物体获得角度.
例如:
Object1X = 211.000000, Object1Y = 429.000000
Object2X = 246.500000, Object2Y = 441.500000
Run Code Online (Sandbox Code Playgroud)
我在阳光下尝试过以下各种变化:
double radians = ccpAngle(Object1,Object2);
double degrees = ((radians * 180) / Pi);
Run Code Online (Sandbox Code Playgroud)
但我只是得到2.949023返回我想要45度等的东西.
我想知道我的相机在 ARKit 中面向哪个方向,以便我对我面前的物体进行的操作是正确的(比如向左滑动以向左移动)。
现在我已经尝试使用 POV 方向(不起作用,因为它总是正的)和节点方向(photo.worldFront.z - 这将起作用,除非应用旋转,一旦旋转超过 180 度,方向是错误的)。
有什么建议?