-
Member
[Request] Help with coördinates walking / source code.
Dear ownedcore,
I'm currently writing a bot which reads my current position (X,Y Coordinate) and heading (facing from north in degrees). What I want to is fill in coordinates I want to go to, then based on the coordinates I'm currently on, calculate the heading I need to face in order to get to the destination coordinates. Now I've done some research and figured out the Atan2 function is the way to do it.
What I've learned about the WoW coordinate system is:
-If you walk south, your Y coördinate value increases.
-If you walk east, your X coördinate value increases.
Now based on this I set up this Atan2 function in C#:
Code:
double angle = Math.Atan2(bX - aX, bY - aY) / (Math.PI /180) + 180;
Whereas b stands for destination, and a for current location. Which basically means, delta X and delta Y.
Now this all seemed to make total sense and worked perfectly for all basic angles (90° and 45°).
A quick example:
Code:
aX = 50.00
aY = 80.00
bX = 52.00
bY = 52.00
(A 45° angle).
would return 225°, which fits perfectly with the ingame degree system. I've tested all angles ingame (45,90,135,180,225,270,315 & 360°). Everything worked perfectly.
Now everything made total sense until this point, whereas I ended up testing some "real" coördinates, and things seemed to be a little off here.
Code:
double aX = 49.004501104355 ;
double aY = 93.001425266266;
double bX = 50.004827976227;
double bY = 88.004219532013;
would return the angle 348,680303112313. Now if you look at my attatchment:
you can see that if I follow this heading it would get me to 49,66 - 88,00 rather than 50,00 - 88,00.
Is there someone who can explain the difference between these kind of angles and the classic 45° and 90° angles? Is there some kind of offset I'm missing? I know that people have done this kind of "basic" thing and I'm really interested in the solutions people have come up with. Perhaps people have encountered this same issue, or have another solution that works? If so, I would be really greatful if someone can provide me some source code.
Thanks in advance,
Dronelol
Last edited by Dronelol; 02-06-2014 at 09:05 PM.
-
Post Thanks / Like - 1 Thanks
MurderBurger (1 members gave Thanks to Dronelol for this useful post)
-
Member
Been months since I posted this without replies, perhaps people would know a solution by now