Hi, my math is pretty awful…
I’m trying to clamp an angle within a specific range with this piece of code (c#):
float a = Mathf.Clamp( Mathf.Atan2( p.y, p.x ), -Mathf.Deg2Rad*coneAngle, Mathf.Deg2Rad*coneAngle );
Unfortunately, when the coordinates px and p.y are both negative (so are in the bottom left quadrant) the returned clamped value is on the wrong side…
What is my schoolboy error?