Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think this works, but I haven't tested it thoroughly. You have 2 arcs and each arc has a start angle and a stop angle. I'll work this in degrees measured clockwise from north, as you have done, but it will be just as easy to work in radians measured anti-clockwise from east as the mathematicians do.</p> <p>First 'normalise' your arcs, that is, reduce all the angles in them to lie in <code>[0,360)</code>, so take out multiples of 360deg and make all the angles +ve. Make sure that the stop angle of each arc lies to clockwise of the start angle.</p> <p>Next, choose the start angle of one of your arcs, it doesn't matter which. Sort all the angles you have (4 of them) into numerical order. If any of the angles are numerically smaller than the start angle you have chosen, add 360deg to them.</p> <p>Re-sort the angles into increasing numerical order. Your chosen start angle will be the first element in the new list. From the start angle you already chose, what is the next angle in the list ?</p> <p>1) If it is the stop angle of the same arc then either there is no overlap or this arc is entirely contained within the other arc. Make a note and find the next angle. If the next angle is the start angle of the other arc there is no overlap and you can stop; if it is the stop angle of the other arc then the overlap contains the whole of the first arc. Stop</p> <p>2) If it is the start angle of the other arc, then the overlap begins at that angle. Make a note of this angle. The next angle your sweep encounters has to be a stop angle and the overlap ends there. Stop.</p> <p>3) If it is the stop angle of the other arc then the overlap comprises the angle between the start angle of the first arc and this angle. Stop.</p> <p>This isn't particularly elegant and relies on ifs rather more than I generally like but it should work and be relatively easy to translate into your favourite programming language. </p> <p>And look, no trigonometry at all !</p> <p><strong>EDIT</strong></p> <p>Here's a more 'mathematical' approach since you seem to feel the need.</p> <p>For an angle theta in <code>(-pi,pi]</code> the hyperbolic sine function (often called <code>sinh</code>) maps the angle to an interval on the real line in the interval (approximately) <code>(-11.5,11.5]</code>. Unlike <code>arcsin</code> and <code>arccos</code> the inverse of this function is also single-valued on the same interval. Follow these steps:</p> <p>1) If an arc includes 0 break it into 2 arcs, <code>(start,0)</code> and <code>(0,stop)</code>. You now have 2, 3 or 4 intervals on the real line.</p> <p>2) Compute the intersection of those intervals and transform back from linear measurement into angular measurement. You now have the intersection of the two arcs.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload