title: Stroking lines and computing line joins
body: <p>does anyone have any tips/ideas on how to calculate Round line joins?
  The device I'm working on only supports single width lines. 
  I am trying to implement basic stroking with only round line joins.</p>
  
  <p>Some things I'm messing with are below. 
  It's not much, but I hope to get some ideas on how to handle the different cases when two lines join, based on any replies.</p>
  
  <p>Thanks in advance for any help.</p>
  
  <p>I have had some progress with the outer join:</p>
  
  <p>a. Get clockwise order vertices (I get these from flattened glyphs)<br>
  b. Grab 3 vertices<br>
  c. Compute normal of line A (prevX, prevY) -> (currentX, currentY)<br>
  d. Compute normal of line B (currentX, currentY) -> (nextX, nextY)<br></p>
  
  <p>I compute normals using a left turn on the current clockwise vertices<br>
  normal = (deltaY, -deltaX) // Thanks Andreas</p>
  
  <pre><code>Vec2[] computeNormals(float prevX, float prevY, float x, float y, float nextX, float nextY) {
      float dx1 = x - prevX;
      float dy1 = y - prevY;
  
      float dx2 = x - nextX;
      float dy2 = y - nextY;
  
      Vec2 normal1 = new Vec2(dy1, -dx1).normalize();
      Vec2 normal2 = new Vec2(dy2, -dx2).normalize();
      if (normal1.angleDeg() &gt; normal2.angleDeg()) {
          normal2.rot((float) Math.PI);
      }
  
      return (new Vec2[] { normal1, normal2 });
  }
  </code></pre>
  
  <p>e. Determine outer join arc angle from atan2(deltaY, -deltaX)</p>
  
  <pre><code>void computeArc(VertexBuffer dest, float x, float y, float arcRadius, Vec2 normal1, Vec2 normal2) {
      // Angle from Vecto2D is atan2(y, x)
      float angleStart = normal1.angle();
      float angleEnd = normal2.angle();
  
      float angleInc = (float) Math.PI / 4f; // Temporary, need to find a way to determine numVertices for a Pen of a given width
      while (angleStart &gt; angleEnd) {
          angleStart -= (float) (2f * Math.PI);
      }
      for (float a = angleStart; a &lt;= angleEnd; a += angleInc) {
          float vx = x + ((float) Math.cos(a) * arcRadius);
          float vy = y + ((float) Math.sin(a) * arcRadius);
          dest.addVertex(vx, vy);
      }
  }
  </code></pre>