#include <cmath>
#include <iostream>

struct Obj
{
	double x, y, dir;
	Obj(double x, double y, double dir) :x{ x }, y{ y }, dir{ dir } {}
	double GetHeadingAngle(Obj const &other)
	{
		double heading = std::atan2(other.x - this->x, other.y - this->y) * 180 / 3.1415926535897 - this->dir;
		if (heading < -180) heading += 360;
		if (heading > 180) heading -= 360;
		return heading;
	}
};


int main() 
{
	Obj A(10, 10, 90);
	
	Obj B(15, 5, 0);
	std::cout << A.GetHeadingAngle(B) << std::endl; // 45

	Obj C(10, 15, 0);
	std::cout << A.GetHeadingAngle(C) << std::endl; // -90

	Obj D(5, 5, 0);
	std::cout << A.GetHeadingAngle(D) << std::endl; // 135

	return 0;
}