
04-30-2007, 10:46 PM
|
That one guy...
|
 |
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
|
|
Quote:
Originally Posted by DustyPorViva
Okay, say I have a number of directions, in this example, 16.
I have a set dir1, 6.
And I also have dir2, 1.
How would I get the 'distance', or in this case, the number of directions dir1 is from dir2?
I know in the example I posted with it, it's 2 directions away, but what would be the formula to do this? The problem arises since, like in the example, dir1 is 15, and dir2 is 1, so abs(dir2-dir1)=14.
If any of this makes sense, any advice?
|
I would suggest just doing something like:
dist = abs(dir2 - dir1);
if (dist > 8) dist = 16 - dist; |
__________________
Do it with a DON!
|
|
|