Home   Help Search Login Register  

Author Topic: angle between objects...  (Read 503 times)

0 Members and 1 Guest are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
angle between objects...
« on: 24 Feb 2005, 16:58:12 »
i have looked in the faq, and i see a couple on setdir and distance between - close but no cigar. i know this has been asked before, so apologies....

i need to know the trig involved in finding the degree heading between two objects. the purpose is to sidestep the dowatch getpos object route and force a setdir relative to the player.

i know it's something to do with subtracting the x and y values of the target from the source, and then some sin/cos doohicky... i dunno, maths was never my strong point.

cheers meantime :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:angle between objects...
« Reply #1 on: 24 Feb 2005, 17:04:46 »
Try:

(x2-x1) atan2 (y2-y1)

where X is result of getPos select 0 on the two objects
and Y is the result of getPos select 1 on the two objects

The resulting angle is the direction of object 2 from object 1 in degrees, in the range -180 to +180.
« Last Edit: 24 Feb 2005, 17:09:31 by THobson »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:angle between objects...
« Reply #2 on: 24 Feb 2005, 17:09:38 »
There are a couple of trig guides in the Ed Depot, and every now and again a kind soul like THobson posts something like this in the forums.

I also have a feeling somebody made a function that does this.  It is the sort of thing functions are for.
Plenty of reviewed ArmA missions for you to play

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:angle between objects...
« Reply #3 on: 24 Feb 2005, 17:16:08 »
y'know, i've just finished putting a textual head-nod to you (THobson) at the top of these scripts i'm working on, for pointers on direction. looks like another is in order :)

many thanks.

(you get a head nod too gubes, just cos you're so special  :-* )
« Last Edit: 24 Feb 2005, 17:19:27 by bedges »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:angle between objects...
« Reply #4 on: 24 Feb 2005, 17:21:45 »
I appreciate it.  

Actually I do have horrible admission to make.  I really, really like maths and always have.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:angle between objects...
« Reply #5 on: 24 Feb 2005, 17:23:50 »
 ;D :booty:

I used to like maths a bit, when I could remember some.    Never trig though.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:angle between objects...
« Reply #6 on: 24 Feb 2005, 18:05:07 »
You know I am a smilie illiterate and now you are confusing me with ones that move!