|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.geom2d.curve.AbstractContinuousCurve2D math.geom2d.curve.AbstractSmoothCurve2D math.geom2d.line.Line2D
public class Line2D
Line object defined from 2 points. This object keep points reference in memory, and recomputes properties directly from points. Line2D is mutable.
Example :
// Create an Edge2D
Line2D line = new Line2D(new Point2D(0, 0), new Point2D(1, 2));
// Change direction of line, by changing second point :
line.setPoint2(new Point2D(4, 5));
// Change position and direction of the line, by changing first point.
// 'line' is now the edge (2,3)-(4,5)
line.setPoint1(new Point2D(2, 3));
This class may be slower than Edge2D or StraightLine2D, because parameters
are updated each time a computation is made, causing lot of additional
processing. Moreover, as inner point fields are public, it is not as safe
as LineSegment2D
.
Field Summary | |
---|---|
Point2D |
p1
The origin point. |
Point2D |
p2
The destination point. |
Fields inherited from interface math.geom2d.Shape2D |
---|
ACCURACY |
Constructor Summary | |
---|---|
Line2D(double x1,
double y1,
double x2,
double y2)
Define a new Line2D with two extremities. |
|
Line2D(Point2D point1,
Point2D point2)
Define a new Line2D with two extremities. |
Method Summary | |
---|---|
boolean |
almostEquals(GeometricObject2D obj,
double eps)
Checks if the two objects are similar up to a given threshold value. |
java.awt.geom.GeneralPath |
appendPath(java.awt.geom.GeneralPath path)
Append the path of the curve to the given path. |
Box2D |
boundingBox()
Returns the bounding box of the Line2D. |
CirculinearDomain2D |
buffer(double dist)
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d. |
double[] |
cartesianEquation()
|
CurveSet2D<? extends Line2D> |
clip(Box2D box)
Clips the line object by a box. |
Line2D |
clone()
Overrides Object declaration to ensure Curve2D implementation are cloned as Curve2D. |
boolean |
contains(double x,
double y)
Returns true if the point (x, y) lies on the line, with precision given by Shape2D.ACCURACY. |
boolean |
contains(Point2D p)
Returns true if the point p lies on the line, with precision given by Shape2D.ACCURACY. |
java.util.Collection<? extends Line2D> |
continuousCurves()
Returns the collection of continuous curves which constitute this curve. |
static Line2D |
create(Point2D p1,
Point2D p2)
Deprecated. since 0.11.1 |
double |
curvature(double t)
Returns 0 as every linear shape. |
Vector2D |
direction()
Return one direction vector of the linear shape. |
double |
distance(double x,
double y)
Returns the distance of the point (x, y) to this edge. |
double |
distance(Point2D p)
Returns the distance of the point p to this edge. |
boolean |
equals(java.lang.Object obj)
Two Line2D are equals if the share the two same points, in the same order. |
Point2D |
firstPoint()
Get the first point of the curve. |
java.awt.geom.GeneralPath |
getGeneralPath()
|
Point2D |
getOtherPoint(Point2D point)
Return the opposite vertex of the edge. |
Point2D |
getPoint1()
Return the first point of the edge. |
Point2D |
getPoint2()
Return the last point of the edge. |
double |
getT0()
Deprecated. replaced by t0() (since 0.11.1). |
double |
getT1()
Deprecated. replaced by t1() (since 0.11.1). |
double |
getX1()
|
double |
getX2()
|
double |
getY1()
|
double |
getY2()
|
double |
horizontalAngle()
Returns the angle with axis (O,i), counted counter-clockwise. |
Point2D |
intersection(LinearShape2D line)
Returns the unique intersection with a linear shape. |
java.util.Collection<Point2D> |
intersections(LinearShape2D line)
Returns the intersection points of the curve with the specified line. |
static boolean |
intersects(Line2D line1,
Line2D line2)
Checks if two line intersect. |
boolean |
isBounded()
Returns true |
boolean |
isClosed()
Returns false. |
boolean |
isColinear(LinearShape2D line)
|
boolean |
isEmpty()
Returns false |
boolean |
isInside(Point2D point)
Returns true if the point is 'inside' the domain bounded by the curve. |
boolean |
isParallel(LinearShape2D line)
Test if the this object is parallel to the given one. |
Point2D |
lastPoint()
Get the last point of the curve. |
double |
length()
|
double |
length(double pos)
|
Point2D |
origin()
Returns a point in the linear shape. |
Line2D |
parallel(double d)
Creates a new curve, formed by the points with parameterization: p(t) = c(t) + d*n(t)/|n(t)| , with p(t) being a point of
the original curve, n(t) the normal of the curve, and |n| being the
norm of n. |
StraightLine2D |
parallel(Point2D point)
Creates a straight line parallel to this object, and passing through the given point. |
double[][] |
parametric()
|
StraightLine2D |
perpendicular(Point2D point)
Creates a straight line perpendicular to this object, and passing through the given point. |
Point2D |
point(double t)
Returns the point located at the given position on the curve. |
double[] |
polarCoefficients()
|
double[] |
polarCoefficientsSigned()
|
double |
position(double length)
|
double |
position(Point2D point)
Returns the position of the point on the line. |
double |
project(Point2D point)
Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. |
Line2D |
reverse()
Returns the Line2D object which starts at point2 and ends at
point1 . |
void |
setPoint1(Point2D point)
|
void |
setPoint2(Point2D point)
|
double |
signedDistance(double x,
double y)
The same as distanceSigned(Point2D), but by passing 2 double as arguments. |
double |
signedDistance(Point2D p)
Returns the signed distance of the curve to the given point. |
java.util.Collection<? extends Line2D> |
smoothPieces()
Returns a set of smooth curves. |
Line2D |
subCurve(double t0,
double t1)
Returns a new Line2D, which is the portion of the line delimited by parameters t0 and t1. |
StraightLine2D |
supportingLine()
Returns the straight line that contains this linear shape. |
double |
t0()
Returns 0. |
double |
t1()
Returns 1. |
Vector2D |
tangent(double t)
Returns the tangent of the curve at the given position. |
java.lang.String |
toString()
|
Line2D |
transform(AffineTransform2D trans)
Transforms the shape by an affine transform. |
CirculinearElement2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion. |
double |
windingAngle(Point2D point)
Return the angle portion that the curve turn around the given point. |
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D |
---|
isSingular, leftTangent, normal, rightTangent, singularPoints, vertices |
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D |
---|
asAwtShape, asPolyline, draw |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface math.geom2d.curve.SmoothCurve2D |
---|
normal |
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D |
---|
asPolyline, leftTangent, rightTangent |
Methods inherited from interface math.geom2d.curve.Curve2D |
---|
asAwtShape, draw, isSingular, singularPoints, vertices |
Field Detail |
---|
public Point2D p1
public Point2D p2
Constructor Detail |
---|
public Line2D(Point2D point1, Point2D point2)
public Line2D(double x1, double y1, double x2, double y2)
Method Detail |
---|
public static boolean intersects(Line2D line1, Line2D line2)
Point2D.ccw
method, which is based on Sedgewick algorithm.
line1
- a Line2D objectline2
- a Line2D object
@Deprecated public static Line2D create(Point2D p1, Point2D p2)
public Point2D getPoint1()
public Point2D getPoint2()
public double getX1()
public double getY1()
public double getX2()
public double getY2()
public Point2D getOtherPoint(Point2D point)
point
- : one of the vertices of the edge
public void setPoint1(Point2D point)
public void setPoint2(Point2D point)
public boolean isColinear(LinearShape2D line)
public boolean isParallel(LinearShape2D line)
public CirculinearDomain2D buffer(double dist)
CirculinearShape2D
buffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shape
public Line2D parallel(double d)
CirculinearCurve2D
p(t) = c(t) + d*n(t)/|n(t)|
, with p(t) being a point of
the original curve, n(t) the normal of the curve, and |n| being the
norm of n.
parallel
in interface CirculinearContinuousCurve2D
parallel
in interface CirculinearCurve2D
parallel
in interface CirculinearElement2D
d
- the distance between the original curve and he parallel curve.
public double length()
length
in interface CirculinearCurve2D
public double length(double pos)
length
in interface CirculinearCurve2D
public double position(double length)
position
in interface CirculinearCurve2D
public CirculinearElement2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearContinuousCurve2D
transform
in interface CirculinearCurve2D
transform
in interface CirculinearElement2D
transform
in interface CirculinearShape2D
inv
- the circle inversion
public double[][] parametric()
public double[] cartesianEquation()
public double[] polarCoefficients()
public double[] polarCoefficientsSigned()
public double horizontalAngle()
LinearShape2D
horizontalAngle
in interface LinearShape2D
public Point2D intersection(LinearShape2D line)
LinearShape2D
intersection
in interface LinearShape2D
public Point2D origin()
LinearShape2D
origin
in interface LinearShape2D
public StraightLine2D supportingLine()
LinearShape2D
supportingLine
in interface LinearShape2D
public Vector2D direction()
LinearShape2D
direction
in interface LinearShape2D
public double signedDistance(Point2D p)
OrientedCurve2D
signedDistance
in interface OrientedCurve2D
p
- a point of the plane
public double signedDistance(double x, double y)
OrientedCurve2D
signedDistance
in interface OrientedCurve2D
x
- x-coord of a pointy
- y-coord of a point
public java.util.Collection<? extends Line2D> smoothPieces()
ContinuousCurve2D
smoothPieces
in interface CirculinearContinuousCurve2D
smoothPieces
in interface ContinuousCurve2D
smoothPieces
in class AbstractSmoothCurve2D
public boolean isClosed()
isClosed
in interface ContinuousCurve2D
ContinuousCurve2D.isClosed()
public double distance(Point2D p)
p
to this edge.
distance
in interface Shape2D
public double distance(double x, double y)
distance
in interface Shape2D
public StraightLine2D parallel(Point2D point)
point
- the point to go through
public StraightLine2D perpendicular(Point2D point)
point
- the point to go through
public CurveSet2D<? extends Line2D> clip(Box2D box)
clip
in interface CirculinearContinuousCurve2D
clip
in interface CirculinearCurve2D
clip
in interface CirculinearElement2D
clip
in interface ContinuousCurve2D
clip
in interface Curve2D
clip
in interface SmoothCurve2D
clip
in interface ContinuousOrientedCurve2D
clip
in interface OrientedCurve2D
clip
in interface SmoothOrientedCurve2D
clip
in interface LinearElement2D
clip
in interface Shape2D
box
- the clipping box
public Box2D boundingBox()
boundingBox
in interface Shape2D
public Vector2D tangent(double t)
SmoothCurve2D
tangent
in interface SmoothCurve2D
t
- a position on the curve
SmoothCurve2D.normal(double)
public double curvature(double t)
curvature
in interface ContinuousCurve2D
t
- the position on the curve
public double windingAngle(Point2D point)
OrientedCurve2D
windingAngle
in interface OrientedCurve2D
point
- a point of the plane
public boolean isInside(Point2D point)
OrientedCurve2D
isInside
in interface OrientedCurve2D
point
- a point in the plane
public double t0()
t0
in interface Curve2D
@Deprecated public double getT0()
getT0
in interface Curve2D
public double t1()
t1
in interface Curve2D
@Deprecated public double getT1()
getT1
in interface Curve2D
public Point2D point(double t)
Curve2D
point
in interface Curve2D
public Point2D firstPoint()
firstPoint
in interface Curve2D
firstPoint
in class AbstractContinuousCurve2D
Curve2D.t0()
,
Curve2D.point(double)
public Point2D lastPoint()
lastPoint
in interface Curve2D
lastPoint
in class AbstractContinuousCurve2D
Curve2D.t1()
,
Curve2D.point(double)
public double position(Point2D point)
If point does not belong to edge, return Double.NaN. The current implementation
uses the direction with the biggest derivative, in order to avoid divisions
by zero.
t = (xp - x0)/dx <\code>, or equivalently :
t = (yp - y0)/dy <\code>.
point
- a point belonging to the curve
Curve2D.point(double)
public double project(Point2D point)
Curve2D
project
in interface Curve2D
point
- a point to project
public Line2D reverse()
point2
and ends at
point1
.
reverse
in interface CirculinearContinuousCurve2D
reverse
in interface CirculinearCurve2D
reverse
in interface CirculinearElement2D
reverse
in interface ContinuousCurve2D
reverse
in interface Curve2D
reverse
in interface SmoothCurve2D
reverse
in interface ContinuousOrientedCurve2D
reverse
in interface OrientedCurve2D
reverse
in interface SmoothOrientedCurve2D
public java.util.Collection<? extends Line2D> continuousCurves()
Curve2D
continuousCurves
in interface CirculinearCurve2D
continuousCurves
in interface Curve2D
continuousCurves
in class AbstractContinuousCurve2D
public Line2D subCurve(double t0, double t1)
subCurve
in interface CirculinearContinuousCurve2D
subCurve
in interface CirculinearCurve2D
subCurve
in interface CirculinearElement2D
subCurve
in interface ContinuousCurve2D
subCurve
in interface Curve2D
subCurve
in interface SmoothCurve2D
subCurve
in interface ContinuousOrientedCurve2D
subCurve
in interface SmoothOrientedCurve2D
subCurve
in interface LinearElement2D
t0
- position of the start of the sub-curvet1
- position of the end of the sub-curve
public java.util.Collection<Point2D> intersections(LinearShape2D line)
Curve2D
intersections
in interface Curve2D
public Line2D transform(AffineTransform2D trans)
Shape2D
transform
in interface ContinuousCurve2D
transform
in interface Curve2D
transform
in interface SmoothCurve2D
transform
in interface ContinuousOrientedCurve2D
transform
in interface OrientedCurve2D
transform
in interface SmoothOrientedCurve2D
transform
in interface LinearElement2D
transform
in interface LinearShape2D
transform
in interface Shape2D
trans
- an affine transform
public boolean contains(double x, double y)
contains
in interface Shape2D
public boolean contains(Point2D p)
contains
in interface Shape2D
public boolean isBounded()
isBounded
in interface Shape2D
public boolean isEmpty()
isEmpty
in interface Shape2D
public java.awt.geom.GeneralPath getGeneralPath()
public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
ContinuousCurve2D
appendPath
in interface ContinuousCurve2D
path
- a path to modify
public boolean almostEquals(GeometricObject2D obj, double eps)
GeometricObject2D
almostEquals
in interface GeometricObject2D
obj
- the object to compareeps
- a threshold value, for example the minimal coordinate difference
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the edge to compare to.
public Line2D clone()
Curve2D
clone
in interface Curve2D
clone
in class AbstractSmoothCurve2D
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |