Posts: 92
Threads: 26
Joined: Aug 2010
Reputation:
0
guyz, i have a racing script, but i need to detect angle from first two checkpoints. I can do it with "atan", bur dunno how to do. Can some1 help me?
Posts: 4,878
Threads: 85
Joined: Jun 2007
Reputation:
0
The best way would be using atan2, because you do not have to calc a lot for this. It requires the x and y difference between your two points.
All in all you could get the angle like this:
atan2(x1 - x2, y1 - y2)
with x1/y1 being your first checkpoint, and x2/y2 the other
Posts: 92
Threads: 26
Joined: Aug 2010
Reputation:
0
atan2(x1 - x2, y1 - y2)
there must be a "/" between x2 and y1, but you wrote ",". Is it true?
and how will i use it? i mean:
new Float:angle;
angle = atan2(x1 - x2, y1 - y2) ?
Posts: 4,878
Threads: 85
Joined: Jun 2007
Reputation:
0
Yep, the , is correct. There are two types of atan, the normal one (this would require a / ) and atan2 (easier to use)
The result will be the angle in degrees. Maybe it can be a negative value, not sure about this atm, if it is, you can add 180 to the result to make it more useful.
Posts: 2,929
Threads: 160
Joined: Feb 2009
Reputation:
0
You used a comma. Use '/' to divide them with each other.
Posts: 92
Threads: 26
Joined: Aug 2010
Reputation:
0
But that is "atan2", not "atan". Sorry if im wrong, but isn't it true?