public abstract class AbstractLine2D extends AbstractSmoothCurve2D implements SmoothOrientedCurve2D, LinearShape2D, CirculinearElement2D
Base class for straight curves, such as straight lines, rays, or edges.
Internal representation of straight objects is parametric: (x0, y0) is a point in the object, and (dx, dy) is a direction vector of the line.
If the line is defined by two point, we can set (x0,y0) to the first point, and (dx,dy) to the vector (p1, p2).
Then, coordinates for a point (x,y) such as x=x0+t*dx and y=y0+t=dy, t between 0 and 1 give a point inside p1 and p2, t<0 give a point 'before' p1, and t>1 give a point 'after' p2, so it is convenient to easily manage edges, rays and straight lines.
| Modifier and Type | Field and Description |
|---|---|
protected double |
dx
Direction vector of the line.
|
protected double |
dy
Direction vector of the line.
|
protected double |
x0
Coordinates of starting point of the line
|
protected double |
y0
Coordinates of starting point of the line
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLine2D(double x0,
double y0,
double dx,
double dy) |
protected |
AbstractLine2D(LinearShape2D line) |
protected |
AbstractLine2D(Point2D point,
Vector2D vector) |
| Modifier and Type | Method and Description |
|---|---|
CurveSet2D<? extends AbstractLine2D> |
clip(Box2D box)
When a curve is clipped, the result is a set of curves.
|
abstract AbstractLine2D |
clone()
Ensures public declaration of clone(), and ensures valid return type.
|
boolean |
contains(Point2D p)
Checks if the shape contains the given point.
|
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()
Returns the coefficient of the Cartesian representation of the line.
|
Collection<? extends AbstractLine2D> |
getContinuousCurves()
Returns the collection of continuous curves which constitute this curve.
|
double |
getCurvature(double t)
returns 0 as every straight object.
|
double |
getDistance(double x,
double y)
Gets the distance of the StraightObject2d to the given point.
|
double |
getDistance(Point2D p)
Gets the distance of the StraightObject2d to the given point.
|
double |
getHorizontalAngle()
Gets Angle with axis (O,i), counted counter-clockwise.
|
static Point2D |
getIntersection(AbstractLine2D l1,
AbstractLine2D l2)
Returns the unique intersection of two straight objects.
|
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.
|
double |
getLength() |
double |
getLength(double pos) |
Point2D |
getOrigin()
Returns a point in the linear shape.
|
StraightLine2D |
getParallel(Point2D point)
Create a straight line parallel to this object, and going through the
given point.
|
double[][] |
getParametric()
Returns the matrix of parametric representation of the line.
|
StraightLine2D |
getPerpendicular(Point2D point)
Create a straight line perpendicular to this object, and going through
the given point.
|
double[] |
getPolarCoefficients()
Returns polar coefficients.
|
double |
getPosition(double length) |
double |
getPosition(Point2D point)
Gets the position of the point on the line arc.
|
double |
getPositionOnLine(double x,
double y)
Compute position on the line, that is the number t such that if the point
belong to the line, it location is given by x=x0+t*dx and y=y0+t*dy.
|
double |
getPositionOnLine(Point2D point) |
Point2D |
getProjectedPoint(double x,
double y)
Return the projection of point p on the line.
|
Point2D |
getProjectedPoint(Point2D p)
Return the projection of point p on the line.
|
double |
getSignedDistance(double x,
double y)
Get the signed distance of the StraightObject2d to the given point.
|
double |
getSignedDistance(Point2D p)
Get the signed distance of the StraightObject2d to the given point.
|
double[] |
getSignedPolarCoefficients()
Returns the signed polar coefficients.
|
Collection<? extends AbstractLine2D> |
getSmoothPieces()
Return the intersection points of the curve with the specified line.
|
AbstractLine2D |
getSubCurve(double t0,
double t1)
Returns a new AbstractLine2D, which is the portion of this AbstractLine2D
delimited by parameters t0 and t1.
|
StraightLine2D |
getSupportingLine() |
Point2D |
getSymmetric(double x,
double y)
Return the symmetric of point with coordinate (x, y) relative to this
straight line.
|
Point2D |
getSymmetric(Point2D p)
Return the symmetric of point p relative to this straight line.
|
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.
|
boolean |
isClosed()
Always returns false, because we can not come back to starting point if
we always go straight...
|
static boolean |
isColinear(AbstractLine2D line1,
AbstractLine2D line2)
Test if the two linear objects are located on the same straight line.
|
boolean |
isColinear(LinearShape2D linear) |
boolean |
isEmpty()
Returns false, unless both dx and dy equal 0.
|
boolean |
isInside(Point2D p)
Returns true if the given point lies to the left of the line when
traveling along the line in the direction given by its direction vector.
|
static boolean |
isParallel(AbstractLine2D line1,
AbstractLine2D line2)
Test if the two linear objects are parallel.
|
boolean |
isParallel(LinearShape2D line)
Test if the this object is parallel to the given one.
|
double |
project(Point2D point)
Gets the position of the closest point on the line arc.
|
protected boolean |
supportContains(double x,
double y)
Returns true if the point (x, y) lies on the line covering the object,
with precision given by Shape2D.ACCURACY.
|
abstract AbstractLine2D |
transform(AffineTransform2D transform)
Transforms the curve by an affine transform.
|
CirculinearElement2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion.
|
getLeftTangent, getRightTangent, getSingularPoints, isSingulardraw, getAsAWTShape, getAsPolyline, getFirstPoint, getLastPoint, wrapCurveequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParallel, getReverseCurveappendPath, getAsPolyline, getLeftTangent, getRightTangentdraw, getAsAWTShape, getFirstPoint, getLastPoint, getPoint, getSingularPoints, getT0, getT1, isSingularcontains, getBoundingBox, isBoundedprotected double x0
protected double y0
protected double dx
protected double dy
protected AbstractLine2D(double x0,
double y0,
double dx,
double dy)
protected AbstractLine2D(LinearShape2D line)
public static final Point2D getIntersection(AbstractLine2D l1, AbstractLine2D l2)
public static final boolean isColinear(AbstractLine2D line1, AbstractLine2D line2)
public static final boolean isParallel(AbstractLine2D line1, AbstractLine2D line2)
public boolean isColinear(LinearShape2D linear)
public boolean isParallel(LinearShape2D line)
protected boolean supportContains(double x,
double y)
public double[][] getParametric()
[ x0 dx ]
[ y0 dy ]
It can be easily extended to higher dimensions and/or higher polynomial forms.
public double[] getCartesianEquation()
ax+by+c=0public double[] getPolarCoefficients()
public double[] getSignedPolarCoefficients()
public double getPositionOnLine(Point2D point)
public double getPositionOnLine(double x,
double y)
If the point does not belong to the line, the method returns the position of its projection on the line.
public Point2D getProjectedPoint(Point2D p)
p - a point outside the line (if point p lies on the line, it is
returned)public Point2D getProjectedPoint(double x, double y)
x - : coordinate x of point to be projectedy - : coordinate y of point to be projectedpublic Point2D getSymmetric(Point2D p)
p - a point outside the line (if point p lies on the line, it is
returned)public Point2D getSymmetric(double x, double y)
x - : coordinate x of point to be projectedy - : coordinate y of point to be projectedpublic StraightLine2D getParallel(Point2D point)
point - the point to go throughpublic StraightLine2D getPerpendicular(Point2D point)
point - the point to go throughpublic Point2D getOrigin()
LinearShape2DgetOrigin in interface LinearShape2Dpublic Vector2D getVector()
LinearShape2DgetVector in interface LinearShape2Dpublic double getHorizontalAngle()
getHorizontalAngle in interface LinearShape2Dpublic Point2D getIntersection(LinearShape2D line)
getIntersection in interface LinearShape2Dpublic StraightLine2D getSupportingLine()
getSupportingLine in interface LinearShape2Dpublic CirculinearDomain2D getBuffer(double dist)
CirculinearShape2DgetBuffer in interface CirculinearShape2Ddist - the maximal distance between a point of the buffer and the
shapepublic 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)
CirculinearShape2Dtransform in interface CirculinearContinuousCurve2Dtransform in interface CirculinearCurve2Dtransform in interface CirculinearElement2Dtransform in interface CirculinearShape2Dtransform in interface ContinuousCirculinearCurve2Dinv - the circle inversionpublic double getWindingAngle(Point2D point)
OrientedCurve2DgetWindingAngle in interface OrientedCurve2Dpoint - a point of the planepublic double getSignedDistance(Point2D p)
getSignedDistance in interface OrientedCurve2Dp - a point of the planepublic double getSignedDistance(double x,
double y)
getSignedDistance in interface OrientedCurve2Dx - x-coord of a pointy - y-coord of a pointpublic boolean isInside(Point2D p)
isInside in interface OrientedCurve2Dp - the point to testpublic Vector2D getTangent(double t)
getTangent in interface SmoothCurve2Dpublic double getCurvature(double t)
getCurvature in interface SmoothCurve2Dpublic boolean isClosed()
isClosed in interface ContinuousCurve2Dpublic Collection<? extends AbstractLine2D> getSmoothPieces()
getSmoothPieces in interface CirculinearContinuousCurve2DgetSmoothPieces in interface ContinuousCirculinearCurve2DgetSmoothPieces in interface ContinuousCurve2DgetSmoothPieces in class AbstractSmoothCurve2Dpublic Collection<Point2D> getIntersections(LinearShape2D line)
Curve2DgetIntersections in interface Curve2Dpublic double getPosition(Point2D point)
If point does not belong to edge, returns Double.NaN. t = (xp - x0)/dx <\code>, or equivalently: t = (yp - y0)/dy <\code>.
getPosition in interface Curve2Dpoint - a point belonging to the curvepublic double project(Point2D point)
If point does not belong to edge, returns t0, or t1, depending on which
one is the closest. t = (xp - x0)/dx <\code>, or equivalently: t = (yp - y0)/dy <\code>.
public AbstractLine2D 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-curvepublic Collection<? extends AbstractLine2D> getContinuousCurves()
Curve2DgetContinuousCurves in interface CirculinearCurve2DgetContinuousCurves in interface Curve2DgetContinuousCurves in class AbstractContinuousCurve2Dpublic double getDistance(Point2D p)
getDistance in interface Shape2Dpublic double getDistance(double x,
double y)
getDistance in interface Shape2Dx - x-coordinate of the pointy - y-coordinate of the pointpublic boolean contains(Point2D p)
Shape2Dpublic boolean isEmpty()
public abstract AbstractLine2D transform(AffineTransform2D transform)
Curve2Dtransform in interface ContinuousCurve2Dtransform in interface Curve2Dtransform in interface SmoothCurve2Dtransform in interface ContinuousOrientedCurve2Dtransform in interface OrientedCurve2Dtransform in interface SmoothOrientedCurve2Dtransform in interface LinearShape2Dtransform in interface Shape2Dtransform - an affine transformpublic CurveSet2D<? extends AbstractLine2D> clip(Box2D box)
Curve2Dclip 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 boxpublic abstract AbstractLine2D clone()
clone in interface Curve2Dclone in class AbstractSmoothCurve2DCopyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.