Package armyc2.c2sd.graphics2d
Class QuadCurve2D
java.lang.Object
armyc2.c2sd.graphics2d.QuadCurve2D
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 -
Method Summary
Modifier and TypeMethodDescriptionclone()static doublegetFlatnessSq(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 doublegetFlatnessSq2(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 intsolveQuadratic(double[] eqn) Solves the quadratic whose coefficients are in theeqnarray and places the non-complex roots back into the same array, returning the number of roots.static intsolveQuadratic2(double[] eqn, double[] res) Solves the quadratic whose coefficients are in theeqnarray and places the non-complex roots into theresarray, returning the number of roots.static voidsubdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff) Subdivides the quadratic curve specified by the coordinates stored in thesrcarray at indicessrcoffthroughsrcoff+ 5 and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.
-
Constructor Details
-
QuadCurve2D
public QuadCurve2D()
-
-
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 pointy1- the Y coordinate of the start pointctrlx- the X coordinate of the control pointctrly- the Y coordinate of the control pointx2- the X coordinate of the end pointy2- 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
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 valuesoffset- the index intocoordsfrom 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 thesrcarray at indicessrcoffthroughsrcoff+ 5 and stores the resulting two subdivided curves into the two result arrays at the corresponding indices. Either or both of theleftandrightarrays can benullor a reference to the same array and offset as thesrcarray. 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 forleftandrightand to use offsets such thatrightoffequalsleftoff+ 4 in order to avoid allocating extra storage for this common point.- Parameters:
src- the array holding the coordinates for the source curvesrcoff- the offset into the array of the beginning of the the 6 source coordinatesleft- the array for storing the coordinates for the first half of the subdivided curveleftoff- the offset into the array of the beginning of the the 6 left coordinatesright- the array for storing the coordinates for the second half of the subdivided curverightoff- the offset into the array of the beginning of the the 6 right coordinates- Since:
- 1.2
-
solveQuadratic
Solves the quadratic whose coefficients are in theeqnarray 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 = 0A return value of-1is 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
-1if the equation is a constant - Since:
- 1.2
-
solveQuadratic2
Solves the quadratic whose coefficients are in theeqnarray and places the non-complex roots into theresarray, returning the number of roots. The quadratic solved is represented by the equation:eqn = {C, B, A}; ax^2 + bx + c = 0A return value of-1is 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 equationres- the array that contains the non-complex roots resulting from the solution of the quadratic equation- Returns:
- the number of roots, or
-1if the equation is a constant. - Since:
- 1.3
-
clone
-