This is based on SFML where zero degrees is right -> (+x axis)
#include <cmath>
float angleBetweenVectors(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
float angleInRadians = atan2(p1.y - p2.y, p1.x - p2.x);
float angleInDegrees = (angleInRadians / M_PI) * 180.0;
return angleInDegrees < 0 ? angleInDegrees + 360 : angleInDegrees;
}
When the angle goes negative, we add 360 to normalise it.