double x1, y1, x2, y2; // set values for x1, y1, x2, y2 double angle = atan2(y2 - y1, x2 - x1);
double x, y; // set values for x, y double angle = atan2(y, x);This calculates the angle in radians between the positive x-axis and the vector (x,y). The atan2() function is part of the C++ standard library and does not require a separate package or library.