atan2 rotation angle between 2 points - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: atan2 rotation angle between 2 points (
/showthread.php?tid=417037)
atan2 rotation angle between 2 points -
Daslee - 19.02.2013
How I can get rotation angle in degrees in pawn using atan2? I tried this:
pawn Code:
forward getAngleBetween(Float:x1, Float:y1, Float:x2, Float:y2);
public getAngleBetween(Float:x1, Float:y1, Float:x2, Float:y2){
new Float:angle = atan2(y1-y2, x1-x2) * 57.2957795;
return angle;
}
But got this result:
-979055680
And tried this:
pawn Code:
forward getAngleBetween(Float:x1, Float:y1, Float:x2, Float:y2);
public getAngleBetween(Float:x1, Float:y1, Float:x2, Float:y2){
new Float:angle = atan2(y2-y1, x2-x1);
return angle;
}
And here is result:
-1029692736
I also tried those codes in Java programming language, and it worked perfect, but here in pawn it's wrong. Where could be the problem?
Re: atan2 rotation angle between 2 points -
FUNExtreme - 19.02.2013
This might be interesting to read:
https://sampforum.blast.hk/showthread.php?tid=194942
Re: atan2 rotation angle between 2 points -
Daslee - 19.02.2013
Quote:
Originally Posted by ******
Angle is a float, not an integer (that function should give a warning when you compile).
|
Yes, I'm getting tag mismatch error on line:
Quote:
Originally Posted by FUNExtreme
|
Already read this, but can't find solution for my problem. Even in that topic u gave, he getting 0-360 angle, and I'm getting in thousands.
EDIT: Fixed it. Never knew that tag mismatch could do so big changes to results, thanks ******