title: How are angles on QPainterPath::arcTo interpreted?
body: <p>I'm working on feature of a graphic editor where I'm editing arcs, and QPainterPath::arcTo is not behaving as I expected when the shape is an ellipse; it works as expected when it's a circle.</p>
  
  <p>The two images below show the results. In the first case, I've created a circle, which I then convert to an arc with an initial start angle of 45 and span angle of 270. The scene coordinate space is square. The diagonal lines are at 45 degrees. As expected, the circular arc's end points are exactly on the diagonal lines.</p>
  
  <p>In the second case, I have an ellipse, which is converted to an arc in exactly the same way with 45 and 270 degree angles respectively. The end points of the arc no longer fall on the diagonal lines, which is not what I expect.</p>
  
  <p>In both cases, the drawing code is:</p>
  
  <pre><code>painter.arcTo (rect, 45, 270);
  </code></pre>
  
  <p>Zero degrees is at the 3 o'clock position, and I had believed that the specified angle was measured between that and a line from the center point to the point on the arc edge. Clearly, something else is going on that I don't understand and doesn't appear to be documented in the QPainter::arcTo description.</p>
  
  <p>This is an issue because I'm writing code to reshape the arc, and I need to be able to work backgrounds when all I have is the current mouse position and the center point of the encompassing rectangle. Right now, as I reshape the arc, the angle that I'm calculating is only accurate at 0, 90, 180, and 270. The closer I get to the intervening 45 degree angles, the further off my angle is.</p>
  
  <p>I'm getting that angle by:</p>
  
  <pre><code>QLineF (rect.center(), mouse_pos).angle ();
  </code></pre>
  
  <p>Again, for circles, this works perfectly. For non-circular ellipses, it doesn't.</p>
  
  <p>After writing this up, I found this <a href="https://tex.stackexchange.com/questions/47611/is-it-a-bug-in-psellipticarc-or-is-my-calculation-wrong">beautiful illustration</a>, which exactly demonstrates what I'm dealing with. Unfortunately, the Postscript solution isn't helpful for me. I need to know what to do to calculate the correct angles.</p>
  
  <p><a href="https://i.stack.imgur.com/59zRk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/59zRk.png" alt="Circular arc with start angle of 45 and span angle of 270"></a></p>
  
  <p><a href="https://i.stack.imgur.com/dIsrE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dIsrE.png" alt="Elliptical arc with start angle of 45 and span angle of 270"></a></p>