Answer the question
In order to leave comments, you need to log in
How to calculate mathematical degrees?
Hello people. I'm making a simple game, in which you need to make sure that the tower object always turns towards the player, in this picture: A is the tower object itself, and (B) is the player.
They are at the position (x, y) = A(100, 100), B (200, 200)
So in the photo you can presumably say that the tower should be rotated 135 degrees.
I did the calculations (the formula is visible in the picture) I got 0 in the results, PLEASE TELL ME WHERE I made a mistake? even when I tried to make such values so that there was no zero in arctg, it still showed incorrect degrees.
Answer the question
In order to leave comments, you need to log in
And the arc tangent must be taken arctan((200−100)/(200−100))
In addition, for this there is a function atan2, defined for all x and y that are not equal to 0 at the same time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question