Class QuadCurve2D

java.lang.Object
armyc2.c2sd.graphics2d.QuadCurve2D

public final class QuadCurve2D extends Object
The QuadCurve2D class defines a quadratic parametric curve segment in (x,y) coordinate space.

This class is only the abstract superclass for all objects that store a 2D quadratic curve segment. The actual storage representation of the coordinates is left to the subclass.

Since:
1.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    static double
    getFlatnessSq(double[] coords, int offset)
    Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the control points stored in the indicated array at the indicated index.
    static double
    getFlatnessSq2(double x1, double y1, double ctrlx, double ctrly, double x2, double y2)
    Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the indicated control points.
    static int
    solveQuadratic(double[] eqn)
    Solves the quadratic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots.
    static int
    solveQuadratic2(double[] eqn, double[] res)
    Solves the quadratic whose coefficients are in the eqn array and places the non-complex roots into the res array, returning the number of roots.
    static void
    subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff)
    Subdivides the quadratic curve specified by the coordinates stored in the src array at indices srcoff through srcoff + 5 and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getFlatnessSq2

      public static double getFlatnessSq2(double x1, double y1, double ctrlx, double ctrly, double x2, double y2)
      Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the indicated control points.
      Parameters:
      x1 - the X coordinate of the start point
      y1 - the Y coordinate of the start point
      ctrlx - the X coordinate of the control point
      ctrly - the Y coordinate of the control point
      x2 - the X coordinate of the end point
      y2 - the Y coordinate of the end point
      Returns:
      the square of the flatness of the quadratic curve defined by the specified coordinates.
      Since:
      1.2
    • getFlatnessSq

      public static double getFlatnessSq(double[] coords, int offset)
      Returns the square of the flatness, or maximum distance of a control point from the line connecting the end points, of the quadratic curve specified by the control points stored in the indicated array at the indicated index.
      Parameters:
      coords - an array containing coordinate values
      offset - the index into coords from which to to start getting the values from the array
      Returns:
      the flatness of the quadratic curve that is defined by the values in the specified array at the specified index.
      Since:
      1.2
    • subdivide

      public static void subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff)
      Subdivides the quadratic curve specified by the coordinates stored in the src array at indices srcoff through srcoff + 5 and stores the resulting two subdivided curves into the two result arrays at the corresponding indices. Either or both of the left and right arrays can be null or a reference to the same array and offset as the src array. Note that the last point in the first subdivided curve is the same as the first point in the second subdivided curve. Thus, it is possible to pass the same array for left and right and to use offsets such that rightoff equals leftoff + 4 in order to avoid allocating extra storage for this common point.
      Parameters:
      src - the array holding the coordinates for the source curve
      srcoff - the offset into the array of the beginning of the the 6 source coordinates
      left - the array for storing the coordinates for the first half of the subdivided curve
      leftoff - the offset into the array of the beginning of the the 6 left coordinates
      right - the array for storing the coordinates for the second half of the subdivided curve
      rightoff - the offset into the array of the beginning of the the 6 right coordinates
      Since:
      1.2
    • solveQuadratic

      public static int solveQuadratic(double[] eqn)
      Solves the quadratic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots. The quadratic solved is represented by the equation:
           eqn = {C, B, A};
           ax^2 + bx + c = 0
       
      A return value of -1 is used to distinguish a constant equation, which might be always 0 or never 0, from an equation that has no zeroes.
      Parameters:
      eqn - the array that contains the quadratic coefficients
      Returns:
      the number of roots, or -1 if the equation is a constant
      Since:
      1.2
    • solveQuadratic2

      public static int solveQuadratic2(double[] eqn, double[] res)
      Solves the quadratic whose coefficients are in the eqn array and places the non-complex roots into the res array, returning the number of roots. The quadratic solved is represented by the equation:
           eqn = {C, B, A};
           ax^2 + bx + c = 0
       
      A return value of -1 is used to distinguish a constant equation, which might be always 0 or never 0, from an equation that has no zeroes.
      Parameters:
      eqn - the specified array of coefficients to use to solve the quadratic equation
      res - the array that contains the non-complex roots resulting from the solution of the quadratic equation
      Returns:
      the number of roots, or -1 if the equation is a constant.
      Since:
      1.3
    • clone

      public Object clone()
      Overrides:
      clone in class Object