⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quadcurve2d.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	if (t >= 0.0 && t <= 1.0)	  {	    double crossing = t * t * (b2 - 2 * b1 + b0) + 2 * t * (b1 - b0)	                      + b0;	    /* single root is always doubly degenerate in quads */	    if (crossing > 0 && crossing < distance)	      nCrossings += (nRoots == 1) ? 2 : 1;	  }      }    if (useYaxis)      {	if (Line2D.linesIntersect(b0, a0, b2, a2, EPSILON, 0.0, distance, 0.0))	  nCrossings++;      }    else      {	if (Line2D.linesIntersect(a0, b0, a2, b2, 0.0, EPSILON, 0.0, distance))	  nCrossings++;      }    return (nCrossings);  }  /**   * A two-dimensional curve that is parameterized with a quadratic   * function and stores coordinate values in double-precision   * floating-point format.   *   * @see QuadCurve2D.Float   *   * @author Eric Blake (ebb9@email.byu.edu)   * @author Sascha Brawer (brawer@dandelis.ch)   */  public static class Double extends QuadCurve2D  {    /**     * The <i>x</i> coordinate of the curve&#x2019;s start point.     */    public double x1;    /**     * The <i>y</i> coordinate of the curve&#x2019;s start point.     */    public double y1;    /**     * The <i>x</i> coordinate of the curve&#x2019;s control point.     */    public double ctrlx;    /**     * The <i>y</i> coordinate of the curve&#x2019;s control point.     */    public double ctrly;    /**     * The <i>x</i> coordinate of the curve&#x2019;s end point.     */    public double x2;    /**     * The <i>y</i> coordinate of the curve&#x2019;s end point.     */    public double y2;    /**     * Constructs a new QuadCurve2D that stores its coordinate values     * in double-precision floating-point format. All points are     * initially at position (0, 0).     */    public Double()    {    }    /**     * Constructs a new QuadCurve2D that stores its coordinate values     * in double-precision floating-point format, specifying the     * initial position of each point.     *     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s start     * point.     *     * @param y1 the <i>y</i> coordinate of the curve&#x2019;s start     * point.     *     * @param cx the <i>x</i> coordinate of the curve&#x2019;s control     * point.     *     * @param cy the <i>y</i> coordinate of the curve&#x2019;s control     * point.     *     * @param x2 the <i>x</i> coordinate of the curve&#x2019;s end     * point.     *     * @param y2 the <i>y</i> coordinate of the curve&#x2019;s end     * point.     */    public Double(double x1, double y1, double cx, double cy, double x2,                  double y2)    {      this.x1 = x1;      this.y1 = y1;      ctrlx = cx;      ctrly = cy;      this.x2 = x2;      this.y2 = y2;    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s start     * point.     */    public double getX1()    {      return x1;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s start     * point.     */    public double getY1()    {      return y1;    }    /**     * Returns the curve&#x2019;s start point.     */    public Point2D getP1()    {      return new Point2D.Double(x1, y1);    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s control     * point.     */    public double getCtrlX()    {      return ctrlx;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s control     * point.     */    public double getCtrlY()    {      return ctrly;    }    /**     * Returns the curve&#x2019;s control point.     */    public Point2D getCtrlPt()    {      return new Point2D.Double(ctrlx, ctrly);    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s end     * point.     */    public double getX2()    {      return x2;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s end     * point.     */    public double getY2()    {      return y2;    }    /**     * Returns the curve&#x2019;s end point.     */    public Point2D getP2()    {      return new Point2D.Double(x2, y2);    }    /**     * Changes the geometry of the curve.     *     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param y1 the <i>y</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param cx the <i>x</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param cy the <i>y</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param x2 the <i>x</i> coordinate of the curve&#x2019;s new     * end point.     *     * @param y2 the <i>y</i> coordinate of the curve&#x2019;s new     * end point.     */    public void setCurve(double x1, double y1, double cx, double cy,                         double x2, double y2)    {      this.x1 = x1;      this.y1 = y1;      ctrlx = cx;      ctrly = cy;      this.x2 = x2;      this.y2 = y2;    }    /**     * Determines the smallest rectangle that encloses the     * curve&#x2019;s start, end and control point. As the     * illustration below shows, the invisible control point may cause     * the bounds to be much larger than the area that is actually     * covered by the curve.     *     * <p><img src="doc-files/QuadCurve2D-2.png" width="350" height="180"     * alt="An illustration of the bounds of a QuadCurve2D" />     */    public Rectangle2D getBounds2D()    {      double nx1 = Math.min(Math.min(x1, ctrlx), x2);      double ny1 = Math.min(Math.min(y1, ctrly), y2);      double nx2 = Math.max(Math.max(x1, ctrlx), x2);      double ny2 = Math.max(Math.max(y1, ctrly), y2);      return new Rectangle2D.Double(nx1, ny1, nx2 - nx1, ny2 - ny1);    }  }  /**   * A two-dimensional curve that is parameterized with a quadratic   * function and stores coordinate values in single-precision   * floating-point format.   *   * @see QuadCurve2D.Double   *   * @author Eric Blake (ebb9@email.byu.edu)   * @author Sascha Brawer (brawer@dandelis.ch)   */  public static class Float extends QuadCurve2D  {    /**     * The <i>x</i> coordinate of the curve&#x2019;s start point.     */    public float x1;    /**     * The <i>y</i> coordinate of the curve&#x2019;s start point.     */    public float y1;    /**     * The <i>x</i> coordinate of the curve&#x2019;s control point.     */    public float ctrlx;    /**     * The <i>y</i> coordinate of the curve&#x2019;s control point.     */    public float ctrly;    /**     * The <i>x</i> coordinate of the curve&#x2019;s end point.     */    public float x2;    /**     * The <i>y</i> coordinate of the curve&#x2019;s end point.     */    public float y2;    /**     * Constructs a new QuadCurve2D that stores its coordinate values     * in single-precision floating-point format. All points are     * initially at position (0, 0).     */    public Float()    {    }    /**     * Constructs a new QuadCurve2D that stores its coordinate values     * in single-precision floating-point format, specifying the     * initial position of each point.     *     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s start     * point.     *     * @param y1 the <i>y</i> coordinate of the curve&#x2019;s start     * point.     *     * @param cx the <i>x</i> coordinate of the curve&#x2019;s control     * point.     *     * @param cy the <i>y</i> coordinate of the curve&#x2019;s control     * point.     *     * @param x2 the <i>x</i> coordinate of the curve&#x2019;s end     * point.     *     * @param y2 the <i>y</i> coordinate of the curve&#x2019;s end     * point.     */    public Float(float x1, float y1, float cx, float cy, float x2, float y2)    {      this.x1 = x1;      this.y1 = y1;      ctrlx = cx;      ctrly = cy;      this.x2 = x2;      this.y2 = y2;    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s start     * point.     */    public double getX1()    {      return x1;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s start     * point.     */    public double getY1()    {      return y1;    }    /**     * Returns the curve&#x2019;s start point.     */    public Point2D getP1()    {      return new Point2D.Float(x1, y1);    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s control     * point.     */    public double getCtrlX()    {      return ctrlx;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s control     * point.     */    public double getCtrlY()    {      return ctrly;    }    /**     * Returns the curve&#x2019;s control point.     */    public Point2D getCtrlPt()    {      return new Point2D.Float(ctrlx, ctrly);    }    /**     * Returns the <i>x</i> coordinate of the curve&#x2019;s end     * point.     */    public double getX2()    {      return x2;    }    /**     * Returns the <i>y</i> coordinate of the curve&#x2019;s end     * point.     */    public double getY2()    {      return y2;    }    /**     * Returns the curve&#x2019;s end point.     */    public Point2D getP2()    {      return new Point2D.Float(x2, y2);    }    /**     * Changes the geometry of the curve, specifying coordinate values     * as double-precision floating-point numbers.     *     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param y1 the <i>y</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param cx the <i>x</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param cy the <i>y</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param x2 the <i>x</i> coordinate of the curve&#x2019;s new     * end point.     *     * @param y2 the <i>y</i> coordinate of the curve&#x2019;s new     * end point.     */    public void setCurve(double x1, double y1, double cx, double cy,                         double x2, double y2)    {      this.x1 = (float) x1;      this.y1 = (float) y1;      ctrlx = (float) cx;      ctrly = (float) cy;      this.x2 = (float) x2;      this.y2 = (float) y2;    }    /**     * Changes the geometry of the curve, specifying coordinate values     * as single-precision floating-point numbers.     *     * @param x1 the <i>x</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param y1 the <i>y</i> coordinate of the curve&#x2019;s new     * start point.     *     * @param cx the <i>x</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param cy the <i>y</i> coordinate of the curve&#x2019;s new     * control point.     *     * @param x2 the <i>x</i> coordinate of the curve&#x2019;s new     * end point.     *     * @param y2 the <i>y</i> coordinate of the curve&#x2019;s new     * end point.     */    public void setCurve(float x1, float y1, float cx, float cy, float x2,                         float y2)    {      this.x1 = x1;      this.y1 = y1;      ctrlx = cx;      ctrly = cy;      this.x2 = x2;      this.y2 = y2;    }    /**     * Determines the smallest rectangle that encloses the     * curve&#x2019;s start, end and control point. As the     * illustration below shows, the invisible control point may cause     * the bounds to be much larger than the area that is actually     * covered by the curve.     *     * <p><img src="doc-files/QuadCurve2D-2.png" width="350" height="180"     * alt="An illustration of the bounds of a QuadCurve2D" />     */    public Rectangle2D getBounds2D()    {      float nx1 = (float) Math.min(Math.min(x1, ctrlx), x2);      float ny1 = (float) Math.min(Math.min(y1, ctrly), y2);      float nx2 = (float) Math.max(Math.max(x1, ctrlx), x2);      float ny2 = (float) Math.max(Math.max(y1, ctrly), y2);      return new Rectangle2D.Float(nx1, ny1, nx2 - nx1, ny2 - ny1);    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -