> You may have misaprehended the problem and are trying to > get the math to solve the _wrong_ thing. I could live with that! :) >I haven't been following this > thread so this may already have been proposed: but the 'average' > of a set of bearing VECTORS is certainly just their vector sum > (normalized to some length) and since you just want bearing=angle > you can ignore the length. Not exactly. My incoming data all has a radius of 1, but I need to average a lot of bearings, and I need an indictor of how much spread there was in the data. The radius gives me that. > So if you have the bearings in rectangular coordinates just > do the (multibyte) summations and then the ratio-> trig on the two > most significant bytes. (Involves 16 bit division). That's where I'm at. I have the grand sum as a 16 bit value for X and Y, made up of N samples, where N can be >16, and <=FFFF > It is difficult for me to see how the 'average' of just two opposite > bearings isn't either zero or UNDEF. It is, but the radius is zero (or nearly so) and so I toss it. > Your explanation also seems to suggest you want a 'recent' > average i.e. some time averaging as well. You can get this by saving > the two most sig. bytes of the sum which is at least 8-bit accurate > Also if 'noisy' measurements result (somehow) in shorter > vectors then these would contribute proportionately less to > the vector sum and average.. Yup, that's handled. A new bearing sample gets converted to rect, and stored in the level 1 buffer. Each entry from this point onward is an XY pair, not necessarily on the unit circle. When level 1 becomes full (16 pairs) then I average level 1 and create a level 2 entry. .... When level 4 becomes full, (or if I stop getting bearing inputs) I take the highest level with data in it, and average that, and calculate the radius. If the radius is small, then the data is "unusable" and is just dumped. If the radius is large, then I'll need the result bearing, which is what has me stuck. I've got time to calculate though, which is good. While I have data coming in, it may be as slow as 300S/Sec, or as fast as 4000S/Sec, so the rectangular math is a big winner on speed.