I have an angle defined as such:
accelerationX = acceleration.x * kFilteringFactor + accelerationX * (1.0 - kFilteringFactor);
accelerationY = acceleration.y * kFilteringFactor + accelerationY * (1.0 - kFilteringFactor);
double angle = atan2(accelerationY, -accelerationX) + M_PI/2;
I want to limit the value of angle to minimum -pi/3 and max pi/3. So if the value goes over pi/3, it should just stay at pi/3. How can I do this?
1 Answer