|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectmath.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 CirculinearShape2Ddist - 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 CirculinearContinuousCurve2DgetParallel in interface CirculinearCurve2DgetParallel in interface CirculinearElement2DgetParallel in interface ContinuousCirculinearCurve2Dd - the distance between the original curve and he parallel curve.
public double getLength()
getLength in interface CirculinearCurve2Dpublic double getLength(double pos)
getLength in interface CirculinearCurve2Dpublic double getPosition(double length)
getPosition in interface CirculinearCurve2Dpublic CirculinearElement2D transform(CircleInversion2D inv)
CirculinearShape2D
transform in interface CirculinearContinuousCurve2Dtransform in interface CirculinearCurve2Dtransform in interface CirculinearElement2Dtransform in interface CirculinearShape2Dtransform in interface ContinuousCirculinearCurve2Dinv - the circle inversion
public double[][] getParametric()
public double[] getCartesianEquation()
public double[] getPolarCoefficients()
public double[] getSignedPolarCoefficients()
public double getHorizontalAngle()
LinearShape2D
getHorizontalAngle in interface LinearShape2Dpublic Point2D getIntersection(LinearShape2D line)
LinearShape2D
getIntersection in interface LinearShape2Dpublic Point2D getOrigin()
LinearShape2D
getOrigin in interface LinearShape2Dpublic StraightLine2D getSupportingLine()
getSupportingLine in interface LinearShape2Dpublic Vector2D getVector()
LinearShape2D
getVector in interface LinearShape2Dpublic double getSignedDistance(Point2D p)
OrientedCurve2D
getSignedDistance in interface OrientedCurve2Dp - a point of the plane
public double getSignedDistance(double x,
double y)
OrientedCurve2D
getSignedDistance in interface OrientedCurve2Dx - x-coord of a pointy - y-coord of a point
public Collection<? extends Line2D> getSmoothPieces()
ContinuousCurve2D
getSmoothPieces in interface CirculinearContinuousCurve2DgetSmoothPieces in interface ContinuousCirculinearCurve2DgetSmoothPieces in interface ContinuousCurve2DgetSmoothPieces in class AbstractSmoothCurve2Dpublic boolean isClosed()
isClosed in interface ContinuousCurve2DContinuousCurve2D.isClosed()public double getDistance(Point2D p)
getDistance in interface Shape2D
public double getDistance(double x,
double y)
getDistance in interface Shape2Dpublic 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 CirculinearContinuousCurve2Dclip in interface CirculinearCurve2Dclip in interface CirculinearElement2Dclip in interface ContinuousCirculinearCurve2Dclip in interface ContinuousCurve2Dclip in interface Curve2Dclip in interface SmoothCurve2Dclip in interface ContinuousOrientedCurve2Dclip in interface OrientedCurve2Dclip in interface SmoothOrientedCurve2Dclip in interface Shape2Dbox - the clipping box
public Box2D getBoundingBox()
getBoundingBox in interface Shape2Dpublic Vector2D getTangent(double t)
getTangent in interface SmoothCurve2Dpublic double getCurvature(double t)
getCurvature in interface SmoothCurve2Dpublic double getWindingAngle(Point2D point)
OrientedCurve2D
getWindingAngle in interface OrientedCurve2Dpoint - a point of the plane
public boolean isInside(Point2D point)
OrientedCurve2D
isInside in interface OrientedCurve2Dpoint - a point in the plane
public double getT0()
getT0 in interface Curve2Dpublic double getT1()
getT1 in interface Curve2Dpublic Point2D getPoint(double t)
Curve2D
getPoint in interface Curve2Dpublic Point2D getFirstPoint()
getFirstPoint in interface Curve2DgetFirstPoint in class AbstractContinuousCurve2Dpublic Point2D getLastPoint()
getLastPoint in interface Curve2DgetLastPoint in class AbstractContinuousCurve2Dpublic 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 Curve2Dpoint - a point to project
public Line2D getReverseCurve()
point2 and ends at
point1.
getReverseCurve in interface CirculinearContinuousCurve2DgetReverseCurve in interface CirculinearCurve2DgetReverseCurve in interface CirculinearElement2DgetReverseCurve in interface ContinuousCirculinearCurve2DgetReverseCurve in interface ContinuousCurve2DgetReverseCurve in interface Curve2DgetReverseCurve in interface SmoothCurve2DgetReverseCurve in interface ContinuousOrientedCurve2DgetReverseCurve in interface OrientedCurve2DgetReverseCurve in interface SmoothOrientedCurve2Dpublic Collection<? extends Line2D> getContinuousCurves()
Curve2D
getContinuousCurves in interface CirculinearCurve2DgetContinuousCurves in interface Curve2DgetContinuousCurves in class AbstractContinuousCurve2D
public Line2D getSubCurve(double t0,
double t1)
getSubCurve in interface CirculinearContinuousCurve2DgetSubCurve in interface CirculinearCurve2DgetSubCurve in interface CirculinearElement2DgetSubCurve in interface ContinuousCirculinearCurve2DgetSubCurve in interface ContinuousCurve2DgetSubCurve in interface Curve2DgetSubCurve in interface SmoothCurve2DgetSubCurve in interface ContinuousOrientedCurve2DgetSubCurve in interface SmoothOrientedCurve2Dt0 - 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 Curve2Dpublic Line2D transform(AffineTransform2D trans)
Shape2D
transform in interface ContinuousCurve2Dtransform in interface Curve2Dtransform in interface SmoothCurve2Dtransform in interface ContinuousOrientedCurve2Dtransform in interface OrientedCurve2Dtransform in interface SmoothOrientedCurve2Dtransform in interface LinearShape2Dtransform in interface Shape2Dtrans - an affine transform
public boolean contains(double x,
double y)
contains in interface Shape2Dpublic boolean contains(Point2D p)
contains in interface Shape2Dpublic boolean isBounded()
isBounded in interface Shape2Dpublic boolean isEmpty()
isEmpty in interface Shape2Dpublic GeneralPath getGeneralPath()
public GeneralPath appendPath(GeneralPath path)
ContinuousCurve2D
appendPath in interface ContinuousCurve2Dpath - a path to modify
public String toString()
toString in class Objectpublic boolean equals(Object obj)
equals in class Objectobj - the edge to compare to.
public Line2D clone()
Curve2D
clone in interface Curve2Dclone in class AbstractSmoothCurve2D
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||