I am working on an 802.11a demod that works, for the most part, but has a bug that causes intermittent errors. I haven't finished characterizing it, but it appears that the problem is in my equalizer block.
802.11a is an OFDM signal, and each OFDM symbol has 64 sub-channels. Four of those sub-channels are pilots (known data), at sub-channels 7, 21, -7, and -21. I use the pilots to correct for any remaining carrier offset (shows up as a constant phase offset in the pilots) and timing offset (shows up as a liner offset- i.e. the phase offset is 0 at bin 0 and grows as it gets further from bin 0).
I do simple averaging to detect the carrier offset phase, and some simple manipulations before averaging to detect the time phase offset (e.g. multiply channel -21 by -1, multiply channel -7 by -3, and multiply channel 7 by 3). I'm intentionally leaving out some unneeded details, but hopefully this gives the gist of what I'm doing.
My problem is that the circular nature of angles can cause the averaging to misbehave in catastrophic ways for certain values. For instance, imagine imagine averaging $-\frac{4}{5}\pi$ and $\frac{4}{5}\pi$. It's easy to see graphically that the answer should be either $-\pi$ or $\pi$, but the standard averaging formula gives the answer of 0, literally the opposite of the correct answer.

What is the proper way to average angles?
EDIT: I'll try and make what I'm doing a little clearer. There are two "error conditions" that manifest themselves differently at the output of the FFT. First is carrier offset, which manifests itself as a constant phase offset.

For this case averaging the cartesian pilot values rather than the angle, as John suggested, is a good idea. Thank you.
The second error condition is timing offset, which manifests as a linear phase offset. The greater the time offset, the larger the slope of the phase offset. The slope can also be negative, depending on whether the receiver is ahead or behind where it should be.

Now, since it is strictly linear (the origin passes through zero), I could theoretically calculate the slope from just one pilot. I would first calculate the carrier offset phase offset (i.e. error condition #1), subtract that out, and then use any of the four to calculate the slope. That would avoid averaging altogether. The problem is that noise can make these values jump around, so my estimate is much better if I use all four- thus the averaging.
Hopefully the picture above makes it clear that I can't just take the pilot values and average them as is- I have to modify them to make them a constant + noise. I do this by multiplying the angle of the -21 pilot by -1, the -7 pilot by -3, the 7 pilot by 3, and the 21 pilot by 1. They thus become equivalent to the 21 pilot and can be averaged.

I don't know of a good way to multiply the angle of a vector by a constant like "3" in the cartesian system, so it looks to me like I would have to convert to polar coordinates, multiply the angles by -1, -3, 3, and 1 respectively, convert back to cartesian coordinates, average the pilots, then convert back to polar to get the phase offset. While this is do-able, I would like to find a less klunky solution if possible.