SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/02/2013, 01:20 PM   #1
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default atan2 rotation angle between 2 points

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?
Daslee is offline   Reply With Quote
Old 19/02/2013, 01:28 PM   #2
FUNExtreme
Gangsta
 
Join Date: Mar 2008
Posts: 790
Reputation: 128
Default Re: atan2 rotation angle between 2 points

This might be interesting to read: http://forum.sa-mp.com/showthread.php?t=194942
__________________

FUNExtreme is offline   Reply With Quote
Old 19/02/2013, 01:34 PM   #3
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default Re: atan2 rotation angle between 2 points

Quote:
Originally Posted by ****** View Post
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:
pawn Code:
return angle;



Quote:
Originally Posted by FUNExtreme View Post
This might be interesting to read: http://forum.sa-mp.com/showthread.php?t=194942
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 ******
Daslee is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help For Angle Between Two Points, for SetPlayerAttachedObject MJ! Help Archive 5 14/01/2011 01:12 PM
Diference between atan2 pawn vs C versions xxmitsu Help Archive 11 01/12/2010 03:00 PM
Quaternion ( IPL ) rotation to normal rotation kurta999 Help Archive 0 29/11/2010 01:34 PM
Rotation between two points ev0lution Help Archive 6 04/04/2010 12:15 AM
asin. acos, atan, atan2 Kovacs_Richard Help Archive 1 17/11/2009 07:55 AM


All times are GMT. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.