터치 좌표를 이용하여 각도구하는 방법

스크린 상단이 0도가 되며 좌측이 -, 우측이 + 스크린 하단이 180도 이다.


http://stackoverflow.com/questions/17037798/ios-detecting-line-angle-or-degree


- (float) getAngle:(CGPoint)a :(CGPoint)b

{

    int x = a.x;

    int y = a.y;

    float dx = b.x - x;

    float dy = b.y - y;

    CGFloat radians = atan2(-dx,dy);        // in radians

    CGFloat degrees = radians * 180 / 3.14; // in degrees

    return degrees;

}

+ Recent posts