Exemple #1
0
  /*
   * (non-Javadoc)
   *
   * @see math.geom2d.Curve2D#position(math.geom2d.Point2D)
   */
  public double position(Point2D point) {
    double angle = Angle2D.horizontalAngle(ellipse.center(), point);
    if (this.containsAngle(angle))
      if (angleExtent > 0) return Angle2D.formatAngle(angle - startAngle);
      else return Angle2D.formatAngle(startAngle - angle);

    // If the point is not contained in the arc, return NaN.
    return Double.NaN;
  }
Exemple #2
0
 @Override
 public String toString() {
   Point2D center = ellipse.center();
   return String.format(
       Locale.US,
       "EllipseArc2D(%7.2f,%7.2f,%7.2f,%7.2f,%7.5f,%7.5f,%7.5f)",
       center.x(),
       center.y(),
       ellipse.r1,
       ellipse.r2,
       ellipse.theta,
       startAngle,
       angleExtent);
 }
Exemple #3
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);
  }