Use trig for the averaging