Search code examples
javageometrycurvequadratic

Mid-point of QuadCurve2D


I'm using Java's QuadCurve2D and I'd like to show an anchor point exactly half way across this curve. I have code like this:

Point anchor = anchor();    
if (showArcHandle) {
    Ellipse2D.Float e = new Ellipse2D.Float(anchor.x-ANCHOR_RADIUS, anchor.y-ANCHOR_RADIUS, 2*ANCHOR_RADIUS, 2*ANCHOR_RADIUS);
    g2.draw(e);
}

but this was assuming that the anchor point was the same as the control point in the QuadCurve API.

As my anchor point is always half way across the curve, and the curve is always symmetric, is there a way to find this point, which should rest on the line?

I hope that makes sense, if anything needs clarifying, please ask.

Thanks


Solution

  • Don't know for sure ... but QuadCurve2D.subdivide(QuadCurve2D,QuadCurve2D) mentiones 2 halfs.