Home   Help Search Login Register  

Author Topic: dist/dir into x/y coords?  (Read 443 times)

0 Members and 1 Guest are viewing this topic.

Grendel

  • Guest
dist/dir into x/y coords?
« on: 20 Aug 2003, 00:59:46 »
First, thanks for taking the time to check this question out!
 ??? :-\
My question is how to calculate x/y coordinates from a direction (in degrees);  lets say the player sees something, and uses his compass to determine that the something is at 45 degrees (or a script uses GetDir to find out), and 1000 meters away.  How do I calculate the direction and degrees into x/y coordinates?  I've tried looking at some scripts that I think are doing this, and it uses Sin and CoSin functions (which is beyond my current level of mathmatic ability).  I would really appreciate someone who could show me the correct equation needed.

Grendel

  • Guest
Re:dist/dir into x/y coords?
« Reply #1 on: 20 Aug 2003, 01:20:52 »
I did some more digging and I think I'm on the right track, but I'm not positive. would this work?

_xtarget=_xplayer + (_targetdistance * (sin(_playerdirection)));
_ytarget=_yplayer + (_targetdistance * (cos(_playerdirection)));
« Last Edit: 20 Aug 2003, 01:43:38 by Grendel »

Grendel

  • Guest
Re:dist/dir into x/y coords?
« Reply #2 on: 20 Aug 2003, 01:40:48 »
 :D
Answered my own darn question...
Did some trial and error using the windows calculator, and it works...
so if anyone needs a calculation for, say, polar plot artillery missions - that would work.