APIdia Launch Partner
Top Description Inners Constructors Methods
java.awt.geom

public abstract Class CubicCurve2D

extends Object
implements Shape, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.awt.Shape
Known Direct Subclasses
java.awt.geom.CubicCurve2D.Float, java.awt.geom.CubicCurve2D.Double
Imports
java.awt.Rectangle, .Shape, java.io.Serial, .Serializable, java.util.Arrays, sun.awt.geom.Curve

The CubicCurve2D class defines a cubic parametric curve segment in (x,y) coordinate space.

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

Author
Jim Graham
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CubicCurve2D.Double

A cubic parametric curve segment specified with double coordinates.

public static class
CubicCurve2D.Float

A cubic parametric curve segment specified with float coordinates.

Constructor Summary

AccessConstructor and Description
protected
CubicCurve2D()

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
private static double
bisectRoot(double[] eqn, double x0, double xe)

private static double
bisectRootWithHint(double[] eqn, double x0, double xe, double hint)

public Object

Returns:

a clone of this instance.
clone
()

Overrides java.lang.Object.clone.

Creates a new object of the same class as this object.

public boolean
contains(double x, double y)

Implements java.awt.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness.

public boolean
contains(Point2D p)

Implements java.awt.Shape.contains.

Tests if a specified Point2D is inside the boundary of the Shape, as described by the definition of insideness.

public boolean
contains(double x, double y, double w, double h)

Implements java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.

public boolean
contains(Rectangle2D r)

Implements java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified Rectangle2D.

private static int
fixRoots(double[] eqn, double[] res, int num)

public Rectangle
getBounds()

Implements java.awt.Shape.getBounds.

Returns an integer Rectangle that completely encloses the Shape.

public Rectangle2D
getBounds2D()

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.

public abstract Point2D

Returns:

a Point2D that is the first control point of the CubicCurve2D.
getCtrlP1
()

Returns the first control point.

public abstract Point2D

Returns:

a Point2D that is the second control point of the CubicCurve2D.
getCtrlP2
()

Returns the second control point.

public abstract double

Returns:

the X coordinate of the first control point of the CubicCurve2D.
getCtrlX1
()

Returns the X coordinate of the first control point in double precision.

public abstract double

Returns:

the X coordinate of the second control point of the CubicCurve2D.
getCtrlX2
()

Returns the X coordinate of the second control point in double precision.

public abstract double

Returns:

the Y coordinate of the first control point of the CubicCurve2D.
getCtrlY1
()

Returns the Y coordinate of the first control point in double precision.

public abstract double

Returns:

the Y coordinate of the second control point of the CubicCurve2D.
getCtrlY2
()

Returns the Y coordinate of the second control point in double precision.

public static double

Returns:

the flatness of the CubicCurve2D represented by the specified coordinates.
getFlatness
(double
the X coordinate that specifies the start point of a CubicCurve2D
x1
,
double
the Y coordinate that specifies the start point of a CubicCurve2D
y1
,
double
the X coordinate that specifies the first control point of a CubicCurve2D
ctrlx1
,
double
the Y coordinate that specifies the first control point of a CubicCurve2D
ctrly1
,
double
the X coordinate that specifies the second control point of a CubicCurve2D
ctrlx2
,
double
the Y coordinate that specifies the second control point of a CubicCurve2D
ctrly2
,
double
the X coordinate that specifies the end point of a CubicCurve2D
x2
,
double
the Y coordinate that specifies the end point of a CubicCurve2D
y2
)

Returns the flatness of the cubic curve specified by the indicated control points.

public static double

Returns:

the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.
getFlatness
(double[]
an array containing coordinates
coords
,
int
the index of coords from which to begin getting the end points and control points of the curve
offset
)

Returns the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.

public double

Returns:

the flatness of this curve.
getFlatness
()

Returns the flatness of this curve.

public static double

Returns:

the square of the flatness of the CubicCurve2D represented by the specified coordinates.
getFlatnessSq
(double
the X coordinate that specifies the start point of a CubicCurve2D
x1
,
double
the Y coordinate that specifies the start point of a CubicCurve2D
y1
,
double
the X coordinate that specifies the first control point of a CubicCurve2D
ctrlx1
,
double
the Y coordinate that specifies the first control point of a CubicCurve2D
ctrly1
,
double
the X coordinate that specifies the second control point of a CubicCurve2D
ctrlx2
,
double
the Y coordinate that specifies the second control point of a CubicCurve2D
ctrly2
,
double
the X coordinate that specifies the end point of a CubicCurve2D
x2
,
double
the Y coordinate that specifies the end point of a CubicCurve2D
y2
)

Returns the square of the flatness of the cubic curve specified by the indicated control points.

public static double

Returns:

the square of the flatness of the CubicCurve2D specified by the coordinates in coords at the specified offset.
getFlatnessSq
(double[]
an array containing coordinates
coords
,
int
the index of coords from which to begin getting the end points and control points of the curve
offset
)

Returns the square of the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.

public double

Returns:

the square of the flatness of this curve.
getFlatnessSq
()

