/** * Transforms this circle by an affine transform. If the transformed shape is a circle (ellipse * with equal axis lengths), returns an instance of Circle2D. The resulting ellipse is direct if * this ellipse and the transform are either both direct or both indirect. */ public EllipseShape2D transform(AffineTransform2D trans) { // When the transform is not a similarity, should switch to EllipseArc // computation if (!AffineTransform2D.isSimilarity(trans)) { return this.asEllipse().transform(trans); } // If transform is a similarity, the result is a circle Point2D center = this.center().transform(trans); Point2D p1 = this.firstPoint().transform(trans); boolean direct = !this.direct ^ trans.isDirect(); Circle2D result = new Circle2D(center, center.distance(p1), direct); return result; }
/* * (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); }