Мне нужно рассчитать угол в градусах между двумя точками для моего собственного класса Point, точка a будет центральной точкой.
Метод:
public float getAngle(Point target) {
return (float) Math.toDegrees(Math.atan2(target.x - x, target.y - y));
}
Тест 1://возвращает 45
Point a = new Point(0, 0);
System.out.println(a.getAngle(new Point(1, 1)));
Тест 2://возвращает -90, ожидается: 270
Point a = new Point(0, 0);
System.out.println(a.getAngle(new Point(-1, 0)));
Как преобразовать возвращаемый результат в число от 0 до 359?