groundFungus:
void headToPoint(int x, int y) {
long theta = atan2(y, x);
long thetaPos; // declare an uninitialized local variable
long thetaDiff = theta - thetaPos;
What is the value of thetaPos after it is declared?
thetaPos = theta;
Isn't it correct? thetaPos stores the value of theta in the end of the function.