public class BezierCurve extends java.lang.Object implements ICurve, ITranslatable<BezierCurve>, IScalable<BezierCurve>, IRotatable<BezierCurve>
Instances of the BezierCurve class individually represent an
arbitrary Bezier curve. This is the base class of the special quadratic and
cubic Bezier curve classes (QuadraticCurve and CubicCurve).
| Constructor and Description |
|---|
BezierCurve(CubicCurve c)
Constructs a new
BezierCurve from the given CubicCurve. |
BezierCurve(double... controlPoints)
Constructs a new
BezierCurve from the given control Point
coordinates. |
BezierCurve(Point... controlPoints)
Constructs a new
BezierCurve from the given control Point
s. |
BezierCurve(QuadraticCurve c)
Constructs a new
BezierCurve from the given
QuadraticCurve. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
boolean |
contains(BezierCurve o)
Tests if this
BezierCurve contains the given other
BezierCurve. |
boolean |
contains(Point p)
|
boolean |
equals(java.lang.Object other) |
Point |
get(double t)
Computes the
Point on this BezierCurve at parameter value
t, which is expected to lie in the parameter Interval
[0;1]. |
Rectangle |
getBounds()
|
BezierCurve |
getClipped(double s,
double e)
|
Rectangle |
getControlBounds()
|
BezierCurve |
getCopy()
Returns a new identical copy of this
IGeometry. |
BezierCurve |
getDerivative()
Computes the hodograph, the first parametric derivative, of this
BezierCurve. |
BezierCurve |
getElevated()
Computes a
BezierCurve with a degree of one higher than this
BezierCurve's degree but of the same shape. |
protected java.util.Set<org.eclipse.gef4.geometry.planar.BezierCurve.IntervalPair> |
getIntersectionIntervalPairs(BezierCurve other,
java.util.Set<Point> intersections)
Computes
IntervalPairs which do reflect Points of
intersection between this and the given other BezierCurve. |
Point[] |
getIntersections(BezierCurve other)
Returns the
Points of intersection of this and the given other
BezierCurve. |
Point[] |
getIntersections(ICurve curve)
|
BezierCurve |
getOverlap(BezierCurve other)
Returns a
BezierCurve that represents the overlap of this
BezierCurve and the given other BezierCurve. |
ICurve[] |
getOverlaps(ICurve c)
|
Point |
getP1()
|
Point |
getP2()
|
double |
getParameterAt(Point p)
Returns the parameter value of this
BezierCurve for the given
Point. |
Point |
getPoint(int i)
Returns the ith control
Point of this BezierCurve. |
Point[] |
getPoints()
Returns the control
Points of this BezierCurve. |
Point |
getProjection(Point reference)
|
BezierCurve |
getRotatedCCW(Angle angle)
|
BezierCurve |
getRotatedCCW(Angle angle,
double cx,
double cy)
|
BezierCurve |
getRotatedCCW(Angle angle,
Point center)
|
BezierCurve |
getRotatedCW(Angle angle)
|
BezierCurve |
getRotatedCW(Angle angle,
double cx,
double cy)
|
BezierCurve |
getRotatedCW(Angle angle,
Point center)
|
BezierCurve |
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its
center
Point. |
BezierCurve |
getScaled(double fx,
double fy)
Scales a copy of the calling object by the given factors relative to its
center
Point. |
BezierCurve |
getScaled(double factor,
double cx,
double cy)
Scales a copy of the calling object by the given factor relative to the
given center
Point (cx, cy). |
BezierCurve |
getScaled(double fx,
double fy,
double cx,
double cy)
Scales a copy of the calling object by the given factors relative to the
given center
Point (cx, cy). |
BezierCurve |
getScaled(double fx,
double fy,
Point center)
Scales a copy of the calling object by the given factors relative to the
given center
Point. |
BezierCurve |
getScaled(double factor,
Point center)
Scales a copy of the calling object by the given factor relative to the
given center
Point. |
BezierCurve |
getTransformed(AffineTransform t)
|
BezierCurve |
getTranslated(double dx,
double dy)
Translates a copy of this object by the given values in x and y
direction.
|
BezierCurve |
getTranslated(Point d)
Translates a copy of this object by the given
Point. |
double |
getX1()
Returns the start
Point's x coordinate. |
double |
getX2()
Returns the end
Point's x coordinate. |
double |
getY1()
Returns the start
Point's y coordinate. |
double |
getY2()
Returns the end
Point's y coordinate. |
int |
hashCode() |
boolean |
intersects(ICurve c)
|
boolean |
overlaps(BezierCurve other)
Checks if this
BezierCurve and the given other
BezierCurve overlap, i.e. an infinite set of intersection
Points exists. |
boolean |
overlaps(ICurve c)
|
BezierCurve |
rotateCCW(Angle angle)
Directly rotates this
BezierCurve counter-clockwise (CCW) around
its center Point by the given Angle. |
BezierCurve |
rotateCCW(Angle angle,
double cx,
double cy)
Directly rotates this
BezierCurve counter-clockwise (CCW) around
the Point specified by the given x and y coordinate values by the
given Angle. |
BezierCurve |
rotateCCW(Angle angle,
Point center)
Directly rotates this
BezierCurve counter-clockwise (CCW) around
the given Point by the given Angle. |
BezierCurve |
rotateCW(Angle angle)
|
BezierCurve |
rotateCW(Angle angle,
double cx,
double cy)
Directly rotates this
BezierCurve clockwise (CW) around the
Point specified by the given x and y coordinate values by the
given Angle. |
BezierCurve |
rotateCW(Angle angle,
Point center)
|
BezierCurve |
scale(double factor)
Scales the calling object by the given factor relative to its center
Point. |
BezierCurve |
scale(double fx,
double fy)
Scales the calling object by the given factors relative to the given
center
Point. |
BezierCurve |
scale(double factor,
double cx,
double cy)
Scales the calling object by the given factor relative to the given
center
Point (cx, cy). |
BezierCurve |
scale(double fx,
double fy,
double cx,
double cy)
Scales the calling object by the given factors relative to the given
center
Point (cx, cy). |
BezierCurve |
scale(double fx,
double fy,
Point center)
Scales the calling object by the given factors relative to the given
center
Point. |
BezierCurve |
scale(double factor,
Point center)
Scales the calling object by the given factor relative to the given
center
Point. |
BezierCurve |
setP1(Point p1)
|
BezierCurve |
setP2(Point p2)
|
BezierCurve |
setPoint(int i,
Point p)
Sets the ith control
Point of this BezierCurve. |
BezierCurve[] |
split(double t)
Subdivides this
BezierCurve at the given parameter value t
into two new BezierCurves. |
BezierCurve[] |
toBezier()
Computes a list of
BezierCurves that approximate the
ICurve. |
CubicCurve |
toCubic()
Returns a hard approximation of this
BezierCurve as a
CubicCurve. |
Line |
toLine()
Returns a hard approximation of this
BezierCurve as a
Line. |
Line[] |
toLineStrip(double lineSimilarity)
Computes an approximation of this
BezierCurve by a strip of
Lines. |
Line[] |
toLineStrip(double lineSimilarity,
org.eclipse.gef4.geometry.planar.BezierCurve.Interval startInterval)
Computes an approximation of this
BezierCurve by a strip of
Lines. |
Path |
toPath()
|
Point[] |
toPoints(org.eclipse.gef4.geometry.planar.BezierCurve.Interval startInterval)
|
QuadraticCurve |
toQuadratic()
Returns a hard approximation of this
BezierCurve as a
QuadraticCurve. |
java.lang.String |
toString() |
boolean |
touches(IGeometry g)
|
BezierCurve |
translate(double dx,
double dy)
Translates the object by the given values in x and y direction.
|
BezierCurve |
translate(Point d)
Translates the object by the given
Point. |
public BezierCurve(CubicCurve c)
BezierCurve from the given CubicCurve.c - the CubicCurve of which the new BezierCurve is
constructed frompublic BezierCurve(double... controlPoints)
BezierCurve from the given control Point
coordinates. The coordinates are expected to be in x, y order, i.e. x1,
y1, x2, y2, x3, y3, ...controlPoints - the control Point coordinates of the new
BezierCurve in x, y orderpublic BezierCurve(Point... controlPoints)
BezierCurve from the given control Point
s.controlPoints - the control Points of the new BezierCurvepublic BezierCurve(QuadraticCurve c)
BezierCurve from the given
QuadraticCurve.c - the QuadraticCurve of which the new
BezierCurve is constructed frompublic boolean contains(BezierCurve o)
Tests if this BezierCurve contains the given other
BezierCurve.
The other BezierCurve is regarded to be contained by this
BezierCurve if its start and end Point lie on this
BezierCurve and an overlapping segment of the two curves can be
detected.
o - the BezierCurve that is checked to be contained by
this BezierCurvetrue if the given BezierCurve is contained
by this BezierCurve, otherwise falsepublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic Point get(double t)
Point on this BezierCurve at parameter value
t, which is expected to lie in the parameter Interval
[0;1].t - the parameter value for which this BezierCurve is
evaluatedPoint on this BezierCurve at the given
parameter valuepublic BezierCurve getClipped(double s, double e)
s - the lower limit of the parameter Interval which is
clipped out of this BezierCurvee - the upper limit of the parameter Interval which is
clipped out of this BezierCurveBezierCurve representing this BezierCurve
on the Interval [s;e]public Rectangle getControlBounds()
Rectangle representing the bounds of the control
Polygon of this BezierCurvepublic BezierCurve getCopy()
IGeometryIGeometry.public BezierCurve getDerivative()
BezierCurve.BezierCurvepublic BezierCurve getElevated()
BezierCurve with a degree of one higher than this
BezierCurve's degree but of the same shape.BezierCurve of the same shape as this
BezierCurve but with one more control Pointprotected java.util.Set<org.eclipse.gef4.geometry.planar.BezierCurve.IntervalPair> getIntersectionIntervalPairs(BezierCurve other, java.util.Set<Point> intersections)
Computes IntervalPairs which do reflect Points of
intersection between this and the given other BezierCurve. Each
IntervalPair reflects a single Point of intersection.
For every IntervalPair a Point of intersection is
inserted into the given Set of Points.
If there are infinite Points of intersection, i.e. the curves do
overlap, an empty set is returned. (see
overlaps(BezierCurve))
other - The BezierCurve which is searched for Points
of intersection with this BezierCurve.intersections - The Point-Set where Points of
intersection are inserted.Points, a Set
of IntervalPairs is returned where every
IntervalPair represents a single Point of
intersection. For an infinite number of intersection
Points, an empty Set is returned.public Point[] getIntersections(BezierCurve other)
Points of intersection of this and the given other
BezierCurve.other - the BezierCurve which is searched for Points
of intersection with this BezierCurvePoints of intersection of this BezierCurve
and the given other BezierCurvepublic final Point[] getIntersections(ICurve curve)
ICurvegetIntersections in interface ICurvecurve - The ICurve to compute intersection points with.public BezierCurve getOverlap(BezierCurve other)
Returns a BezierCurve that represents the overlap of this
BezierCurve and the given other BezierCurve. If no
overlap exists, null is returned. An overlap is identified
by an infinite number of intersection points.
other - The BezierCurve to which an overlap is computed.BezierCurve representing the overlap of this and the
given other BezierCurve if an overlap exists, otherwise
nullpublic final ICurve[] getOverlaps(ICurve c)
ICurvegetOverlaps in interface ICurvec - The curve to compute overlaps with.public double getParameterAt(Point p)
BezierCurve for the given
Point. If the given Point is not on this
BezierCurve an IllegalArgumentException is thrown.p - the Point for which the parameter value on this
BezierCurve is to be foundPoint on
this BezierCurvepublic Point getPoint(int i)
Point of this BezierCurve.
The start Point is at index 0, the first handle-
Point is at index 1, etc.i - the index of the control Point of this
BezierCurve to returnPoint of this BezierCurvepublic Point[] getPoints()
Points of this BezierCurve.Points of this BezierCurvepublic Point getProjection(Point reference)
ICurvePoint onto
this ICurve, i.e. a Point on this ICurve that is
closest to the given reference Point. Note, thatgetProjection in interface ICurvereference - The reference Point for which to return the
projection.Point onto
this ICurve.public BezierCurve getRotatedCCW(Angle angle)
IRotatableAngle counter-clock-wise
(CCW) around its center Point. Does not necessarily return an
object of the same type.getRotatedCCW in interface IRotatable<BezierCurve>angle - rotation AngleIGeometry representing the result of the rotationpublic BezierCurve getRotatedCCW(Angle angle, double cx, double cy)
IRotatableAngle
counter-clock-wise (CCW) around the specified center Point (cx,
cy). Does not necessarily return an object of the same type.getRotatedCCW in interface IRotatable<BezierCurve>angle - rotation Anglecx - x-coordinate of the relative Point for the rotationcy - y-coordinate of the relative Point for the rotationIGeometry representing the result of the rotationpublic BezierCurve getRotatedCCW(Angle angle, Point center)
IRotatableAngle
counter-clock-wise (CCW) around the specified center Point. Does
not necessarily return an object of the same type.getRotatedCCW in interface IRotatable<BezierCurve>angle - rotation Anglecenter - relative Point for the rotationIGeometry representing the result of the rotationpublic BezierCurve getRotatedCW(Angle angle)
IRotatableAngle clock-wise (CW)
around its center Point. Does not necessarily return an object of
the same type.getRotatedCW in interface IRotatable<BezierCurve>angle - rotation AngleIGeometry representing the result of the rotationpublic BezierCurve getRotatedCW(Angle angle, double cx, double cy)
IRotatableAngle clock-wise (CW)
around the specified center Point (cx, cy). Does not necessarily
return an object of the same type.getRotatedCW in interface IRotatable<BezierCurve>angle - rotation Anglecx - x-coordinate of the relative Point for the rotationcy - y-coordinate of the relative Point for the rotationIGeometry representing the result of the rotationpublic BezierCurve getRotatedCW(Angle angle, Point center)
IRotatableAngle clock-wise (CW)
around the specified center Point. Does not necessarily return an
object of the same type.getRotatedCW in interface IRotatable<BezierCurve>angle - rotation Anglecenter - relative Point for the rotationIGeometry representing the result of the rotationpublic BezierCurve getScaled(double factor)
IScalablePoint.getScaled in interface IScalable<BezierCurve>factor - scale-factorpublic BezierCurve getScaled(double fx, double fy)
IScalablePoint.getScaled in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorpublic BezierCurve getScaled(double factor, double cx, double cy)
IScalablePoint (cx, cy).getScaled in interface IScalable<BezierCurve>factor - scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingpublic BezierCurve getScaled(double fx, double fy, double cx, double cy)
IScalablePoint (cx, cy).getScaled in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingpublic BezierCurve getScaled(double fx, double fy, Point center)
IScalablePoint.getScaled in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorcenter - relative Point for the scalingpublic BezierCurve getScaled(double factor, Point center)
IScalablePoint.getScaled in interface IScalable<BezierCurve>factor - scale-factorcenter - relative Point for the scalingpublic BezierCurve getTransformed(AffineTransform t)
Path
representation of this IGeometry. Subclasses may override this
method to return a more specific representation.getTransformed in interface IGeometryt - The AffineTransform to be appliedPath representation of this
IGeometryIGeometry.getTransformed(AffineTransform)public BezierCurve getTranslated(double dx, double dy)
ITranslatablegetTranslated in interface ITranslatable<BezierCurve>dx - x-translationdy - y-translationpublic BezierCurve getTranslated(Point d)
ITranslatablePoint.getTranslated in interface ITranslatable<BezierCurve>d - translation Pointpublic double getX1()
ICurvePoint's x coordinate.public double getX2()
ICurvePoint's x coordinate.public double getY1()
ICurvePoint's y coordinate.public double getY2()
ICurvePoint's y coordinate.public boolean intersects(ICurve c)
ICurveICurve and the given ICurve intersect, i.e.
whether a final set of intersection points exists. Two curves intersect
if they touch (see IGeometry.touches(IGeometry)) but do not
overlap (see ICurve.overlaps(ICurve)).intersects in interface ICurvec - The ICurve to test for intersections.true if they intersect, false otherwisepublic boolean overlaps(BezierCurve other)
BezierCurve and the given other
BezierCurve overlap, i.e. an infinite set of intersection
Points exists.other - the BezierCurve to check for an overlapping segment
with this BezierCurvetrue if this and the given other BezierCurve
overlap, otherwise falsepublic final boolean overlaps(ICurve c)
ICurveICurve and the given ICurve overlap, i.e.
whether an infinite set of intersection points exists. Two curves overlap
if they touch (see IGeometry.touches(IGeometry)) but not
intersect (see ICurve.intersects(ICurve)).public BezierCurve rotateCCW(Angle angle)
BezierCurve counter-clockwise (CCW) around
its center Point by the given Angle. Direct adaptation
means, that this BezierCurve is modified in-place.angle - the rotation Anglethis for conveniencepublic BezierCurve rotateCCW(Angle angle, double cx, double cy)
BezierCurve counter-clockwise (CCW) around
the Point specified by the given x and y coordinate values by the
given Angle. Direct adaptation means, that this
BezierCurve is modified in-place.public BezierCurve rotateCCW(Angle angle, Point center)
BezierCurve counter-clockwise (CCW) around
the given Point by the given Angle. Direct adaptation
means, that this BezierCurve is modified in-place.public BezierCurve rotateCW(Angle angle)
BezierCurve clockwise (CW) around its
center Point by the given Angle. Direct adaptation means,
that this BezierCurve is modified in-place.angle - the rotation Anglethis for conveniencepublic BezierCurve rotateCW(Angle angle, double cx, double cy)
BezierCurve clockwise (CW) around the
Point specified by the given x and y coordinate values by the
given Angle. Direct adaptation means, that this
BezierCurve is modified in-place.public BezierCurve rotateCW(Angle angle, Point center)
BezierCurve clockwise (CW) around the given
Point by the given Angle. Direct adaptation means, that
this BezierCurve is modified in-place.public BezierCurve scale(double factor)
IScalablePoint.scale in interface IScalable<BezierCurve>factor - scale-factorthis for conveniencepublic BezierCurve scale(double fx, double fy)
IScalablePoint.scale in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorthis for conveniencepublic BezierCurve scale(double factor, double cx, double cy)
IScalablePoint (cx, cy).scale in interface IScalable<BezierCurve>factor - scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingthis for conveniencepublic BezierCurve scale(double fx, double fy, double cx, double cy)
IScalablePoint (cx, cy).scale in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingthis for conveniencepublic BezierCurve scale(double fx, double fy, Point center)
IScalablePoint.scale in interface IScalable<BezierCurve>fx - x-scale-factorfy - y-scale-factorcenter - relative Point for the scalingthis for conveniencepublic BezierCurve scale(double factor, Point center)
IScalablePoint.scale in interface IScalable<BezierCurve>factor - scale-factorcenter - relative Point for the scalingthis for conveniencepublic BezierCurve setP1(Point p1)
p1 - the new start Point of this BezierCurvethis for conveniencepublic BezierCurve setP2(Point p2)
p2 - the new end Point of this BezierCurvethis for conveniencepublic BezierCurve setPoint(int i, Point p)
Point of this BezierCurve.
The start Point is at index 0, the first handle-
Point is at index 1, etc.i - the index of the control Point of this
BezierCurve to setp - the new control Point at the given indexthis for conveniencepublic BezierCurve[] split(double t)
BezierCurve at the given parameter value t
into two new BezierCurves. The first one is the
BezierCurve over the parameter Interval
[0;t] and the second one is the BezierCurve over the
parameter Interval [t;1].t - the parameter value at which this BezierCurve is
subdividedBezierCurves, the left (
[0;t]) and the right ([t;1])public BezierCurve[] toBezier()
ICurveBezierCurves that approximate the
ICurve. For example, a Line or a BezierCurve in
general could return a list with the curve itself as its only element.
But an Ellipse or an Arc may return a list of consecutive
BezierCurves which approximate the ICurve.toBezier in interface ICurveBezierCurves that approximate the
ICurvepublic CubicCurve toCubic()
BezierCurve as a
CubicCurve. The new CubicCurve is constructed from the
start Point, the first two handle Points and the end
Point of this BezierCurve. If this BezierCurve is
not of degree four or higher, i.e. it does not have four or more control
Points (including start and end Point), null
is returned.CubicCurve that is constructed from the start
Point, the first two handle Points and the end
Point of this BezierCurve or null if
this BezierCurve does not have at least four control
Pointspublic Line toLine()
BezierCurve as a
Line. The Line is constructed from the start and end
Point of this BezierCurve.Line from the start Point to the end
Point of this BezierCurve or null if
this BezierCurve does only have one control Pointpublic Line[] toLineStrip(double lineSimilarity)
BezierCurve by a strip of
Lines. For detailed information on how the approximation is
computed, see toLineStrip(double, Interval).lineSimilarity - the threshold for the sum of the distances of the control
Points to the baseline (toLine()) of this
BezierCurveBezierCurve by a strip of
LinestoLineStrip(double, Interval)public Line[] toLineStrip(double lineSimilarity, org.eclipse.gef4.geometry.planar.BezierCurve.Interval startInterval)
Computes an approximation of this BezierCurve by a strip of
Lines.
The BezierCurve is recursively subdivided until it is "similar"
to a straight Line. The similarity check computes the sum of the
distances of the control Points to the baseline (
toLine()) of this BezierCurve. If this sum is smaller
than the given lineSimilarity, the BezierCurve is assumed
to be "similar" to a straight line.
lineSimilarity - the threshold for the sum of the distances of the control
points to the baseline of this BezierCurvestartInterval - the Interval of this BezierCurve that has to
be approximated by a strip of LinesLine segments approximating this BezierCurvepublic Path toPath()
toPath in interface IGeometryPath approximating this BezierCurve using
Line segmentspublic Point[] toPoints(org.eclipse.gef4.geometry.planar.BezierCurve.Interval startInterval)
Points on this BezierCurve over the given
Interval. Consecutive returned Points are required to be
equal to each other.startInterval - the Interval of this BezierCurve to calculate
Points forPoints on this BezierCurve over the given
parameter Interval where consecutive Points are
equal to each otherpublic QuadraticCurve toQuadratic()
BezierCurve as a
QuadraticCurve. The new QuadraticCurve is constructed
from the start Point, the first handle Point and the end
Point of this BezierCurve. If this BezierCurve is
not of degree three or higher, i.e. it does not have three or more
control Points (including start and end Point),
null is returned.QuadraticCurve that is constructed from the start
Point, the first handle Point and the end
Point of this BezierCurve or null if
this BezierCurve does not have at least three control
Pointspublic java.lang.String toString()
toString in class java.lang.Objectpublic BezierCurve translate(double dx, double dy)
ITranslatabletranslate in interface ITranslatable<BezierCurve>dx - x-translationdy - y-translationthis for conveniencepublic BezierCurve translate(Point d)
ITranslatablePoint.translate in interface ITranslatable<BezierCurve>d - translation Pointthis for conveniencepublic java.lang.Object clone()
Cloneable
.clone in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()Copyright (c) 2014 itemis AG, and others. All rights reserved.