Class AbstractLine2D
- java.lang.Object
-
- math.geom2d.curve.AbstractContinuousCurve2D
-
- math.geom2d.curve.AbstractSmoothCurve2D
-
- math.geom2d.line.AbstractLine2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, CirculinearContinuousCurve2D, CirculinearCurve2D, CirculinearElement2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, SmoothCurve2D, ContinuousOrientedCurve2D, OrientedCurve2D, SmoothOrientedCurve2D, GeometricObject2D, LinearElement2D, LinearShape2D, Shape2D
- Direct Known Subclasses:
- InvertedRay2D, LineArc2D, LineSegment2D, Ray2D, StraightLine2D
public abstract class AbstractLine2D extends AbstractSmoothCurve2D implements SmoothOrientedCurve2D, LinearElement2D
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description CirculinearDomain2Dbuffer(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()Returns the coefficient of the Cartesian representation of the line.CurveSet2D<? extends AbstractLine2D>clip(Box2D box)When a curve is clipped, the result is a set of curves.abstract AbstractLine2Dclone()Deprecated.use copy constructor instead (0.11.2)booleancontains(Point2D p)Checks if the shape contains the given point.java.util.Collection<? extends AbstractLine2D>continuousCurves()Returns a collection of lines containing only this line.doublecurvature(double t)Returns 0 as for every straight object.Vector2Ddirection()Returns the direction vector of this linear shape.doubledistance(double x, double y)Returns the distance of the StraightObject2d to the given point.doubledistance(Point2D p)Returns the distance of the StraightObject2d to the given point.static Point2DgetIntersection(AbstractLine2D line1, AbstractLine2D line2)Returns the unique intersection of two straight objects.Point2DgetSymmetric(double x, double y)Return the symmetric of point with coordinate (x, y) relative to this straight line.Point2DgetSymmetric(Point2D p)Return the symmetric of point p relative to this straight line.doublehorizontalAngle()Gets Angle with axis (O,i), counted counter-clockwise.Point2Dintersection(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.booleanisClosed()Always returns false, because we can not come back to starting point if we always go straight...static booleanisColinear(AbstractLine2D line1, AbstractLine2D line2)Tests if the two linear objects are located on the same straight line.booleanisColinear(LinearShape2D linear)Tests if the given linear shape is parallel to this shape.booleanisEmpty()Returns false, unless both dx and dy equal 0.booleanisInside(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 booleanisParallel(AbstractLine2D line1, AbstractLine2D line2)Tests if the two linear objects are parallel.booleanisParallel(LinearShape2D line)Tests if the this object is parallel to the given one.doublelength()doublelength(double pos)Point2Dorigin()Returns the origin point of this linear shape.StraightLine2Dparallel(Point2D point)Creates a straight line parallel to this object, and going through the given point.double[][]parametric()Returns the matrix of parametric representation of the line.StraightLine2Dperpendicular(Point2D point)Creates a straight line perpendicular to this object, and going through the given point.double[]polarCoefficients()Returns polar coefficients of this linear shape.double[]polarCoefficientsSigned()Returns the signed polar coefficients.doubleposition(double distance)doubleposition(Point2D point)Returns the position of the point on the line arc.doublepositionOnLine(double x, double y)Computes position on the line of the point given by (x,y).doublepositionOnLine(Point2D point)doubleproject(Point2D point)Returns the position of the closest point on the line arc.Point2DprojectedPoint(double x, double y)Returns the projection of point p on the line.Point2DprojectedPoint(Point2D p)Returns the projection of point p on the line.doublesignedDistance(double x, double y)Returns the signed distance of the StraightObject2d to the given point.doublesignedDistance(Point2D p)Returns the signed distance of the StraightObject2d to the given point.java.util.Collection<? extends AbstractLine2D>smoothPieces()Returns a collection of lines containing only this line.AbstractLine2DsubCurve(double t0, double t1)Returns a new AbstractLine2D, which is the portion of this AbstractLine2D delimited by parameters t0 and t1.StraightLine2DsupportingLine()Returns the straight line that contains this linear shape.Vector2Dtangent(double t)Returns the tangent of the curve at the given position.abstract AbstractLine2Dtransform(AffineTransform2D transform)Transforms the curve by an affine transform.CirculinearElement2Dtransform(CircleInversion2D inv)Transforms the shape by a circle inversion.doublewindingAngle(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, firstPoint, lastPoint
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface math.geom2d.circulinear.CirculinearElement2D
parallel
-
Methods inherited from interface math.geom2d.curve.SmoothCurve2D
normal
-
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
appendPath, asPolyline, leftTangent, rightTangent
-
Methods inherited from interface math.geom2d.curve.Curve2D
asAwtShape, draw, firstPoint, getT0, getT1, isSingular, lastPoint, point, singularPoints, t0, t1, vertices
-
Methods inherited from interface math.geom2d.Shape2D
boundingBox, contains, isBounded
-
Methods inherited from interface math.geom2d.GeometricObject2D
almostEquals
-
-
-
-
Method Detail
-
getIntersection
public static Point2D getIntersection(AbstractLine2D line1, AbstractLine2D line2)
Returns the unique intersection of two straight objects. If the intersection doesn't exist (parallel lines, short edge), return null.
-
isColinear
public static boolean isColinear(AbstractLine2D line1, AbstractLine2D line2)
Tests if the two linear objects are located on the same straight line.
-
isParallel
public static boolean isParallel(AbstractLine2D line1, AbstractLine2D line2)
Tests if the two linear objects are parallel.
-
isColinear
public boolean isColinear(LinearShape2D linear)
Tests if the given linear shape is parallel to this shape.
-
isParallel
public boolean isParallel(LinearShape2D line)
Tests if the this object is parallel to the given one.
-
parametric
public double[][] parametric()
Returns the matrix of parametric representation of the line. Result has the form:[ x0 dx ]
[ y0 dy ]
It can be easily extended to higher dimensions and/or higher polynomial forms.
-
cartesianEquation
public double[] cartesianEquation()
Returns the coefficient of the Cartesian representation of the line. Cartesian equation has the form:ax+by+c=0- Returns:
- the array {a, b, c}.
-
polarCoefficients
public double[] polarCoefficients()
Returns polar coefficients of this linear shape.- Returns:
- an array of 2 elements, the first one is the distance to the origin, the second one is the angle with horizontal, between 0 and 2*PI.
-
polarCoefficientsSigned
public double[] polarCoefficientsSigned()
Returns the signed polar coefficients. Distance to origin can be negative: this allows representation of directed lines.- Returns:
- an array of 2 elements, the first one is the signed distance to the origin, the second one is the angle with horizontal, between 0 and 2*PI.
-
positionOnLine
public double positionOnLine(Point2D point)
-
positionOnLine
public double positionOnLine(double x, double y)Computes position on the line of the point given by (x,y). The position 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.If the point does not belong to the line, the method returns the position of its projection on the line.
-
projectedPoint
public Point2D projectedPoint(Point2D p)
Returns the projection of point p on the line. The returned point can be used to compute distance from point to line.- Parameters:
p- a point outside the line (if point p lies on the line, it is returned)- Returns:
- the projection of the point p on the line
-
projectedPoint
public Point2D projectedPoint(double x, double y)
Returns the projection of point p on the line. The returned point can be used to compute distance from point to line.- Parameters:
x- coordinate x of point to be projectedy- coordinate y of point to be projected- Returns:
- the projection of the point p on the line
-
getSymmetric
public Point2D getSymmetric(Point2D p)
Return the symmetric of point p relative to this straight line.- Parameters:
p- a point outside the line (if point p lies on the line, it is returned)- Returns:
- the projection of the point p on the line
-
getSymmetric
public Point2D getSymmetric(double x, double y)
Return the symmetric of point with coordinate (x, y) relative to this straight line.- Parameters:
x- x-coordinate of point to be projectedy- y-coordinate of point to be projected- Returns:
- the projection of the point (x,y) on the line
-
parallel
public StraightLine2D parallel(Point2D point)
Creates a straight line parallel to this object, and going through the given point.- Parameters:
point- the point to go through- Returns:
- the parallel through the point
-
perpendicular
public StraightLine2D perpendicular(Point2D point)
Creates a straight line perpendicular to this object, and going through the given point.- Parameters:
point- the point to go through- Returns:
- the perpendicular through the point
-
origin
public Point2D origin()
Returns the origin point of this linear shape.- Specified by:
originin interfaceLinearShape2D- Returns:
- a point in the linear shape.
-
direction
public Vector2D direction()
Returns the direction vector of this linear shape.- Specified by:
directionin interfaceLinearShape2D- Returns:
- a direction vector
-
horizontalAngle
public double horizontalAngle()
Gets Angle with axis (O,i), counted counter-clockwise. Result is given between 0 and 2*pi.- Specified by:
horizontalAnglein interfaceLinearShape2D
-
intersection
public Point2D intersection(LinearShape2D line)
Returns the unique intersection with a linear shape. If the intersection doesn't exist (parallel lines, short edges), return null.- Specified by:
intersectionin interfaceLinearShape2D
-
supportingLine
public StraightLine2D supportingLine()
Description copied from interface:LinearShape2DReturns the straight line that contains this linear shape. The direction is the same, and if possible the direction vector should be the same.- Specified by:
supportingLinein interfaceLinearShape2D- Returns:
- the straight line that contains this linear shape
-
length
public double length()
- Specified by:
lengthin interfaceCirculinearCurve2D- Returns:
- the length of the curve
-
length
public double length(double pos)
- Specified by:
lengthin interfaceCirculinearCurve2D- Returns:
- the length from the beginning to the position given by pos
-
position
public double position(double distance)
- Specified by:
positionin interfaceCirculinearCurve2D- Returns:
- the position located at a given geodesic distance from the origin
-
transform
public CirculinearElement2D transform(CircleInversion2D inv)
Description copied from interface:CirculinearShape2DTransforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.- Specified by:
transformin interfaceCirculinearContinuousCurve2D- Specified by:
transformin interfaceCirculinearCurve2D- Specified by:
transformin interfaceCirculinearElement2D- Specified by:
transformin interfaceCirculinearShape2D- Parameters:
inv- the circle inversion- Returns:
- the transformed shape
-
buffer
public CirculinearDomain2D buffer(double dist)
Description copied from interface:CirculinearShape2DComputes 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.- Specified by:
bufferin interfaceCirculinearShape2D- Parameters:
dist- the maximal distance between a point of the buffer and the shape- Returns:
- the buffer of the shape
-
windingAngle
public double windingAngle(Point2D point)
Description copied from interface:OrientedCurve2DReturn the angle portion that the curve turn around the given point. Result is a signed angle.- Specified by:
windingAnglein interfaceOrientedCurve2D- Parameters:
point- a point of the plane- Returns:
- a signed angle
-
signedDistance
public double signedDistance(Point2D p)
Returns the signed distance of the StraightObject2d to the given point. The signed distance is positive if point lies 'to the right' of the line, when moving in the direction given by direction vector. 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:
signedDistancein interfaceOrientedCurve2D- Parameters:
p- a point of the plane- Returns:
- the signed distance to the curve
-
signedDistance
public double signedDistance(double x, double y)Returns the signed distance of the StraightObject2d to the given point. The signed distance is positive if point lies 'to the right' of the line, when moving in the direction given by direction vector. 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:
signedDistancein interfaceOrientedCurve2D- Parameters:
x- x-coord of a pointy- y-coord of a point- Returns:
- the signed distance of the point (x,y) to the curve
-
isInside
public 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.- Specified by:
isInsidein interfaceOrientedCurve2D- Parameters:
p- the point to test- Returns:
- true if point p lies on the 'left' of the line.
-
tangent
public Vector2D tangent(double t)
Description copied from interface:SmoothCurve2DReturns the tangent of the curve at the given position.- Specified by:
tangentin interfaceSmoothCurve2D- Parameters:
t- a position on the curve- Returns:
- the tangent vector computed for position t
- See Also:
SmoothCurve2D.normal(double)
-
curvature
public double curvature(double t)
Returns 0 as for every straight object.- Specified by:
curvaturein interfaceContinuousCurve2D- Parameters:
t- the position on the curve- Returns:
- the curvature of the curve for position t
-
isClosed
public boolean isClosed()
Always returns false, because we can not come back to starting point if we always go straight...- Specified by:
isClosedin interfaceContinuousCurve2D
-
smoothPieces
public java.util.Collection<? extends AbstractLine2D> smoothPieces()
Returns a collection of lines containing only this line.- Specified by:
smoothPiecesin interfaceCirculinearContinuousCurve2D- Specified by:
smoothPiecesin interfaceContinuousCurve2D- Overrides:
smoothPiecesin classAbstractSmoothCurve2D
-
intersections
public java.util.Collection<Point2D> intersections(LinearShape2D line)
Returns the intersection points of the curve with the specified line. The length of the result array is the number of intersection points.- Specified by:
intersectionsin interfaceCurve2D
-
position
public double position(Point2D point)
Returns the position of the point on the line arc. If the 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 line, returns Double.NaN.
- Specified by:
positionin interfaceCurve2D- Parameters:
point- a point belonging to the curve- Returns:
- the position of the point on the curve
- See Also:
Curve2D.point(double)
-
project
public double project(Point2D point)
Returns the position of the closest point on the line arc. If the 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 line, returns t0, or t1, depending on which one is the closest.
-
subCurve
public AbstractLine2D subCurve(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:
subCurvein interfaceCirculinearContinuousCurve2D- Specified by:
subCurvein interfaceCirculinearCurve2D- Specified by:
subCurvein interfaceCirculinearElement2D- Specified by:
subCurvein interfaceContinuousCurve2D- Specified by:
subCurvein interfaceCurve2D- Specified by:
subCurvein interfaceSmoothCurve2D- Specified by:
subCurvein interfaceContinuousOrientedCurve2D- Specified by:
subCurvein interfaceSmoothOrientedCurve2D- Specified by:
subCurvein interfaceLinearElement2D- 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.
-
continuousCurves
public java.util.Collection<? extends AbstractLine2D> continuousCurves()
Returns a collection of lines containing only this line.- Specified by:
continuousCurvesin interfaceCirculinearCurve2D- Specified by:
continuousCurvesin interfaceCurve2D- Overrides:
continuousCurvesin classAbstractContinuousCurve2D- Returns:
- a collection of continuous curves.
-
distance
public double distance(Point2D p)
Returns 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.
-
distance
public double distance(double x, double y)Returns 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.
-
contains
public boolean contains(Point2D p)
Description copied from interface:Shape2DChecks 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:Curve2DTransforms the curve by an affine transform. The result is an instance of Curve2D.- Specified by:
transformin interfaceContinuousCurve2D- Specified by:
transformin interfaceCurve2D- Specified by:
transformin interfaceSmoothCurve2D- Specified by:
transformin interfaceContinuousOrientedCurve2D- Specified by:
transformin interfaceOrientedCurve2D- Specified by:
transformin interfaceSmoothOrientedCurve2D- Specified by:
transformin interfaceLinearElement2D- Specified by:
transformin interfaceLinearShape2D- Specified by:
transformin interfaceShape2D- Parameters:
transform- an affine transform- Returns:
- the transformed shape
-
clip
public CurveSet2D<? extends AbstractLine2D> clip(Box2D box)
Description copied from interface:Curve2DWhen a curve is clipped, the result is a set of curves.- Specified by:
clipin interfaceCirculinearContinuousCurve2D- Specified by:
clipin interfaceCirculinearCurve2D- Specified by:
clipin interfaceCirculinearElement2D- Specified by:
clipin interfaceContinuousCurve2D- Specified by:
clipin interfaceCurve2D- Specified by:
clipin interfaceSmoothCurve2D- Specified by:
clipin interfaceContinuousOrientedCurve2D- Specified by:
clipin interfaceOrientedCurve2D- Specified by:
clipin interfaceSmoothOrientedCurve2D- Specified by:
clipin interfaceLinearElement2D- Specified by:
clipin interfaceShape2D- Parameters:
box- the clipping box- Returns:
- the clipped shape
-
clone
@Deprecated public abstract AbstractLine2D clone()
Deprecated. use copy constructor instead (0.11.2)- Specified by:
clonein interfaceCurve2D- Specified by:
clonein classAbstractSmoothCurve2D
-
-
DMelt 3.0 © DataMelt by jWork.ORG