math.geom2d.line
Class StraightLine2D
- java.lang.Object
-
- math.geom2d.curve.AbstractContinuousCurve2D
-
- math.geom2d.curve.AbstractSmoothCurve2D
-
- math.geom2d.line.AbstractLine2D
-
- math.geom2d.line.StraightLine2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, CircleLine2D, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearElement2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, SmoothCurve2D, Boundary2D, ContinuousOrientedCurve2D, Contour2D, OrientedCurve2D, SmoothContour2D, SmoothOrientedCurve2D, GeometricObject2D, LinearElement2D, LinearShape2D, Shape2D
public class StraightLine2D extends AbstractLine2D implements SmoothContour2D, java.lang.Cloneable, CircleLine2D
Implementation of a straight line. Such a line can be constructed using two points, a point and a parallel line or straight object, or with coefficient of the Cartesian equation.
-
-
Constructor Summary
Constructors Constructor and Description StraightLine2D()Empty constructor: a straight line corresponding to horizontal axis.StraightLine2D(double a, double b, double c)Defines a new straight line, from the coefficients of the cartesian equation.StraightLine2D(double xp, double yp, double dx, double dy)StraightLine2D(LinearShape2D line)Copy constructor: Defines a new Straight line at the same position and with the same direction than an other straight object (line, edge or ray).StraightLine2D(LinearShape2D line, Point2D point)Defines a new Straight line, parallel to another straigth object (ray, straight line or edge), and going through the given point.StraightLine2D(Point2D point, double angle)Defines a new Straight line going through the given point, and with the specified direction given by angle.StraightLine2D(Point2D point, double dx, double dy)Defines a new Straight line going through the given point, and with the specified direction vector.StraightLine2D(Point2D point1, Point2D point2)Defines a new Straight line going through the two given points.StraightLine2D(Point2D point, Vector2D direction)Defines a new Straight line going through the given point, and with the specified direction vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanalmostEquals(GeometricObject2D obj, double eps)Checks if the two objects are similar up to a given threshold value.java.awt.geom.GeneralPathappendPath(java.awt.geom.GeneralPath path)Append the path of the curve to the given path.Polyline2DasPolyline(int n)Throws an exception when called.Box2DboundingBox()Returns the bounding box of the shape.StraightLine2Dclone()Deprecated.use copy constructor instead (0.11.2)booleancontains(double x, double y)Returns true if the point (x, y) lies on the line, with precision given by Shape2D.ACCURACY.booleancontains(Point2D p)Returns true if the point p lies on the line, with precision given by Shape2D.ACCURACY.java.util.Collection<? extends StraightLine2D>continuousCurves()Need to override to cast the type.static StraightLine2Dcreate(Point2D point, double angle)Deprecated.since 0.11.1static StraightLine2Dcreate(Point2D p1, Point2D p2)Deprecated.since 0.11.1static StraightLine2Dcreate(Point2D origin, Vector2D direction)Deprecated.since 0.11.1static StraightLine2DcreateCartesian(double a, double b, double c)Returns a new Straight line, with the given coefficient of the cartesian equation (a*x + b*y + c = 0).static StraightLine2DcreateHorizontal(Point2D origin)Creates a vertical straight line through the given point.static StraightLine2DcreateMedian(Point2D p1, Point2D p2)Creates a median between 2 points.static StraightLine2DcreateParallel(LinearShape2D linear, double d)Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.static StraightLine2DcreateParallel(LinearShape2D line, Point2D point)Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.static StraightLine2DcreatePerpendicular(LinearShape2D linear, Point2D point)Returns a new Straight line, perpendicular to a straight object (ray, straight line or edge), and going through the given point.static StraightLine2DcreateVertical(Point2D origin)Creates a vertical straight line through the given point.doubledistance(double x, double y)Returns the distance of the point (x, y) to this straight line.CirculinearDomain2Ddomain()Returns the domain delimited by this boundary.booleanequals(java.lang.Object obj)voidfill(java.awt.Graphics2D g2)Fills the interior of the boundary, using the Graphics current Paint.Point2DfirstPoint()Throws an infiniteShapeExceptionjava.awt.geom.GeneralPathgetGeneralPath()Throws an infiniteShapeExceptionstatic Point2DgetIntersection(Point2D p1, Point2D p2, Point2D p3, Point2D p4)Computes the intersection point of the two (infinite) lines going through p1 and p2 for the first one, and p3 and p4 for the second one.doublegetT0()Deprecated.replaced by t0() (since 0.11.1).doublegetT1()Deprecated.replaced by t1() (since 0.11.1).booleanisBounded()Always returns false, because a line is not bounded.booleanisSingular(double pos)Returns false, whatever the position.Point2DlastPoint()Throws an infiniteShapeExceptionStraightLine2Dparallel(double d)Returns the parallel line located at a distance d from the line.StraightLine2Dparallel(Point2D point)Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.StraightLine2Dperpendicular(Point2D point)Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.Point2Dpoint(double t)Returns the point specified with the parametric representation of the line.StraightLine2Dreverse()Returns the straight line with same origin but with opposite direction vector.java.util.Collection<Point2D>singularPoints()Returns an empty list of points.doublet0()Returns the parameter of the first point of the line, which is always Double.NEGATIVE_INFINITY.doublet1()Returns the parameter of the last point of the line, which is always Double.POSITIVE_INFINITY.java.lang.StringtoString()StraightLine2Dtransform(AffineTransform2D trans)Returns the transformed line.CircleLine2Dtransform(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.line.AbstractLine2D
buffer, cartesianEquation, clip, curvature, direction, distance, getIntersection, getSymmetric, getSymmetric, horizontalAngle, intersection, intersections, isClosed, isColinear, isColinear, isEmpty, isInside, isParallel, isParallel, length, length, origin, parametric, polarCoefficients, polarCoefficientsSigned, position, position, positionOnLine, positionOnLine, project, projectedPoint, projectedPoint, signedDistance, signedDistance, smoothPieces, subCurve, supportingLine, tangent
-
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D
leftTangent, normal, rightTangent, vertices
-
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
asAwtShape, draw
-
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface math.geom2d.circulinear.CirculinearElement2D
clip, subCurve
-
Methods inherited from interface math.geom2d.circulinear.CirculinearContinuousCurve2D
smoothPieces
-
Methods inherited from interface math.geom2d.circulinear.CirculinearCurve2D
length, length, position
-
Methods inherited from interface math.geom2d.circulinear.CirculinearShape2D
buffer
-
Methods inherited from interface math.geom2d.curve.SmoothCurve2D
normal, tangent
-
Methods inherited from interface math.geom2d.domain.Boundary2D
isInside
-
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
curvature, isClosed, leftTangent, rightTangent
-
Methods inherited from interface math.geom2d.domain.OrientedCurve2D
signedDistance, signedDistance
-
Methods inherited from interface math.geom2d.curve.Curve2D
asAwtShape, draw, intersections, position, project, vertices
-
-
-
-
Constructor Detail
-
StraightLine2D
public StraightLine2D()
Empty constructor: a straight line corresponding to horizontal axis.
-
StraightLine2D
public StraightLine2D(Point2D point1, Point2D point2)
Defines a new Straight line going through the two given points.
-
StraightLine2D
public StraightLine2D(Point2D point, Vector2D direction)
Defines a new Straight line going through the given point, and with the specified direction vector.
-
StraightLine2D
public StraightLine2D(Point2D point, double dx, double dy)
Defines a new Straight line going through the given point, and with the specified direction vector.
-
StraightLine2D
public StraightLine2D(Point2D point, double angle)
Defines a new Straight line going through the given point, and with the specified direction given by angle.
-
StraightLine2D
public StraightLine2D(double xp, double yp, double dx, double dy)
-
StraightLine2D
public StraightLine2D(LinearShape2D line)
Copy constructor: Defines a new Straight line at the same position and with the same direction than an other straight object (line, edge or ray).
-
StraightLine2D
public StraightLine2D(LinearShape2D line, Point2D point)
Defines a new Straight line, parallel to another straigth object (ray, straight line or edge), and going through the given point.
-
StraightLine2D
public StraightLine2D(double a, double b, double c)Defines a new straight line, from the coefficients of the cartesian equation. The starting point of the line is then the point of the line closest to the origin, and the direction vector has unit norm.
-
-
Method Detail
-
create
@Deprecated public static StraightLine2D create(Point2D point, double angle)
Deprecated. since 0.11.1Creates a straight line going through a point and with a given angle.
-
create
@Deprecated public static StraightLine2D create(Point2D p1, Point2D p2)
Deprecated. since 0.11.1Creates a straight line through 2 points.
-
create
@Deprecated public static StraightLine2D create(Point2D origin, Vector2D direction)
Deprecated. since 0.11.1Creates a straight line through a point and with a given direction vector.
-
createHorizontal
public static StraightLine2D createHorizontal(Point2D origin)
Creates a vertical straight line through the given point.- Since:
- 0.10.3
-
createVertical
public static StraightLine2D createVertical(Point2D origin)
Creates a vertical straight line through the given point.- Since:
- 0.10.3
-
createMedian
public static StraightLine2D createMedian(Point2D p1, Point2D p2)
Creates a median between 2 points.- Parameters:
p1- one pointp2- another point- Returns:
- the median of points p1 and p2
- Since:
- 0.6.3
-
createParallel
public static StraightLine2D createParallel(LinearShape2D line, Point2D point)
Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.- Since:
- 0.6.3
-
createParallel
public static StraightLine2D createParallel(LinearShape2D linear, double d)
Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.- Since:
- 0.6.3
-
createPerpendicular
public static StraightLine2D createPerpendicular(LinearShape2D linear, Point2D point)
Returns a new Straight line, perpendicular to a straight object (ray, straight line or edge), and going through the given point.- Since:
- 0.6.3
-
createCartesian
public static StraightLine2D createCartesian(double a, double b, double c)
Returns a new Straight line, with the given coefficient of the cartesian equation (a*x + b*y + c = 0).
-
getIntersection
public static Point2D getIntersection(Point2D p1, Point2D p2, Point2D p3, Point2D p4)
Computes the intersection point of the two (infinite) lines going through p1 and p2 for the first one, and p3 and p4 for the second one. Returns null if two lines are parallel.
-
parallel
public StraightLine2D parallel(Point2D point)
Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.- Overrides:
parallelin classAbstractLine2D- Parameters:
point- the point to go through- Returns:
- the parallel through the point
-
parallel
public StraightLine2D parallel(double d)
Returns the parallel line located at a distance d from the line. Distance is positive in the 'right' side of the line (outside of the limiting half-plane), and negative in the 'left' of the line.- Specified by:
parallelin interfaceCircleLine2D- Specified by:
parallelin interfaceCirculinearBoundary2D- Specified by:
parallelin interfaceCirculinearContinuousCurve2D- Specified by:
parallelin interfaceCirculinearContour2D- Specified by:
parallelin interfaceCirculinearCurve2D- Specified by:
parallelin interfaceCirculinearElement2D- Parameters:
d- the distance between the original curve and he parallel curve.- Returns:
- the parallel curve
- Throws:
DegeneratedLine2DException- if line direction vector is null
-
perpendicular
public StraightLine2D perpendicular(Point2D point)
Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.- Overrides:
perpendicularin classAbstractLine2D- Parameters:
point- the point to go through- Returns:
- the perpendicular through the point
-
transform
public CircleLine2D 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 interfaceCircleLine2D- Specified by:
transformin interfaceCirculinearBoundary2D- Specified by:
transformin interfaceCirculinearContinuousCurve2D- Specified by:
transformin interfaceCirculinearContour2D- Specified by:
transformin interfaceCirculinearCurve2D- Specified by:
transformin interfaceCirculinearElement2D- Specified by:
transformin interfaceCirculinearShape2D- Overrides:
transformin classAbstractLine2D- Parameters:
inv- the circle inversion- Returns:
- the transformed shape
-
domain
public CirculinearDomain2D domain()
Description copied from interface:Boundary2DReturns the domain delimited by this boundary.- Specified by:
domainin interfaceCirculinearBoundary2D- Specified by:
domainin interfaceBoundary2D- Returns:
- the domain delimited by this boundary
-
fill
public void fill(java.awt.Graphics2D g2)
Description copied from interface:Boundary2DFills the interior of the boundary, using the Graphics current Paint.- Specified by:
fillin interfaceBoundary2D- Parameters:
g2- the Graphics to fill on
-
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- Overrides:
windingAnglein classAbstractLine2D- Parameters:
point- a point of the plane- Returns:
- a signed angle
-
asPolyline
public Polyline2D asPolyline(int n)
Throws an exception when called.- Specified by:
asPolylinein interfaceContinuousCurve2D- Overrides:
asPolylinein classAbstractContinuousCurve2D- Parameters:
n- the number of line segments- Returns:
- a polyline with
nline segments. - See Also:
ContinuousCurve2D.asPolyline(int)
-
firstPoint
public Point2D firstPoint()
Throws an infiniteShapeException- Specified by:
firstPointin interfaceCurve2D- Overrides:
firstPointin classAbstractContinuousCurve2D- Returns:
- the first point of the curve
- See Also:
Curve2D.t0(),Curve2D.point(double)
-
lastPoint
public Point2D lastPoint()
Throws an infiniteShapeException- Specified by:
lastPointin interfaceCurve2D- Overrides:
lastPointin classAbstractContinuousCurve2D- Returns:
- the last point of the curve.
- See Also:
Curve2D.t1(),Curve2D.point(double)
-
singularPoints
public java.util.Collection<Point2D> singularPoints()
Returns an empty list of points.- Specified by:
singularPointsin interfaceCurve2D- Overrides:
singularPointsin classAbstractSmoothCurve2D- Returns:
- a collection of Point2D.
- See Also:
Curve2D.singularPoints()
-
isSingular
public boolean isSingular(double pos)
Returns false, whatever the position.- Specified by:
isSingularin interfaceCurve2D- Overrides:
isSingularin classAbstractSmoothCurve2D- Parameters:
pos- the position of the point on the curve- Returns:
- true if the point at this location is singular
- See Also:
Curve2D.isSingular(double)
-
t0
public double t0()
Returns the parameter of the first point of the line, which is always Double.NEGATIVE_INFINITY.
-
getT0
@Deprecated public double getT0()
Deprecated. replaced by t0() (since 0.11.1).
-
t1
public double t1()
Returns the parameter of the last point of the line, which is always Double.POSITIVE_INFINITY.
-
getT1
@Deprecated public double getT1()
Deprecated. replaced by t1() (since 0.11.1).
-
point
public Point2D point(double t)
Returns the point specified with the parametric representation of the line.
-
continuousCurves
public java.util.Collection<? extends StraightLine2D> continuousCurves()
Need to override to cast the type.- Specified by:
continuousCurvesin interfaceCirculinearBoundary2D- Specified by:
continuousCurvesin interfaceCirculinearCurve2D- Specified by:
continuousCurvesin interfaceCurve2D- Specified by:
continuousCurvesin interfaceBoundary2D- Overrides:
continuousCurvesin classAbstractLine2D- Returns:
- a collection of continuous curves.
-
reverse
public StraightLine2D reverse()
Returns the straight line with same origin but with opposite direction vector.- Specified by:
reversein interfaceCircleLine2D- Specified by:
reversein interfaceCirculinearBoundary2D- Specified by:
reversein interfaceCirculinearContinuousCurve2D- Specified by:
reversein interfaceCirculinearContour2D- Specified by:
reversein interfaceCirculinearCurve2D- Specified by:
reversein interfaceCirculinearElement2D- Specified by:
reversein interfaceContinuousCurve2D- Specified by:
reversein interfaceCurve2D- Specified by:
reversein interfaceSmoothCurve2D- Specified by:
reversein interfaceBoundary2D- Specified by:
reversein interfaceContinuousOrientedCurve2D- Specified by:
reversein interfaceContour2D- Specified by:
reversein interfaceOrientedCurve2D- Specified by:
reversein interfaceSmoothContour2D- Specified by:
reversein interfaceSmoothOrientedCurve2D
-
appendPath
public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
Description copied from interface:ContinuousCurve2DAppend the path of the curve to the given path.- Specified by:
appendPathin interfaceContinuousCurve2D- Parameters:
path- a path to modify- Returns:
- the modified path
-
isBounded
public boolean isBounded()
Always returns false, because a line is not bounded.
-
distance
public double distance(double x, double y)Returns the distance of the point (x, y) to this straight line.- Specified by:
distancein interfaceShape2D- Overrides:
distancein classAbstractLine2D- Parameters:
x- the x-coordinate of the pointy- the y-coordinate of the point- Returns:
- distance between this object and the point (x,y)
-
boundingBox
public Box2D boundingBox()
Description copied from interface:Shape2DReturns the bounding box of the shape.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
transform
public StraightLine2D transform(AffineTransform2D trans)
Returns the transformed line. The result is still a StraightLine2D.- Specified by:
transformin interfaceContinuousCurve2D- Specified by:
transformin interfaceCurve2D- Specified by:
transformin interfaceSmoothCurve2D- Specified by:
transformin interfaceBoundary2D- Specified by:
transformin interfaceContinuousOrientedCurve2D- Specified by:
transformin interfaceContour2D- Specified by:
transformin interfaceOrientedCurve2D- Specified by:
transformin interfaceSmoothContour2D- Specified by:
transformin interfaceSmoothOrientedCurve2D- Specified by:
transformin interfaceLinearElement2D- Specified by:
transformin interfaceLinearShape2D- Specified by:
transformin interfaceShape2D- Specified by:
transformin classAbstractLine2D- Parameters:
trans- an affine transform- Returns:
- the transformed shape
-
contains
public boolean contains(double x, double y)Returns true if the point (x, y) lies on the line, with precision given by Shape2D.ACCURACY.
-
contains
public boolean contains(Point2D p)
Returns true if the point p lies on the line, with precision given by Shape2D.ACCURACY.- Specified by:
containsin interfaceShape2D- Overrides:
containsin classAbstractLine2D
-
getGeneralPath
public java.awt.geom.GeneralPath getGeneralPath()
Throws an infiniteShapeException
-
almostEquals
public boolean almostEquals(GeometricObject2D obj, double eps)
Description copied from interface:GeometricObject2DChecks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.- Specified by:
almostEqualsin interfaceGeometricObject2D- Parameters:
obj- the object to compareeps- a threshold value, for example the minimal coordinate difference- Returns:
- true if both object have the same value up to the threshold
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clone
@Deprecated public StraightLine2D clone()
Deprecated. use copy constructor instead (0.11.2)- Specified by:
clonein interfaceCurve2D- Specified by:
clonein classAbstractLine2D
-
-
DMelt 3.0 © DataMelt by jWork.ORG