In a 2D grid, I have the center location of all tiles on the map in an array. I also have the character's facing ray (the starting position is the player's position). The character can rotate 360 degrees.
My goal would be to sort the array by the distance they are to that ray in a sweeping motion from the character's position outwards.
If you had two second hands on a clock set to noon, one going clockwise and the other going counter clockwise, the array would be:
12, 1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6
The only difference between that and what I'm hoping for is to do it on a 2D grid of tiles rather than just the numbers on a clock . Well, that and I'd hope if the lines intersect multiple tiles that I could add those tiles to the array based on their distance to the player.
Can someone point me in the right direction for this, perhaps even a term to describe the concept? If I'm not describing it well enough, please let me know and I'll do my best to draw a picture.