Returns the square of the flatness of this curve.

public abstract Point2D

Returns:

a Point2D that is the start point of the CubicCurve2D.
getP1
()

Returns the start point.

public abstract Point2D

Returns:

a Point2D that is the end point of the CubicCurve2D.
getP2
()

Returns the end point.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.
getPathIterator
(AffineTransform
an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
at
)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the shape.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this CubicCurve2D, one segment at a time.
getPathIterator
(AffineTransform
an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
at
,
double
the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the end points
flatness
)

Implements java.awt.Shape.getPathIterator.

Return an iteration object that defines the boundary of the flattened shape.

private static double
getRootUpperBound(double[] eqn)

public abstract double

Returns:

the X coordinate of the start point of the CubicCurve2D.
getX1
()

Returns the X coordinate of the start point in double precision.

public abstract double

Returns:

the X coordinate of the end point of the CubicCurve2D.
getX2
()

Returns the X coordinate of the end point in double precision.

public abstract double

Returns:

the Y coordinate of the start point of the CubicCurve2D.
getY1
()

Returns the Y coordinate of the start point in double precision.

public abstract double

Returns:

the Y coordinate of the end point of the CubicCurve2D.
getY2
()

Returns the Y coordinate of the end point in double precision.

private static boolean
inInterval(double t, double min, double max)

public boolean
intersects(double x, double y, double w, double h)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.

public boolean
intersects(Rectangle2D r)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.

private static boolean
iszero(double x, double err)

private static boolean
oppositeSigns(double x1, double x2)

private int
rectCrossings(double x, double y, double w, double h)

private static double
refineRootWithHint(double[] eqn, double min, double max, double t)

public abstract void
setCurve(double
the X coordinate used to set the start point of this CubicCurve2D
x1
,
double
the Y coordinate used to set the start point of this CubicCurve2D
y1
,
double
the X coordinate used to set the first control point of this CubicCurve2D
ctrlx1
,
double
the Y coordinate used to set the first control point of this CubicCurve2D
ctrly1
,
double
the X coordinate used to set the second control point of this CubicCurve2D
ctrlx2
,
double
the Y coordinate used to set the second control point of this CubicCurve2D
ctrly2
,
double
the X coordinate used to set the end point of this CubicCurve2D
x2
,
double
the Y coordinate used to set the end point of this CubicCurve2D
y2
)

Sets the location of the end points and control points of this curve to the specified double coordinates.

public void
setCurve(double[]
a double array containing coordinates
coords
,
int
the index of coords from which to begin setting the end points and control points of this curve to the coordinates contained in coords
offset
)

Sets the location of the end points and control points of this curve to the double coordinates at the specified offset in the specified array.

public void
setCurve(Point2D
the first specified Point2D used to set the start point of this curve
p1
,
Point2D
the second specified Point2D used to set the first control point of this curve
cp1
,
Point2D
the third specified Point2D used to set the second control point of this curve
cp2
,
Point2D
the fourth specified Point2D used to set the end point of this curve
p2
)

Sets the location of the end points and control points of this curve to the specified Point2D coordinates.

public void
setCurve(Point2D[]
an array of Point2D objects
pts
,
int
the index of pts from which to begin setting the end points and control points of this curve to the points contained in pts
offset
)

Sets the location of the end points and control points of this curve to the coordinates of the Point2D objects at the specified offset in the specified array.

public void
setCurve(CubicCurve2D
the specified CubicCurve2D
c
)

Sets the location of the end points and control points of this curve to the same as those in the specified CubicCurve2D.

public static int

Returns:

the number of roots, or -1 if the equation is a constant.
solveCubic
(double[]
an array containing coefficients for a cubic
eqn
)

Solves the cubic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots.

public static int

Returns:

the number of roots, or -1 if the equation is a constant
solveCubic
(double[]
the specified array of coefficients to use to solve the cubic equation
eqn
,
double[]
the array that contains the non-complex roots resulting from the solution of the cubic equation
res
)

Solve the cubic whose coefficients are in the eqn array and place the non-complex roots into the res array, returning the number of roots.

private static double
solveEqn(double[] eqn, int order, double t)

public void
subdivide(CubicCurve2D
the cubic curve object for storing for the left or first half of the subdivided curve
left
,
CubicCurve2D
the cubic curve object for storing for the right or second half of the subdivided curve
right
)

Subdivides this cubic curve and stores the resulting two subdivided curves into the left and right curve parameters.

public static void
subdivide(CubicCurve2D
the cubic curve to be subdivided
src
,
CubicCurve2D
the cubic curve object for storing the left or first half of the subdivided curve
left
,
CubicCurve2D
the cubic curve object for storing the right or second half of the subdivided curve
right
)

Subdivides the cubic curve specified by the src parameter and stores the resulting two subdivided curves into the left and right curve parameters.

public static void
subdivide(double[]
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
,
double[]
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
,
double[]
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 cubic curve specified by the coordinates stored in the src array at indices srcoff through (srcoff + 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.

private static boolean
within(double x, double y, double err)

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait