1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
double cal_angle ( int current_x , int current_y , int tar_x , int tar_y )
{
return atan2(tar_y - current_y, tar_x - current_x);
}
int main ()
{
double x1 = 2.0;
double y1 = -1;
double x2 = 10.0;
double y2 = -1;
double x3 = 3.5;
double y3 = -1;
double x4 = 2.9;
double y4 = -1;
printf("%lf \n", cal_angle(x2 ,y2 , x1 , y1));
printf("%lf \n", cal_angle(x3 ,y3 , x1 , y1));
printf("%lf \n", cal_angle(x4 ,y4 , x1 , y1));
}
|