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, isSingular
draw, getAsAWTShape, getAsPolyline, getFirstPoint, getLastPoint, wrapCurve
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParallel, getReverseCurve
appendPath, getAsPolyline, getLeftTangent, getRightTangent
draw, getAsAWTShape, getFirstPoint, getLastPoint, getPoint, getSingularPoints, getT0, getT1, isSingular
contains, getBoundingBox, isBounded
protected 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=0
public 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()
LinearShape2D
getOrigin
in interface LinearShape2D
public Vector2D getVector()
LinearShape2D
getVector
in interface LinearShape2D
public double getHorizontalAngle()
getHorizontalAngle
in interface LinearShape2D
public Point2D getIntersection(LinearShape2D line)
getIntersection
in interface LinearShape2D
public StraightLine2D getSupportingLine()
getSupportingLine
in interface LinearShape2D
public CirculinearDomain2D getBuffer(double dist)
CirculinearShape2D
getBuffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shapepublic 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 inversionpublic double getWindingAngle(Point2D point)
OrientedCurve2D
getWindingAngle
in interface OrientedCurve2D
point
- a point of the planepublic double getSignedDistance(Point2D p)
getSignedDistance
in interface OrientedCurve2D
p
- a point of the planepublic double getSignedDistance(double x, double y)
getSignedDistance
in interface OrientedCurve2D
x
- x-coord of a pointy
- y-coord of a pointpublic boolean isInside(Point2D p)
isInside
in interface OrientedCurve2D
p
- the point to testpublic Vector2D getTangent(double t)
getTangent
in interface SmoothCurve2D
public double getCurvature(double t)
getCurvature
in interface SmoothCurve2D
public boolean isClosed()
isClosed
in interface ContinuousCurve2D
public Collection<? extends AbstractLine2D> getSmoothPieces()
getSmoothPieces
in interface CirculinearContinuousCurve2D
getSmoothPieces
in interface ContinuousCirculinearCurve2D
getSmoothPieces
in interface ContinuousCurve2D
getSmoothPieces
in class AbstractSmoothCurve2D
public Collection<Point2D> getIntersections(LinearShape2D line)
Curve2D
getIntersections
in interface Curve2D
public double getPosition(Point2D point)
t = (xp - x0)/dx <\code>, or equivalently:
t = (yp - y0)/dy <\code>.
If point does not belong to edge, returns Double.NaN.
- Specified by:
getPosition
in interface Curve2D
- Parameters:
point
- a point belonging to the curve
- Returns:
- the position of the point on the curve
-
project
public double project(Point2D point)
Gets the position of the closest point on the line arc. If point belongs
to the line, this position is defined by the ratio:
t = (xp - x0)/dx <\code>, or equivalently:
t = (yp - y0)/dy <\code>.
If point does not belong to edge, returns t0, or t1, depending on which
one is the closest.
-
getSubCurve
public AbstractLine2D getSubCurve(double t0,
double t1)
Returns a new AbstractLine2D, which is the portion of this AbstractLine2D
delimited by parameters t0 and t1. Casts the result to StraightLine2D,
Ray2D or LineSegment2D when appropriate.
- Specified by:
getSubCurve
in interface CirculinearContinuousCurve2D
- Specified by:
getSubCurve
in interface CirculinearCurve2D
- Specified by:
getSubCurve
in interface CirculinearElement2D
- Specified by:
getSubCurve
in interface ContinuousCirculinearCurve2D
- Specified by:
getSubCurve
in interface ContinuousCurve2D
- Specified by:
getSubCurve
in interface Curve2D
- Specified by:
getSubCurve
in interface SmoothCurve2D
- Specified by:
getSubCurve
in interface ContinuousOrientedCurve2D
- Specified by:
getSubCurve
in interface SmoothOrientedCurve2D
- Parameters:
t0
- position of the start of the sub-curvet1
- position of the end of the sub-curve
- Returns:
- the portion of original curve comprised between t0 and t1.
-
getContinuousCurves
public Collection<? extends AbstractLine2D> getContinuousCurves()
Description copied from interface: Curve2D
Returns the collection of continuous curves which constitute this curve.
- Specified by:
getContinuousCurves
in interface CirculinearCurve2D
- Specified by:
getContinuousCurves
in interface Curve2D
- Overrides:
getContinuousCurves
in class AbstractContinuousCurve2D
- Returns:
- a collection of continuous curves.
-
getDistance
public double getDistance(Point2D p)
Gets the distance of the StraightObject2d to the given point. This method
is not designed to be used directly, because AbstractLine2D is an
abstract class, but it can be called by subclasses to help computations.
- Specified by:
getDistance
in interface Shape2D
-
getDistance
public double getDistance(double x,
double y)
Gets the distance of the StraightObject2d to the given point. This method
is not designed to be used directly, because AbstractLine2D is an
abstract class, but it can be used by subclasses to help computations.
- Specified by:
getDistance
in interface Shape2D
- Parameters:
x
- x-coordinate of the pointy
- y-coordinate of the point
- Returns:
- distance between this object and the point (x,y)
-
contains
public boolean contains(Point2D p)
Description copied from interface: Shape2D
Checks if the shape contains the given point.
-
isEmpty
public boolean isEmpty()
Returns false, unless both dx and dy equal 0.
-
transform
public abstract AbstractLine2D transform(AffineTransform2D transform)
Description copied from interface: Curve2D
Transforms the curve by an affine transform. The result is an instance of
Curve2D.
- Specified by:
transform
in interface ContinuousCurve2D
- Specified by:
transform
in interface Curve2D
- Specified by:
transform
in interface SmoothCurve2D
- Specified by:
transform
in interface ContinuousOrientedCurve2D
- Specified by:
transform
in interface OrientedCurve2D
- Specified by:
transform
in interface SmoothOrientedCurve2D
- Specified by:
transform
in interface LinearShape2D
- Specified by:
transform
in interface Shape2D
- Parameters:
transform
- an affine transform
- Returns:
- the transformed shape
-
clip
public CurveSet2D<? extends AbstractLine2D> clip(Box2D box)
Description copied from interface: Curve2D
When a curve is clipped, the result is a set of curves.
- Specified by:
clip
in interface CirculinearContinuousCurve2D
- Specified by:
clip
in interface CirculinearCurve2D
- Specified by:
clip
in interface CirculinearElement2D
- Specified by:
clip
in interface ContinuousCirculinearCurve2D
- Specified by:
clip
in interface ContinuousCurve2D
- Specified by:
clip
in interface Curve2D
- Specified by:
clip
in interface SmoothCurve2D
- Specified by:
clip
in interface ContinuousOrientedCurve2D
- Specified by:
clip
in interface OrientedCurve2D
- Specified by:
clip
in interface SmoothOrientedCurve2D
- Specified by:
clip
in interface Shape2D
- Parameters:
box
- the clipping box
- Returns:
- the clipped shape
-
clone
public abstract AbstractLine2D clone()
Ensures public declaration of clone(), and ensures valid return type.
- Specified by:
clone
in interface Curve2D
- Specified by:
clone
in class AbstractSmoothCurve2D
- Returns:
- the cloned curve
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.