Angle distance

Started by
1 comment, last by RegularKid 20 years, 1 month ago
Ok, this is probably a dumb question, but I''m having a brain fart and can''t figure it out (also, the search seems to be down). If I have two angles (0 - 4096), I want to find the smallest angle distance between then. For example, between 2048 and 1024 would be 1024. I can figure this out with most angles using a subtract and then an ABS on the result. But, when the angles wrap around this formula doesn''t work. For example, using the angles 10 and 4090, it should return 16, but I can''t get it to work. This is bugging me because I know I have done something like this before, but like I said, I''m having a brain fart and can''t figure it out. Any ideas? Thanks!
Advertisement
diffAng = abs(A1 - A2);
if (diffAng > 2048) diffAng = 4096 - diffAng;


lonesock

Piranha are people too.
Sweet! Thanks!

This topic is closed to new replies.

Advertisement