0

I need to calculate the angles of an right triangle with the sides: screenX = 1920 and screenY = 1080.

How can i calculate the angles alpha and beta, assuming that gamma is 90° (right triangle).

I've tried it like this:
double alpha = Math.toDegrees(Math.atan(screenX/screenY)); double beta = Math.toDegrees(Math.atan((screenY/screenX)));
resulting in: alpha = 45.0 beta = 0.0

instead of the correct values: alpha = 60.65 beta = 29.35.

Zi1mann
  • 334
  • 1
  • 2
  • 15
  • 3
    You are declaring them as ints (or maybe longs), so the int division is resulting in `1` and `0` respectively. You can avoid this by using `Math.atan2` (or by explicitly coercing them to doubles, of course). – Andy Turner Dec 04 '15 at 16:41
  • Even though it was obv all the time, I didnt think about this. Thank you – Zi1mann Dec 04 '15 at 17:21

0 Answers0