0

I need to limit an angle so it fits into a segment. I have drawn and links to a diagram below to better describe what I am after.

Diagram of my problem.

I am trying to calculate this for a computer program, where I have an angle (slope), and a point (the mouse pointer). The distance does not matter to me, just the angles. If the point is within b1 (green area) then that's fine. But if the point is within b2 or b3 (red or orange) areas, then the angle should snap back to the limit of the green area (along the line s).

The main problem I am having in figuring this out, is snapping the angle to the correct side e.g. If the point is in the red area, then the angle should snap to the angle s on the red side and vice versa.

I am also having trouble because s could be any angle, so I am being tripped up because I can't just do something like this:

if a(radians) is greater than s(radians) then set a to the value of s

or I will get errors when the angle goes between zero and 2Pi.

So How would I work this out? Do I have to rotate everything back to a zero point or something then put it back when I have made my calculations?

Thanks for reading my questing.

flag
not sure that MO is really the right place for your question: see the FAQ. I'm not myself sure where else to recommend getting help with your question, but perhaps someone else can leave suggestions in a comment? – Yemon Choi Jun 23 2010 at 1:52
How is this different than testing which side of the line you're on? (This is easy to do: if the line has equation $y = mx + b$, one side is where $y - mx - b$ is positive and the other is where it's negative. As far as I can tell, you just need to do this once for line $s$, then (if you end up on the wrong side) do it again for the line dividing the red and orange sectors.) – JBL Jun 23 2010 at 2:19
MathOverflow is intended for research mathematics. Please see the faq for suggestions of sites where to ask this question - mathoverflow.net/faq#whatnot – François G. Dorais Jun 23 2010 at 3:09

closed as too localized by Yemon Choi, François G. Dorais Jun 23 2010 at 3:08

Browse other questions tagged or ask your own question.