Use cmath instead of math.h for primary event.