Exemplo n.º 1
0
  /** Returns a new EllipseArc2D. */
  public EllipseArc2D subCurve(double t0, double t1) {
    // convert position to angle
    t0 = Angle2D.formatAngle(startAngle + t0);
    t1 = Angle2D.formatAngle(startAngle + t1);

    // check bounds of angles
    if (!Angle2D.containsAngle(startAngle, startAngle + angleExtent, t0, angleExtent > 0))
      t0 = startAngle;
    if (!Angle2D.containsAngle(startAngle, startAngle + angleExtent, t1, angleExtent > 0))
      t1 = angleExtent;

    // create new arc
    return new EllipseArc2D(ellipse, t0, t1, angleExtent > 0);
  }
Exemplo n.º 2
0
  public Box2D boundingBox() {

    // first get ending points
    Point2D p0 = firstPoint();
    Point2D p1 = lastPoint();

    // get coordinate of ending points
    double x0 = p0.x();
    double y0 = p0.y();
    double x1 = p1.x();
    double y1 = p1.y();

    // initialize min and max coords
    double xmin = min(x0, x1);
    double xmax = max(x0, x1);
    double ymin = min(y0, y1);
    double ymax = max(y0, y1);

    // precomputes some values
    Point2D center = ellipse.center();
    double xc = center.x();
    double yc = center.y();
    double endAngle = startAngle + angleExtent;
    boolean direct = angleExtent >= 0;

    // check cases arc contains one maximum
    if (Angle2D.containsAngle(startAngle, endAngle, PI / 2 + ellipse.theta, direct))
      ymax = max(ymax, yc + ellipse.r1);
    if (Angle2D.containsAngle(startAngle, endAngle, 3 * PI / 2 + ellipse.theta, direct))
      ymin = min(ymin, yc - ellipse.r1);
    if (Angle2D.containsAngle(startAngle, endAngle, ellipse.theta, direct))
      xmax = max(xmax, xc + ellipse.r2);
    if (Angle2D.containsAngle(startAngle, endAngle, PI + ellipse.theta, direct))
      xmin = min(xmin, xc - ellipse.r2);

    // return a bounding with computed limits
    return new Box2D(xmin, xmax, ymin, ymax);
  }
Exemplo n.º 3
0
 public boolean containsAngle(double angle) {
   return Angle2D.containsAngle(startAngle, startAngle + angleExtent, angle, angleExtent > 0);
 }