Exemplo n.º 1
0
  /**
   * 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;
  }
Exemplo n.º 2
0
 @Override
 public Ray2D transform(AffineTransform2D trans) {
   double[] tab = trans.coefficients();
   double x1 = x0 * tab[0] + y0 * tab[1] + tab[2];
   double y1 = x0 * tab[3] + y0 * tab[4] + tab[5];
   return new Ray2D(x1, y1, dx * tab[0] + dy * tab[1], dx * tab[3] + dy * tab[4]);
 }
Exemplo n.º 3
0
  @Override
  public void update() {
    this.defined = false;

    // check parents are defined
    if (!parent1.isDefined()) return;
    if (!parent2.isDefined()) return;

    Shape2D shape;

    // extract first point
    shape = parent1.getShape();
    if (!(shape instanceof Point2D)) return;
    Point2D point1 = (Point2D) shape;

    // extract second point
    shape = parent2.getShape();
    if (!(shape instanceof Point2D)) return;
    Point2D point2 = (Point2D) shape;

    // update distance measure
    this.trans =
        AffineTransform2D.createTranslation(
            point2.getX() - point1.getX(), point2.getY() - point1.getY());

    this.defined = true;
  }
Exemplo n.º 4
0
  /*
   * (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);
  }