title: How to calculate arcTo parameters in Android path
body: <p>I am porting some code to Android from Visual C++. The VC++ ArcTo function takes the bounding rectangle and the start and end points as parameters to define the arc. The android.graphics.Path function arcTo takes the bounding rectangle and the "start angle" and "sweep angle" as parameters.</p>
  
  <p>I am not clear how to convert from the VC set of coordinates to the Android set, or what these two angles are. The arc also has direction (CW or ACW) - I am not clear how to incorporate these in a single Path, or how to switch between one and the other.</p>
  
  <p>One oddity I came across is that in the Android function, angles are expressed in degrees, rather than radians which is what most calculations would use and what one would expect.</p>
  
  <p>I hope my question makes some sort of sense and that someone can help!</p>
  
  <p>Edit: following on from the help I got from Dr Dredel, and with much drawing of diagrams, here's how I eventually translated the VC++ call to Android:  </p>
  
  <pre><code>else if (coord.isArc())  
  {  
      ptCentre = getPoint(new Coord(coord.getArcLat(), coord.getArcLong()));  
      nRadius = getPixels(coord.getArcRadius());  
      rect = new RectF(ptCentre.x - nRadius, ptCentre.y - nRadius,  
                       ptCentre.x + nRadius, ptCentre.y + nRadius);  
      if (coord.isClockwise())  
      {  
          alpha = Math.atan2(ptCentre.y - ptStart.y, ptCentre.x - ptStart.x) *  
                             Constants.k_d180Pi;  
          beta = Math.atan2(ptCentre.y - ptEnd.y, ptEnd.x - ptCentre.x) *  
                             Constants.k_d180Pi;  
          path.arcTo(rect, (float)(alpha + 180), (float)(180 - beta - alpha));  
      }  
      else  
      {  
      }
  </code></pre>
  
  <p>As you can see, I haven't done the anti-clockwise arc yet, but it should be similar. My calculation wasn't perfect, as I originally had (360 - beta - alpha) instead of (180 - beta - alpha), and the original version gave some very funny results!<br>
  (Wow! this formatting mechanism is the other side of weird!)</p>