I have two points A(X,Y) and B(P,Q) in the first quadrant. There's another point C(L,M). How do I find angle between CA and CB in clockwise direction?
I searched a lot and all the solution used atan2() but it finds the angle from origin with respect to x axis.
C and A can be assumed fixed. And B is can be anywhere in the first quadrant. The angle must be clockwise and within range 0-360 (Or 0 to 360-1).
I am doing this in C/C++.
Edit : Adding code per request. This is a bit different, because I got stuck at a concept and needed clarification regarding it. This function ought to return if the point x,y lies between 50,50 and P. P is the angle with respect to CA.
bool isInsideAngle(long double x,long double y, long double p)
{
if((atan2(y,x) >= atan2(50,100)) && (atan2(y,x) <= (p * PI / 50)))
{
// cout<<"YES!";
// cout<<" atan2(y,x) = " <<atan2(y,x)*180/PI<<endl;
// cout<<" atan2(50,50) = " <<atan2(50,100)*180/PI<<endl;
// cout<<" (p * PI / 50) = "<<(p * PI / 50)*180/PI<<endl;
return true;
}
else
return false;
}