[SOLVED] Limiting camera rotation?

I’m writing a gaming library right now, and I’ve accomplished so much yet somehow I can’t wrap my head around how to do this. Here’s the current method I plan on using to limit camera rotation.


public void limitXRotation(float minimum, float maximum) {}

Normally this would be a very simple mechanic to implement, for example:


if(rotx < minimum) rotx = minimum;
if(rotx > maximum) rotx = maximum;

Here comes my problem though, the library makes it so that the rotation value can only ever be a value between 0 and 360 (if the value becomes 361, it resets the value to 1). If I entered a value, for example, minimum = 20 and maximum = 120 there’d be no problem. But what if I want to limit the rotation between 280 and 80. This would be the most likely limitation on the rotation because this would be how I’d mimic a person looking up and down. I just can’t seem to grasp how I’d be able to accomplish this, because if the rotation value was 280, but the maximum was 80, the aforementioned code would set the rotation value back to 80.

I’m sorry if I’m not making much sense, I really don’t know how to word what I’m trying to accomplish properly.