Limit angle in segment - MathOverflow [closed] most recent 30 from http://mathoverflow.net 2013-05-23T04:37:14Z http://mathoverflow.net/feeds/question/29183 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/29183/limit-angle-in-segment Limit angle in segment TandemAdam 2010-06-23T01:24:49Z 2010-06-23T01:24:49Z <p>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.</p> <p><a href="http://sandbox.adamharte.com/dump/trigdiagram.jpg" rel="nofollow">Diagram of my problem</a>.</p> <p>I am trying to calculate this for a computer program, where I have an angle (<em>slope</em>), and a point (the mouse pointer). The distance does not matter to me, just the angles. If the point is within <em>b1</em> (green area) then that's fine. But if the point is within <em>b2</em> or <em>b3</em> (red or orange) areas, then the angle should snap back to the limit of the green area (along the line <em>s</em>).</p> <p>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.</p> <p>I am also having trouble because <em>s</em> could be any angle, so I am being tripped up because I can't just do something like this:</p> <blockquote> <p>if <em>a</em>(radians) is greater than <em>s</em>(radians) then set <em>a</em> to the value of <em>s</em></p> </blockquote> <p>or I will get errors when the angle goes between zero and 2Pi.</p> <p>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?</p> <p>Thanks for reading my questing.</p>