How to get North / South / East / West from a vector

Post here if you want to help developing something for FAF.

How to get North / South / East / West from a vector

Postby Resin_Smoker » 22 Jan 2015, 16:36

This is something I'd liked to have known a long time ago...

Feed in the x and z data from your three point vector...
Code: Select all
local heading = math.atan2( vector[1], vector[3] )
LOG(' heading: ', heading)


A log result of:

Spoiler: show
0 = north
- values = east
+ values = west
3 = south


Hence a value of -2.4257481098175 is somewhere south / east of our target. (Relative to the map not the unit)

Note: Used the vector data from unit.lua DoTakeDamage to test this. No engineers were hurt during the testing of this script.

Resin
Resin_Smoker
Evaluator
 
Posts: 858
Joined: 14 Mar 2012, 17:58
Has liked: 54 times
Been liked: 106 times

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest