/* * (non-Javadoc) * * @see math.geom2d.Shape2D#transform(math.geom2d.AffineTransform2D) */ public EllipseArc2D transform(AffineTransform2D trans) { // transform supporting ellipse Ellipse2D ell = ellipse.transform(trans); // ensure ellipse is direct if (!ell.isDirect()) ell = ell.reverse(); // Compute position of end points on the transformed ellipse double startPos = ell.project(this.firstPoint().transform(trans)); double endPos = ell.project(this.lastPoint().transform(trans)); // Compute the new arc boolean direct = !(angleExtent > 0 ^ trans.isDirect()); return new EllipseArc2D(ell, startPos, endPos, direct); }
public double project(Point2D point) { double angle = ellipse.project(point); // Case of an angle contained in the ellipse arc if (this.containsAngle(angle)) { if (angleExtent > 0) return Angle2D.formatAngle(angle - startAngle); else return Angle2D.formatAngle(startAngle - angle); } // return either 0 or T1, depending on which extremity is closer. double d1 = this.firstPoint().distance(point); double d2 = this.lastPoint().distance(point); return d1 < d2 ? 0 : abs(angleExtent); }