Vec2 dir = c2.minus(c1);
Vec2 norm = new Vec2(dir.y, -dir.x).mult(deviation);
Vec2 middle = c1.plus(c2).div(2.0f).plus(norm);
QuadCurve2D curve = new QuadCurve2D.Float(c1.x, c1.y, middle.x, middle.y,
c2.x, c2.y);
QuadCurve2D last = new QuadCurve2D.Float();
// enable GL_LINE_STIPPLE if edge must be dashed
if (dashed) {
gl.glEnable(GL2.GL_LINE_STIPPLE);
gl.glLineStipple(1, (short) 0xf0f0);
}
boolean ok = drawCurve(gl, center1, center2, curve, shape1, shape2, last);
// now disable GL_LINE_STIPPLE if it was enabled
if (dashed) {
gl.glDisable(GL2.GL_LINE_STIPPLE);
}
if (ok) {
// draw the head at the last position, trying to orient it so that it
// follows the last segment of the "line".
double x1 = last.getP1().getX();
double y1 = last.getP1().getY();
double x2 = last.getP2().getX();
double y2 = last.getP2().getY();
double slope = (y2 - y1) / (x2 - x1);
double angle = (float) Math.tanh(slope) - Math.PI / 2.0;
if (x2 < x1) {
angle += Math.PI;
}
head.setTranslation((float) (last.getP2().getX()), (float) (last.getP2()
.getY()), 0f);
head.setScale(8f, 8f, 8f);
head.setRotation(angle);
head.fill(gl);
}
QuadCurve2D left = new QuadCurve2D.Float();
QuadCurve2D right = new QuadCurve2D.Float();
curve.subdivide(left, right);
return right.getP1(); // new Point2D.Float(middle.x, middle.y);
}