atan2

Á¡ A, B°¡ Á¸ÀçÇÒ¶§ x, y ¸¸Å­ À̵¿ ÇßÀ»¶§  °¢µµ ¥È¸¦ ±¸ÇØ º¸ÀÚ.
AB´Â Á÷°¢ »ï°¢ÇüÀÌ´Ù.



atan2¸¦ ÀÌ¿ëÇÏ¸é °¢µµ ¥È¸¦ ¹Ù·Î ±¸ÇÒ¼ö ÀÖ´Ù.

¥È = atan2(y, x) * INV_PI

#include "stdafx.h"
#include <math.h>
#include <iostream>

using namespace std;

float INV_PI = 180.0f / 3.141592f;
float GetAngle(float x, float y)
{
    float degree = atan2(y, x) * INV_PI;
    degree = fmodf(degree + 360, 360);
    return degree;
}

int main()
{
    
    cout << "degree :  " << GetAngle(1, 1) << std::endl;  //45µµ
    cout << "degree :  " << GetAngle(-1, 0) << std::endl; //180µµ
    cout << "degree :  " << GetAngle(-1, -1) << std::endl; //225µµ
    cout << "degree :  " << GetAngle(0, -1) << std::endl; //270µµ

    
    return 0;
}

Âü°í)
http://zzoyu.tistory.com/73