p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
double[] p2 = new double[]{b.P1.getX(), b.P1.getY()};
double[] p3 = b.cp1();
Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true);
if( p == null || insideP == null )
a.add(new LineSegment(a.last.P2, b.P1));
else if((p.distance(insideP)/width) < limit)
{
a.add(new LineSegment(a.last.P2, p));
a.add(new LineSegment(p, b.P1));
}
else
{
// outside miter limit, do a bevel join.
a.add(new LineSegment(a.last.P2, b.P1));
}
break;
case JOIN_ROUND:
p0 = a.last.cp2();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
dx = p1[0] - p0[0];
dy = p1[1] - p0[1];
l = Math.sqrt(dx * dx + dy * dy);
dx = 0.5*width*dx/l;
dy = 0.5*width*dy/l;
c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
p0 = new double[]{b.P1.getX(), b.P1.getY()};
p1 = b.cp1();
dx = p0[0] - p1[0]; // backwards direction.
dy = p0[1] - p1[1];
l = Math.sqrt(dx * dx + dy * dy);
dx = 0.5*width*dx/l;
dy = 0.5*width*dy/l;
c2 = new Point2D.Double(p0[0] + dx, p0[1] + dy);
a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));
break;
case JOIN_BEVEL:
a.add(new LineSegment(a.last.P2, b.P1));
break;
}
}