public class Line extends BezierCurve
PrecisionUtils
) to compensate for rounding effects.Constructor and Description |
---|
Line(double... coordinates)
Constructs a new
Line from the given coordinate values. |
Line(double x1,
double y1,
double x2,
double y2)
|
Line(Point... points)
|
Line(Point p1,
Point p2)
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
boolean |
contains(Point p)
|
boolean |
equals(double x1,
double y1,
double x2,
double y2)
Tests whether this
Line is equal to the line given implicitly by
the given point coordinates. |
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()
|
Line |
getCopy()
Returns a new
Line , which has the same start and end point
coordinates as this one. |
Angle |
getDirectionCCW()
Returns the counter-clockwise angle between the x axis and this
Line . |
Angle |
getDirectionCW()
Returns the clockwise angle between the x axis and this
Line . |
Point |
getIntersection(Line l)
Returns the single intersection point between this
Line and the
given one, in case it exists. |
Point[] |
getIntersections(BezierCurve curve)
Returns the
Point s of intersection of this and the given other
BezierCurve . |
double |
getLength()
|
Point[] |
getPoints()
|
Point |
getProjection(Point p)
|
Line |
getTransformed(AffineTransform t)
|
int |
hashCode() |
boolean |
intersects(ICurve c)
|
boolean |
intersects(Line l)
Provides an optimized version of the
BezierCurve.intersects(ICurve) method. |
boolean |
overlaps(BezierCurve c)
Checks if this
BezierCurve and the given other
BezierCurve overlap, i.e. an infinite set of intersection
Point s exists. |
boolean |
overlaps(Line l)
|
Line |
setLine(double x1,
double y1,
double x2,
double y2)
Initializes this
Line with the given start and end point
coordinates |
Line |
setLine(Line l)
Initializes this
Line with the start and end point coordinates of
the given one. |
Line |
setLine(Point p1,
Point p2)
Initializes this
Line with the start and end point coordinates
provided by the given points |
Line |
setX1(double x1)
|
Line |
setX2(double x2)
|
Line |
setY1(double y1)
|
Line |
setY2(double y2)
|
Path |
toPath()
|
java.lang.String |
toString() |
boolean |
touches(IGeometry g)
|
boolean |
touches(Line l)
Tests whether this
Line and the given one share at least one
common point. |
contains, equals, getClipped, getControlBounds, getDerivative, getElevated, getIntersections, getOffset, getOverlap, getOverlaps, getP1, getP2, getParameterAt, getPoint, getRotatedCCW, getRotatedCCW, getRotatedCCW, getRotatedCW, getRotatedCW, getRotatedCW, getScaled, getScaled, getScaled, getScaled, getScaled, getScaled, getTranslated, getTranslated, getX1, getX2, getY1, getY2, overlaps, rotateCCW, rotateCCW, rotateCCW, rotateCW, rotateCW, rotateCW, scale, scale, scale, scale, scale, scale, setP1, setP2, setPoint, split, toBezier, toCubic, toLine, toLineStrip, toLineStrip, toPoints, toQuadratic, translate, translate
public Line(double... coordinates)
Line
from the given coordinate values.coordinates
- A varargs of 4 doubles, providing the x and y coordinates of
the start point, followed by those of the end pointBezierCurve.BezierCurve(double[])
public Line(double x1, double y1, double x2, double y2)
x1
- the x-coordinate of the start pointy1
- the y-coordinate of the start pointx2
- the x-coordinate of the end pointy2
- the y-coordinate of the end pointpublic Line(Point... points)
points
- A varargs of two points serving as the start and end point of
this linepublic boolean equals(double x1, double y1, double x2, double y2)
Line
is equal to the line given implicitly by
the given point coordinates.x1
- the x-coordinate of the start point of the line to testy1
- the y-coordinate of the start point of the line to testx2
- the x-coordinate of the end point of the line to testy2
- the y-coordinate of the end point of the line to testtrue
if the given start and end point coordinates
are (imprecisely) equal to this Line
's start and end
point coordinatespublic Point get(double t)
BezierCurve
Point
on this BezierCurve
at parameter value
t, which is expected to lie in the parameter Interval
[0;1]
.get
in class BezierCurve
t
- the parameter value for which this BezierCurve
is
evaluatedPoint
on this BezierCurve
at the given
parameter valuepublic Rectangle getBounds()
getBounds
in interface IGeometry
getBounds
in class BezierCurve
Rectangle
object that fully encloses this
IGeometry
IGeometry.getBounds()
public Line getCopy()
Line
, which has the same start and end point
coordinates as this one.getCopy
in interface IGeometry
getCopy
in class BezierCurve
Line
with the same start and end point coordinatespublic Angle getDirectionCCW()
Line
.Line
.public Angle getDirectionCW()
Line
.Line
.public Point getIntersection(Line l)
Line
and the
given one, in case it exists. Note that even in case
intersects(org.eclipse.gef.geometry.planar.ICurve)
returns true, there may not be a single
intersection point in case both lines overlap in more than one point.l
- the Line, for which to compute the intersection pointLine
and the
given one, in case it intersects, null
insteadpublic Point[] getIntersections(BezierCurve curve)
BezierCurve
Point
s of intersection of this and the given other
BezierCurve
.getIntersections
in class BezierCurve
curve
- the BezierCurve
which is searched for Point
s
of intersection with this BezierCurve
Point
s of intersection of this BezierCurve
and the given other BezierCurve
public double getLength()
Point.getDistance(Point)
public Point[] getPoints()
getPoints
in class BezierCurve
Point
s, whose x and y coordinates match
those of this Line
's start and end pointpublic Point getProjection(Point p)
ICurve
Point
onto
this ICurve
, i.e. a Point
on this ICurve
that is
closest to the given reference Point
. Note, thatgetProjection
in interface ICurve
getProjection
in class BezierCurve
p
- The reference Point
for which to return the
projection.Point
onto
this ICurve
.public Line getTransformed(AffineTransform t)
Path
representation of this IGeometry
. Subclasses may override this
method to return a more specific representation.getTransformed
in interface IGeometry
getTransformed
in class BezierCurve
t
- The AffineTransform
to be appliedPath
representation of this
IGeometry
IGeometry.getTransformed(AffineTransform)
public boolean intersects(ICurve c)
ICurve
ICurve
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 ICurve
intersects
in class BezierCurve
c
- The ICurve
to test for intersections.true
if they intersect, false
otherwisepublic boolean intersects(Line l)
BezierCurve.intersects(ICurve)
method.l
- The Line
to test for intersections.BezierCurve.intersects(ICurve)
public boolean overlaps(BezierCurve c)
BezierCurve
BezierCurve
and the given other
BezierCurve
overlap, i.e. an infinite set of intersection
Point
s exists.overlaps
in class BezierCurve
c
- the BezierCurve
to check for an overlapping segment
with this BezierCurve
true
if this and the given other BezierCurve
overlap, otherwise false
public boolean overlaps(Line l)
Line
and the given other Line
overlap,
i.e. they share an infinite number of Point
s.l
- the other Line
to test for overlap with this
Line
true
if this Line
and the other Line
overlap, otherwise false
ICurve.overlaps(ICurve)
public Line setLine(double x1, double y1, double x2, double y2)
Line
with the given start and end point
coordinatesx1
- the x-coordinate of the start pointy1
- the y-coordinate of the start pointx2
- the x-coordinate of the end pointy2
- the y-coordinate of the end pointthis
for conveniencepublic Line setLine(Line l)
Line
with the start and end point coordinates of
the given one.l
- the Line
whose start and end point coordinates should
be used for initializationthis
for conveniencepublic Line setLine(Point p1, Point p2)
Line
with the start and end point coordinates
provided by the given pointspublic Line setX1(double x1)
public Line setX2(double x2)
public Line setY1(double y1)
public Line setY2(double y2)
public Path toPath()
BezierCurve
toPath
in interface IGeometry
toPath
in class BezierCurve
Path
approximating this BezierCurve
using
Line
segmentspublic java.lang.String toString()
toString
in class BezierCurve
public boolean touches(Line l)
Line
and the given one share at least one
common point.public java.lang.Object clone()
Cloneable
.clone
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) 2014 itemis AG, and others. All rights reserved.