I was working collisions of spiders and 2 spiders going in same direction or nearly so needed collision code different from spiders coming head on or perpendicular to each other.
So how do I tell if spiders are going in same direction or nearly so, say their headings are within 30 degrees of each other or not?
Just subtract the angles right? Or take the ABS of the difference right?
Well what if one has a heading of 0 degrees and the other a heading of 350 degrees the difference is 350, I am wanting 10 degrees so make 0 360 instead, easy right?
So now what if one was x and the other y when do I know to add 360? like with 0.
I came up with a function AngleDifference to handle this because this issue has come up before but it seems kind of clunky. I think the time before I used Major and Minor arc differences, two answers to angle difference. This time one answer but again seems cluncky.
I won't show my code because I don't want to bias someone coming up with maybe a more elegant solution which I suspect exists.
So if you can do it in a line or 2 I'd be interested.
So how do I tell if spiders are going in same direction or nearly so, say their headings are within 30 degrees of each other or not?
Just subtract the angles right? Or take the ABS of the difference right?
Well what if one has a heading of 0 degrees and the other a heading of 350 degrees the difference is 350, I am wanting 10 degrees so make 0 360 instead, easy right?
So now what if one was x and the other y when do I know to add 360? like with 0.
I came up with a function AngleDifference to handle this because this issue has come up before but it seems kind of clunky. I think the time before I used Major and Minor arc differences, two answers to angle difference. This time one answer but again seems cluncky.
I won't show my code because I don't want to bias someone coming up with maybe a more elegant solution which I suspect exists.
So if you can do it in a line or 2 I'd be interested.
b = b + ...