|
||||||||||
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 | |
---|---|
GeneralPath |
appendPath(GeneralPath path)
Append the path of the curve to the given path. |
CurveSet2D<? extends Line2D> |
clip(Box2D box)
Clip 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. |
static Line2D |
create(Point2D p1,
Point2D p2)
Static factory for creating a new Line2D, starting from p1 and finishing at p2. |
boolean |
equals(Object obj)
Two Line2D are equals if the share the two same points, in the same order. |
Box2D |
getBoundingBox()
Returns the bounding box of the Line2D. |
CirculinearDomain2D |
getBuffer(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[] |
getCartesianEquation()
|
Collection<? extends Line2D> |
getContinuousCurves()
Returns the collection of continuous curves which constitute this curve. |
double |
getCurvature(double t)
Returns 0 as every linear shape. |
double |
getDistance(double x,
double y)
Get the distance of the point (x, y) to this edge. |
double |
getDistance(Point2D p)
Get the distance of the point (x, y) to this edge. |
Point2D |
getFirstPoint()
Get the first point of the curve. |
GeneralPath |
getGeneralPath()
|
double |
getHorizontalAngle()
Gets Angle with axis (O,i), counted counter-clockwise. |
Point2D |
getIntersection(LinearShape2D line)
Returns the unique intersection with a linear shape. |
Collection<Point2D> |
getIntersections(LinearShape2D line)
Returns the intersection points of the curve with the specified line. |
Point2D |
getLastPoint()
Get the last point of the curve. |
double |
getLength()
|
double |
getLength(double pos)
|
Point2D |
getOrigin()
Returns a point in the linear shape. |
Point2D |
getOtherPoint(Point2D point)
Return the opposite vertex of the edge. |
Line2D |
getParallel(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.In the case of a continuous curve formed by several smooth circulinear elements, the parallels of contiguous elements are joined by a circle arc. |
StraightLine2D |
getParallel(Point2D point)
Create a straight line parallel to this object, and going through the given point. |
double[][] |
getParametric()
|
StraightLine2D |
getPerpendicular(Point2D point)
Create a straight line perpendicular to this object, and going through the given point. |
Point2D |
getPoint(double t)
Gets the point from a parametric representation of the curve. |
Point2D |
getPoint1()
Return the first point of the edge. |
Point2D |
getPoint2()
Return the last point of the edge. |
double[] |
getPolarCoefficients()
|
double |
getPosition(double length)
|
double |
getPosition(Point2D point)
Gets position of the point on the line. |
Line2D |
getReverseCurve()
Returns the line object which starts at point2 and ends at
point1 . |
double |
getSignedDistance(double x,
double y)
The same as getSignedDistance(Point2D), but by passing 2 double as arguments. |
double |
getSignedDistance(Point2D p)
Get the signed distance of the curve to the given point: this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape. |
double[] |
getSignedPolarCoefficients()
|
Collection<? extends Line2D> |
getSmoothPieces()
Returns a set of smooth curves. |
Line2D |
getSubCurve(double t0,
double t1)
Return a new Line2D, which is the portion of the line delimited by parameters t0 and t1. |
StraightLine2D |
getSupportingLine()
|
double |
getT0()
Returns 0. |
double |
getT1()
Returns 1. |
Vector2D |
getTangent(double t)
|
Vector2D |
getVector()
Return one direction vector of the linear shape. |
double |
getWindingAngle(Point2D point)
Return the angle portion that the curve turn around the given point. |
double |
getX1()
|
double |
getX2()
|
double |
getY1()
|
double |
getY2()
|
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. |
double |
project(Point2D point)
Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. |
void |
setPoint1(Point2D point)
|
void |
setPoint2(Point2D point)
|
String |
toString()
|
Line2D |
transform(AffineTransform2D trans)
Transforms the shape by an affine transform. |
CirculinearElement2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion. |
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D |
---|
getLeftTangent, getRightTangent, getSingularPoints, isSingular |
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D |
---|
draw, getAsAWTShape, getAsPolyline, wrapCurve |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D |
---|
getAsPolyline, getLeftTangent, getRightTangent |
Methods inherited from interface math.geom2d.curve.Curve2D |
---|
draw, getAsAWTShape, getSingularPoints, isSingular |
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
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 getBuffer(double dist)
CirculinearShape2D
getBuffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shape
public Line2D getParallel(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.
getParallel
in interface CirculinearContinuousCurve2D
getParallel
in interface CirculinearCurve2D
getParallel
in interface CirculinearElement2D
getParallel
in interface ContinuousCirculinearCurve2D
d
- the distance between the original curve and he parallel curve.
public double getLength()
getLength
in interface CirculinearCurve2D
public double getLength(double pos)
getLength
in interface CirculinearCurve2D
public double getPosition(double length)
getPosition
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
transform
in interface ContinuousCirculinearCurve2D
inv
- the circle inversion
public double[][] getParametric()
public double[] getCartesianEquation()
public double[] getPolarCoefficients()
public double[] getSignedPolarCoefficients()
public double getHorizontalAngle()
LinearShape2D
getHorizontalAngle
in interface LinearShape2D
public Point2D getIntersection(LinearShape2D line)
LinearShape2D
getIntersection
in interface LinearShape2D
public Point2D getOrigin()
LinearShape2D
getOrigin
in interface LinearShape2D
public StraightLine2D getSupportingLine()
getSupportingLine
in interface LinearShape2D
public Vector2D getVector()
LinearShape2D
getVector
in interface LinearShape2D
public double getSignedDistance(Point2D p)
OrientedCurve2D
getSignedDistance
in interface OrientedCurve2D
p
- a point of the plane
public double getSignedDistance(double x, double y)
OrientedCurve2D
getSignedDistance
in interface OrientedCurve2D
x
- x-coord of a pointy
- y-coord of a point
public Collection<? extends Line2D> getSmoothPieces()
ContinuousCurve2D
getSmoothPieces
in interface CirculinearContinuousCurve2D
getSmoothPieces
in interface ContinuousCirculinearCurve2D
getSmoothPieces
in interface ContinuousCurve2D
getSmoothPieces
in class AbstractSmoothCurve2D
public boolean isClosed()
isClosed
in interface ContinuousCurve2D
ContinuousCurve2D.isClosed()
public double getDistance(Point2D p)
getDistance
in interface Shape2D
public double getDistance(double x, double y)
getDistance
in interface Shape2D
public StraightLine2D getParallel(Point2D point)
point
- the point to go through
public StraightLine2D getPerpendicular(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 ContinuousCirculinearCurve2D
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 Shape2D
box
- the clipping box
public Box2D getBoundingBox()
getBoundingBox
in interface Shape2D
public Vector2D getTangent(double t)
getTangent
in interface SmoothCurve2D
public double getCurvature(double t)
getCurvature
in interface SmoothCurve2D
public double getWindingAngle(Point2D point)
OrientedCurve2D
getWindingAngle
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 getT0()
getT0
in interface Curve2D
public double getT1()
getT1
in interface Curve2D
public Point2D getPoint(double t)
Curve2D
getPoint
in interface Curve2D
public Point2D getFirstPoint()
getFirstPoint
in interface Curve2D
getFirstPoint
in class AbstractContinuousCurve2D
public Point2D getLastPoint()
getLastPoint
in interface Curve2D
getLastPoint
in class AbstractContinuousCurve2D
public double getPosition(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>.
getPosition
in interface Curve2D
point
- a point belonging to the curve
public double project(Point2D point)
Curve2D
project
in interface Curve2D
point
- a point to project
public Line2D getReverseCurve()
point2
and ends at
point1
.
getReverseCurve
in interface CirculinearContinuousCurve2D
getReverseCurve
in interface CirculinearCurve2D
getReverseCurve
in interface CirculinearElement2D
getReverseCurve
in interface ContinuousCirculinearCurve2D
getReverseCurve
in interface ContinuousCurve2D
getReverseCurve
in interface Curve2D
getReverseCurve
in interface SmoothCurve2D
getReverseCurve
in interface ContinuousOrientedCurve2D
getReverseCurve
in interface OrientedCurve2D
getReverseCurve
in interface SmoothOrientedCurve2D
public Collection<? extends Line2D> getContinuousCurves()
Curve2D
getContinuousCurves
in interface CirculinearCurve2D
getContinuousCurves
in interface Curve2D
getContinuousCurves
in class AbstractContinuousCurve2D
public Line2D getSubCurve(double t0, double t1)
getSubCurve
in interface CirculinearContinuousCurve2D
getSubCurve
in interface CirculinearCurve2D
getSubCurve
in interface CirculinearElement2D
getSubCurve
in interface ContinuousCirculinearCurve2D
getSubCurve
in interface ContinuousCurve2D
getSubCurve
in interface Curve2D
getSubCurve
in interface SmoothCurve2D
getSubCurve
in interface ContinuousOrientedCurve2D
getSubCurve
in interface SmoothOrientedCurve2D
t0
- position of the start of the sub-curvet1
- position of the end of the sub-curve
public Collection<Point2D> getIntersections(LinearShape2D line)
Curve2D
getIntersections
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 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 GeneralPath getGeneralPath()
public GeneralPath appendPath(GeneralPath path)
ContinuousCurve2D
appendPath
in interface ContinuousCurve2D
path
- a path to modify
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class 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 |