# 2D Vector Compass Direction [duplicate]

Relating to this question; What's the best way of transforming a 2D vector into the closest 8-way compass direction?

My query is if this would work in the following order(below) and if so, how would i achieve that?

 enum compassDir {
S = 0, SE = 1,
E = 2, NE = 3,
N = 4, NW = 5,
W = 6, SW = 7
};

• -1 Are you asking for clarification to the answer of another question? Write a comment instead. – Anko Jul 19 '13 at 11:00
• Your starting angle should have an offset. In 2D that would be +90 degrees. or +PI/4 radians. Since south is pointing downwards. – Sidar Jul 19 '13 at 11:31
• I feel like this question could easily be answered by trying it. This is almost entirely a coding challenge. The answer I gave goes clockwise around the compass, so the enums are ordered in that way. You have your enums with a different offset and order. Think about how you might reverse the order the while loop traverses the compass. Yes it's possible, but I'm not going to write the code for you :) I agree with Anko, this should be a comment on the original post. – MichaelHouse Jul 19 '13 at 12:57
• Yeah sorry guys, dumb question. I had it the right code all along but after the clarification by Sidar, i realised i had made a typo when the direction gets set. Shit happens :p – dan369 Jul 20 '13 at 11:20