Objective-C矩形CGPoint到极地CGPoint

Ale*_*one 2 iphone objective-c cgpoint ios polar-coordinates

我找到了将X,Y转换成半径和角度的方程式:

x = r*Cos(Q)
y = r*Sin(Q)

r= sqrt(x*x + y*y)
Q = tan^-1(y/x)
Run Code Online (Sandbox Code Playgroud)

我的问题是我不记得目标C中tan ^ -1的语法是什么.我不想弄错.

这让我想到:为什么要从头开始构建这个?是否有内置方法将Objective C中给定的CGPoint从极坐标转换为直角坐标?也许有一些CAAnimation类可以帮助我解决这个问题?

drm*_*att 5

要获得角度使用:

Q = atan2( y, x );
Run Code Online (Sandbox Code Playgroud)

此功能将计算出象限以给出正确的角度符号.