Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see math.geom2d.circulinear.CirculinearCurve2D#transform(math.geom2d.transform.CircleInversion2D)
   */
  public CircleLine2D transform(CircleInversion2D inv) {
    // Extract inversion parameters
    Point2D center = inv.center();
    Point2D c1 = this.center();

    // If circles are concentric, creates directly the new circle
    if (center.distance(c1) < Shape2D.ACCURACY) {
      double r0 = inv.radius();
      double r2 = r0 * r0 / this.r;
      return new Circle2D(center, r2, this.direct);
    }

    // line joining centers of the two circles
    StraightLine2D centersLine = new StraightLine2D(center, c1);

    // get the two intersection points with the line joining the circle centers
    Collection<Point2D> points = this.intersections(centersLine);
    if (points.size() < 2) {
      throw new RuntimeException(
          "Intersection of circle with line through center has less than 2 points");
    }
    Iterator<Point2D> iter = points.iterator();
    Point2D p1 = iter.next();
    Point2D p2 = iter.next();

    // If the circle contains the inversion center, it transforms into a
    // straight line
    if (this.distance(center) < Shape2D.ACCURACY) {
      // choose the intersection point that is not the center
      double dist1 = center.distance(p1);
      double dist2 = center.distance(p2);
      Point2D p0 = dist1 < dist2 ? p2 : p1;

      // transform the point, and return the perpendicular
      p0 = p0.transform(inv);
      return StraightLine2D.createPerpendicular(centersLine, p0);
    }

    // For regular cases, the circle transforms into an other circle

    // transform the two extreme points of the circle,
    // resulting in a diameter of the new circle
    p1 = p1.transform(inv);
    p2 = p2.transform(inv);

    // compute center and diameter of transformed circle
    double diam = p1.distance(p2);
    c1 = Point2D.midPoint(p1, p2);

    // create the transformed circle
    boolean direct = !this.isDirect() ^ this.isInside(inv.center());
    return new Circle2D(c1, diam / 2, direct);
  }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see math.geom2d.Shape2D#transform(math.geom2d.AffineTransform2D)
   */
  public PointArray2D transform(AffineTransform2D trans) {
    PointArray2D res = new PointArray2D(points.size());

    for (Point2D point : points) res.add(point.transform(trans));

    return res;
  }
Ejemplo n.º 3
0
  public PointArray2D transform(CircleInversion2D inv) {

    PointArray2D array = new PointArray2D(points.size());

    for (Point2D point : points) array.add(point.transform(inv));

    return array;
  }