Exemplo n.º 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;
  }
Exemplo n.º 2
0
 /** Returns a new CircleArc2D. t0 and t1 are position on circle. */
 public CircleArc2D subCurve(double t0, double t1) {
   double startAngle, extent;
   if (this.direct) {
     startAngle = t0;
     extent = Angle2D.formatAngle(t1 - t0);
   } else {
     extent = -Angle2D.formatAngle(t1 - t0);
     startAngle = Angle2D.formatAngle(-t0);
   }
   return new CircleArc2D(this, startAngle, extent);
 }
Exemplo n.º 3
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.º 4
0
  public double project(Point2D point) {
    double angle = ellipse.project(point);

    // Case of an angle contained in the ellipse arc
    if (this.containsAngle(angle)) {
      if (angleExtent > 0) return Angle2D.formatAngle(angle - startAngle);
      else return Angle2D.formatAngle(startAngle - angle);
    }

    // return either 0 or T1, depending on which extremity is closer.
    double d1 = this.firstPoint().distance(point);
    double d2 = this.lastPoint().distance(point);
    return d1 < d2 ? 0 : abs(angleExtent);
  }
Exemplo n.º 5
0
 /** Specify parameters of supporting ellipse, bounding angles and flag for direct ellipse. */
 public EllipseArc2D(
     double xc,
     double yc,
     double a,
     double b,
     double theta,
     double start,
     double end,
     boolean direct) {
   this.ellipse = new Ellipse2D(xc, yc, a, b, theta);
   this.startAngle = start;
   this.angleExtent = Angle2D.formatAngle(end - start);
   if (!direct) this.angleExtent = this.angleExtent - PI * 2;
 }
Exemplo n.º 6
0
 public double position(Point2D point) {
   double angle = Angle2D.horizontalAngle(xc, yc, point.x(), point.y());
   if (direct) return Angle2D.formatAngle(angle - theta);
   else return Angle2D.formatAngle(theta - angle);
 }
Exemplo n.º 7
0
 /**
  * Returns the ellipse arc which refers to the reversed parent ellipse, with same start angle, and
  * with opposite angle extent.
  */
 public EllipseArc2D reverse() {
   double newStart = Angle2D.formatAngle(startAngle + angleExtent);
   return new EllipseArc2D(ellipse, newStart, -angleExtent);
 }
Exemplo n.º 8
0
 /** Returns the angle associated with the given position */
 public double getAngle(double position) {
   if (position < 0) position = 0;
   if (position > abs(angleExtent)) position = abs(angleExtent);
   if (angleExtent < 0) position = -position;
   return Angle2D.formatAngle(startAngle + position);
 }