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.
Modifier and Type | Field and Description |
---|---|
private static final int | |
private static final int | |
public float | ctrlx
The X coordinate of the control point of the quadratic curve segment. |
public float | ctrly
The Y coordinate of the control point of the quadratic curve segment. |
private static final int | |
private static final int | |
private static final int | |
public float | x1
The X coordinate of the start point of the quadratic curve segment. |
public float | x2
The X coordinate of the end point of the quadratic curve segment. |
public float | y1
The Y coordinate of the start point of the quadratic curve segment. |
public float | y2
The Y coordinate of the end point of the quadratic curve segment. |
Access | Constructor and Description |
---|---|
public | |
public | QuadCurve2D(float
the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the control point ctrlx, float the Y coordinate of the control point ctrly, float the X coordinate of the end point x2, float the Y coordinate of the end point y2)Constructs and initializes a |
Modifier and Type | Method and Description |
---|---|
public boolean | contains(float
the specified X coordinate to be tested x, float the specified Y coordinate to be tested y)Implements abstract com. Tests if the specified coordinates are inside the boundary of the
|
public boolean | contains(Point2D
the specified p)Point2D to be testedOverrides com. Tests if a specified |
public boolean | contains(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
public QuadCurve2D | copy()
Implements abstract com. Returns a new copy of this |
public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
private static int | evalQuadratic(float[] vals, int num, boolean include0, boolean include1, float[] inflect, float c1, float ctrl, float c2)
Evaluate the t values in the first num slots of the vals[] array and place the evaluated values back into the same array. |
private static void | fillEqn(float[] eqn, float val, float c1, float cp, float c2)
Fill an array with the coefficients of the parametric equation in t, ready for solving against val with solveQuadratic. |
public RectBounds | getBounds()
Implements abstract com. Note that there is no guarantee that the returned
|
public static float | Returns: the flatness of the quadratic curve defined by the specified coordinates.the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the control point ctrlx, float the Y coordinate of the control point ctrly, float the X coordinate of the end point x2, float the Y coordinate of the end point y2)Returns 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. |
public static float | Returns: the flatness of a quadratic curve defined by the specified array at the specified offset.an array containing coordinate values coords, int the index into offset)coords from which to
start getting the coordinate valuesReturns 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. |
public float | Returns: the flatness of thisQuadCurve2D .Returns the flatness, or maximum distance of a
control point from the line connecting the end points, of this
|
public static float | Returns: the square of the flatness of the quadratic curve defined by the specified coordinates.the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the control point ctrlx, float the Y coordinate of the control point ctrly, float the X coordinate of the end point x2, float the Y coordinate of the end point 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. |
public static float | Returns: the flatness of the quadratic curve that is defined by the values in the specified array at the specified index.an array containing coordinate values coords, int the index into offset)coords from which to
to start getting the values from the arrayReturns 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. |
public float | Returns: the square of the flatness of thisQuadCurve2D .Returns the square of the flatness, or maximum distance of a
control point from the line connecting the end points, of this
|
public PathIterator | Returns: aPathIterator object that defines the boundary
of the shape.an optional tx)BaseTransform to apply to the
shape boundaryImplements abstract com. Returns an iteration object that defines the boundary of the
shape of this |
public PathIterator | Returns: aPathIterator object that defines the
flattened boundary of the shape.an optional tx, float BaseTransform to apply
to the boundary of the shapethe maximum distance that the control points for a
subdivided curve can be with respect to a line connecting
the end points of this curve before this curve is
replaced by a straight line connecting the end points. flatness)Implements abstract com. Returns an iteration object that defines the boundary of the
flattened shape of this |
private static int | getTag(float coord, float low, float high)
Determine where coord lies with respect to the range from low to high. |
public int | |
public boolean | intersects(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
private static boolean | inwards(int pttag, int opt1tag, int opt2tag)
Determine if the pttag represents a coordinate that is already in its test range, or is on the border with either of the two opttags representing another coordinate that is "towards the inside" of that test range. |
public void | setCurve(float
the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the control point ctrlx, float the Y coordinate of the control point ctrly, float the X coordinate of the end point x2, float the Y coordinate of the end point y2)Sets the location of the end points and control point of this curve
to the specified |
public void | setCurve(float[]
the array containing coordinate values coords, int the index into the array from which to start
getting the coordinate values and assigning them to this
offset)QuadCurve2D Sets the location of the end points and control points of this
|
public void | |
public void | setCurve(Point2D[]
an array containing pts, int Point2D that define
coordinate valuesthe index into offset)pts from which to start
getting the coordinate values and assigning them to this
QuadCurve2D Sets the location of the end points and control points of this
|
public void | setCurve(QuadCurve2D
the specified c)QuadCurve2D Sets the location of the end points and control point of this
|
public static int | Returns: the number of roots, or-1 if the equation is
a constantthe array that contains the quadratic coefficients eqn)Solves the quadratic whose coefficients are in the |
public static int | Returns: the number of roots, or-1 if the equation is
a constant.the specified array of coefficients to use to solve
the quadratic equation eqn, float[] the array that contains the non-complex roots
resulting from the solution of the quadratic equation res)Solves the quadratic whose coefficients are in the |
public void | subdivide(QuadCurve2D
the left, QuadCurve2D QuadCurve2D object for storing the
left or first half of the subdivided curvethe right)QuadCurve2D object for storing the
right or second half of the subdivided curveSubdivides this |
public static void | subdivide(QuadCurve2D
the quadratic curve to be subdivided src, QuadCurve2D the left, QuadCurve2D QuadCurve2D object for storing the
left or first half of the subdivided curvethe right)QuadCurve2D object for storing the
right or second half of the subdivided curveSubdivides the quadratic curve specified by the |
public static void | subdivide(float[]
the array holding the coordinates for the source curve src, int the offset into the array of the beginning of the
the 6 source coordinates srcoff, float[] the array for storing the coordinates for the first
half of the subdivided curve left, int the offset into the array of the beginning of the
the 6 left coordinates leftoff, float[] the array for storing the coordinates for the second
half of the subdivided curve right, int the offset into the array of the beginning of the
the 6 right coordinates rightoff)Subdivides the quadratic curve specified by the coordinates
stored in the |
public CubicCurve2D |
ABOVE | back to summary |
---|---|
private static final int ABOVE |
BELOW | back to summary |
---|---|
private static final int BELOW |
ctrlx | back to summary |
---|---|
public float ctrlx The X coordinate of the control point of the quadratic curve segment. |
ctrly | back to summary |
---|---|
public float ctrly The Y coordinate of the control point of the quadratic curve segment. |
HIGHEDGE | back to summary |
---|---|
private static final int HIGHEDGE |
INSIDE | back to summary |
---|---|
private static final int INSIDE |
LOWEDGE | back to summary |
---|---|
private static final int LOWEDGE |
x1 | back to summary |
---|---|
public float x1 The X coordinate of the start point of the quadratic curve segment. |
x2 | back to summary |
---|---|
public float x2 The X coordinate of the end point of the quadratic curve segment. |
y1 | back to summary |
---|---|
public float y1 The Y coordinate of the start point of the quadratic curve segment. |
y2 | back to summary |
---|---|
public float y2 The Y coordinate of the end point of the quadratic curve segment. |
QuadCurve2D | back to summary |
---|---|
public QuadCurve2D() Constructs and initializes a |
QuadCurve2D | back to summary |
---|---|
public QuadCurve2D(float x1, float y1, float ctrlx, float ctrly, float x2, float y2) Constructs and initializes a
|
contains | back to summary |
---|---|
public boolean contains(float x, float y) Implements abstract com. Doc from com. Tests if the specified coordinates are inside the boundary of the
|
contains | back to summary |
---|---|
public boolean contains(Point2D p) Overrides com. Doc from com. Tests if a specified |
contains | back to summary |
---|---|
public boolean contains(float x, float y, float w, float h) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return false even though the Shape contains
the rectangular area.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.
|
copy | back to summary |
---|---|
public QuadCurve2D copy() Implements abstract com. Doc from com. Returns a new copy of this
|
equals | back to summary |
---|---|
public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. |
evalQuadratic | back to summary |
---|---|
private static int evalQuadratic(float[] vals, int num, boolean include0, boolean include1, float[] inflect, float c1, float ctrl, float c2) Evaluate the t values in the first num slots of the vals[] array and place the evaluated values back into the same array. Only evaluate t values that are within the range <0, 1>, including the 0 and 1 ends of the range iff the include0 or include1 booleans are true. If an "inflection" equation is handed in, then any points which represent a point of inflection for that quadratic equation are also ignored. |
fillEqn | back to summary |
---|---|
private static void fillEqn(float[] eqn, float val, float c1, float cp, float c2) Fill an array with the coefficients of the parametric equation in t, ready for solving against val with solveQuadratic. We currently have: val = Py(t) = C1*(1-t)^2 + 2*CP*t*(1-t) + C2*t^2 = C1 - 2*C1*t + C1*t^2 + 2*CP*t - 2*CP*t^2 + C2*t^2 = C1 + (2*CP - 2*C1)*t + (C1 - 2*CP + C2)*t^2 0 = (C1 - val) + (2*CP - 2*C1)*t + (C1 - 2*CP + C2)*t^2 0 = C + Bt + At^2 C = C1 - val B = 2*CP - 2*C1 A = C1 - 2*CP + C2 |
getBounds | back to summary |
---|---|
public RectBounds getBounds() Implements abstract com. Doc from com. Note that there is no guarantee that the returned
|
getFlatness | back to summary |
---|---|
public static float getFlatness(float x1, float y1, float ctrlx, float ctrly, float x2, float y2) Returns 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.
|
getFlatness | back to summary |
---|---|
public static float getFlatness(float[] coords, int offset) Returns 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.
|
getFlatness | back to summary |
---|---|
public float getFlatness() Returns the flatness, or maximum distance of a
control point from the line connecting the end points, of this
|
getFlatnessSq | back to summary |
---|---|
public static float getFlatnessSq(float x1, float y1, float ctrlx, float ctrly, float x2, float 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.
|
getFlatnessSq | back to summary |
---|---|
public static float getFlatnessSq(float[] 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.
|
getFlatnessSq | back to summary |
---|---|
public float getFlatnessSq() Returns the square of the flatness, or maximum distance of a
control point from the line connecting the end points, of this
|
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(BaseTransform tx) Implements abstract com. Returns an iteration object that defines the boundary of the
shape of this
|
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(BaseTransform tx, float flatness) Implements abstract com. Returns an iteration object that defines the boundary of the
flattened shape of this
|
getTag | back to summary |
---|---|
private static int getTag(float coord, float low, float high) Determine where coord lies with respect to the range from low to high. It is assumed that low <= high. The return value is one of the 5 values BELOW, LOWEDGE, INSIDE, HIGHEDGE, or ABOVE. |
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
|
intersects | back to summary |
---|---|
public boolean intersects(float x, float y, float w, float h) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return true even though the rectangular area does not
intersect the Shape .
The Area class performs
more accurate computations of geometric intersection than most
Shape objects and therefore can be used if a more precise
answer is required.
|
inwards | back to summary |
---|---|
private static boolean inwards(int pttag, int opt1tag, int opt2tag) Determine if the pttag represents a coordinate that is already in its test range, or is on the border with either of the two opttags representing another coordinate that is "towards the inside" of that test range. In other words, are either of the two "opt" points "drawing the pt inward"? |
setCurve | back to summary |
---|---|
public void setCurve(float x1, float y1, float ctrlx, float ctrly, float x2, float y2) Sets the location of the end points and control point of this curve
to the specified
|
setCurve | back to summary |
---|---|
public void setCurve(float[] coords, int offset) Sets the location of the end points and control points of this
|
setCurve | back to summary |
---|---|
public void setCurve(Point2D p1, Point2D cp, Point2D p2) Sets the location of the end points and control point of this
|
setCurve | back to summary |
---|---|
public void setCurve(Point2D[] pts, int offset) Sets the location of the end points and control points of this
|
setCurve | back to summary |
---|---|
public void setCurve(QuadCurve2D c) Sets the location of the end points and control point of this
|
solveQuadratic | back to summary |
---|---|
public static int solveQuadratic(float[] eqn) Solves the quadratic whose coefficients are in the eqn = {C, B, A}; ax^2 + bx + c = 0A 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.
|
solveQuadratic | back to summary |
---|---|
public static int solveQuadratic(float[] eqn, float[] res) Solves the quadratic whose coefficients are in the eqn = {C, B, A}; ax^2 + bx + c = 0A 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.
|
subdivide | back to summary |
---|---|
public void subdivide(QuadCurve2D left, QuadCurve2D right) Subdivides this
|
subdivide | back to summary |
---|---|
public static void subdivide(QuadCurve2D src, QuadCurve2D left, QuadCurve2D right) Subdivides the quadratic curve specified by the
|
subdivide | back to summary |
---|---|
public static void subdivide(float[] src, int srcoff, float[] left, int leftoff, float[] right, int rightoff) Subdivides the quadratic curve specified by the coordinates
stored in the
|
toCubic | back to summary |
---|---|
public CubicCurve2D toCubic() |