This has been bugging me for some time: I need some spiffy math that can figure out if any two angles are facing the same general direction(within 180 in this case). So far it sounds simple enough until you run into the wall of what happens when you have an angle of 350 and an angle of 10, you and I know they're only 20 apart but try teaching that to a trigger :P Well that's what I'm trying to do and I'm failing miserably. Any help? Btw the specific range I'm working with is -180 and 180 in order to stay closest to how the engine appears to really handle them.
Thank you thank you thank you! I knew there was some fun math that could be done to do it, too bad I suck so much at it. Greatly appreciate you coming up with that formula, I haven't got a chance to try it at the moment but just running it through some test cases in my head it looks like it'll work regardless of a 0/360 or -180/180 method is used which is even better then I thought possible :)
This has been bugging me for some time: I need some spiffy math that can figure out if any two angles are facing the same general direction(within 180 in this case). So far it sounds simple enough until you run into the wall of what happens when you have an angle of 350 and an angle of 10, you and I know they're only 20 apart but try teaching that to a trigger :P Well that's what I'm trying to do and I'm failing miserably. Any help? Btw the specific range I'm working with is -180 and 180 in order to stay closest to how the engine appears to really handle them.
@BumpInTheNight: Go
Make a function AreAnglesClose(AngleOne, AngleTwo, MaximumArc).
Then the math for that function is:
CalculatedArc= AbsoluteValue(AngleOne - AngleTwo).
If(CalculatedArc> 180): CalculatedArc= AbsoluteValue(CalculatedArc- 360)
Return CalculatedArc < MaximumArc
Thank you thank you thank you! I knew there was some fun math that could be done to do it, too bad I suck so much at it. Greatly appreciate you coming up with that formula, I haven't got a chance to try it at the moment but just running it through some test cases in my head it looks like it'll work regardless of a 0/360 or -180/180 method is used which is even better then I thought possible :)
Aight, she works great man:
Thanks again!