math.geom2d.line
Class StraightLine2D

Package class diagram package StraightLine2D
java.lang.Object
  extended by math.geom2d.curve.AbstractContinuousCurve2D
      extended by math.geom2d.curve.AbstractSmoothCurve2D
          extended by math.geom2d.line.AbstractLine2D
              extended by math.geom2d.line.StraightLine2D
All Implemented Interfaces:
Serializable, Cloneable, CircleLine2D, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearElement2D, CirculinearShape2D, ContinuousCirculinearCurve2D, ContinuousCurve2D, Curve2D, SmoothCurve2D, Boundary2D, ContinuousBoundary2D, ContinuousOrientedCurve2D, OrientedCurve2D, SmoothBoundary2D, SmoothOrientedCurve2D, LinearShape2D, Shape2D

public class StraightLine2D
extends AbstractLine2D
implements SmoothBoundary2D, 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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class math.geom2d.line.AbstractLine2D
dx, dy, x0, y0
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
StraightLine2D()
          Empty constructor: a straight line corresponding to horizontal axis.
StraightLine2D(double a, double b, double c)
          Define a new straight line, from the coefficients of the cartesian equation.
StraightLine2D(double xp, double yp, double dx, double dy)
          Define a new Straight line going through the point (xp, yp) and with the direction dx, dy.
StraightLine2D(LinearShape2D line)
          Define 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)
          Define 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)
          Define a new Straight line going through the given point, and with the specified direction given by angle.
StraightLine2D(Point2D point, double dx, double dy)
          Define a new Straight line going through the given point, and with the specified direction vector.
StraightLine2D(Point2D point1, Point2D point2)
          Define a new Straight line going through the two given points.
StraightLine2D(Point2D point, Vector2D direction)
          Define a new Straight line going through the given point, and with the specified direction vector.
 
Method Summary
 GeneralPath appendPath(GeneralPath path)
          Append the path of the curve to the given path.
 StraightLine2D clone()
          Ensures public declaration of clone(), and ensures valid return type.
 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 StraightLine2D create(Point2D point, double angle)
          Creates a straight line going through a point and with a given angle.
static StraightLine2D create(Point2D p1, Point2D p2)
          Creates a straight line through 2 points.
static StraightLine2D create(Point2D origin, Vector2D direction)
          Creates a straight line through a point and with a given direction vector.
static StraightLine2D createCartesian(double a, double b, double c)
          Return a new Straight line, with the given coefficient of the cartesian equation (a*x + b*y + c = 0).
static StraightLine2D createCartesianLine2D(double a, double b, double c)
          Deprecated. since 0.6.3, use createCartesian instead
static StraightLine2D createMedian(Point2D p1, Point2D p2)
          Creates a median between 2 points.
static StraightLine2D createMedian2D(Point2D p1, Point2D p2)
          Deprecated. since 0.6.3, use createMedian instead
static StraightLine2D createOrthogonalLine2D(LinearShape2D linear, Point2D point)
          Deprecated. since 0.6.3, use createPerpendicular instead
static StraightLine2D createParallel(LinearShape2D linear, double d)
          Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.
static StraightLine2D createParallel(LinearShape2D line, Point2D point)
          Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.
static StraightLine2D createParallelLine2D(LinearShape2D linear, double d)
          Deprecated. since 0.6.3, use createParallel() instead
static StraightLine2D createParallelLine2D(LinearShape2D line, Point2D point)
          Deprecated. since 0.6.3, use createParallel() instead
static StraightLine2D createPerpendicular(LinearShape2D linear, Point2D point)
          Return a new Straight line, perpendicular to a straight object (ray, straight line or edge), and going through the given point.
static StraightLine2D createStraightLine2D(Point2D point, double dx, double dy)
          Deprecated. since 0.6.3, use create() instead
static StraightLine2D createStraightLine2D(Point2D p1, Point2D p2)
          Deprecated. use create(Point2D, Point2D) instead
 boolean equals(Object obj)
           
 void fill(Graphics2D g2)
           
 Polyline2D getAsPolyline(int n)
          Throws an exception when called.
 Collection<ContinuousBoundary2D> getBoundaryCurves()
          Returns the different continuous curves composing the boundary
 Box2D getBoundingBox()
          Returns the bounding box of the shape.
 Collection<? extends StraightLine2D> getContinuousCurves()
          Need to override to cast the type.
 double getDistance(double x, double y)
          Returns the distance of the point (x, y) to this straight line.
 Domain2D getDomain()
          Returns the domain delimited by this boundary.
 Point2D getFirstPoint()
          Throws an infiniteShapeException
 GeneralPath getGeneralPath()
          Throws an infiniteShapeException
static Point2D getIntersection(Point2D p1, Point2D p2, Point2D p3, Point2D p4)
          Compute 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.
 Point2D getLastPoint()
          Throws an infiniteShapeException
 StraightLine2D getParallel(double d)
          Return the parallel line located at a distance d.
 StraightLine2D getParallel(Point2D point)
          Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.
 StraightLine2D getPerpendicular(Point2D point)
          Return a new Straight line, parallel to another straigth object (ray, straight line or edge), and going through the given point.
 Point2D getPoint(double t)
          Gets the point specified with the parametric representation of the line.
 StraightLine2D getReverseCurve()
          Returns the straight line with same origin but with opposite direction vector.
 Collection<Point2D> getSingularPoints()
          Returns an empty list of points.
 double getT0()
          Returns the parameter of the first point of the line, which is always Double.NEGATIVE_INFINITY.
 double getT1()
          Returns the parameter of the last point of the line, which is always Double.POSITIVE_INFINITY.
 double getWindingAngle(Point2D point)
          Return the angle portion that the curve turn around the given point.
 boolean isBounded()
          Always returns false, because a line is not bounded.
 boolean isSingular(double pos)
          Returns false, whatever the position.
 void setCartesianEquation(double a, double b, double c)
          Deprecated. lines will become imutable in a future release
 void setLine(double x0, double y0, double dx, double dy)
          Deprecated. lines will become imutable in a future release
 void setLine(LinearShape2D linear)
          Deprecated. lines will become imutable in a future release
 void setLine(Point2D p1, Point2D p2)
          Deprecated. lines will become imutable in a future release
 void setPoints(double x1, double y1, double x2, double y2)
          Deprecated. lines will become imutable in a future release
 String toString()
           
 StraightLine2D transform(AffineTransform2D trans)
          Returns the transformed line.
 CircleLine2D transform(CircleInversion2D inv)
          Transforms the shape by a circle inversion.
 
Methods inherited from class math.geom2d.line.AbstractLine2D
clip, getBuffer, getCartesianEquation, getCurvature, getDistance, getHorizontalAngle, getIntersection, getIntersection, getIntersections, getLength, getLength, getOrigin, getParallel, getParametric, getPolarCoefficients, getPosition, getPosition, getPositionOnLine, getPositionOnLine, getProjectedPoint, getProjectedPoint, getSignedDistance, getSignedDistance, getSignedPolarCoefficients, getSmoothPieces, getSubCurve, getSupportingLine, getSymmetric, getSymmetric, getTangent, getVector, isClosed, isColinear, isColinear, isEmpty, isInside, isParallel, isParallel, project, supportContains
 
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D
getLeftTangent, getRightTangent
 
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
draw, getAsAWTShape, wrapCurve
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface math.geom2d.circulinear.CirculinearElement2D
clip, getSubCurve
 
Methods inherited from interface math.geom2d.circulinear.CirculinearContinuousCurve2D
getSmoothPieces
 
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
getLeftTangent, getRightTangent, isClosed
 
Methods inherited from interface math.geom2d.curve.Curve2D
draw, getAsAWTShape, getIntersections, getPosition, project
 
Methods inherited from interface math.geom2d.Shape2D
getDistance, isEmpty
 
Methods inherited from interface math.geom2d.curve.SmoothCurve2D
getCurvature, getTangent
 
Methods inherited from interface math.geom2d.domain.Boundary2D
isInside
 

Constructor Detail

StraightLine2D

public StraightLine2D()
Empty constructor: a straight line corresponding to horizontal axis.


StraightLine2D

public StraightLine2D(Point2D point1,
                      Point2D point2)
Define a new Straight line going through the two given points.


StraightLine2D

public StraightLine2D(Point2D point,
                      Vector2D direction)
Define a new Straight line going through the given point, and with the specified direction vector.


StraightLine2D

public StraightLine2D(Point2D point,
                      double dx,
                      double dy)
Define a new Straight line going through the given point, and with the specified direction vector.


StraightLine2D

public StraightLine2D(Point2D point,
                      double angle)
Define a new Straight line going through the given point, and with the specified direction given by angle.


StraightLine2D

public StraightLine2D(LinearShape2D line)
Define 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(double xp,
                      double yp,
                      double dx,
                      double dy)
Define a new Straight line going through the point (xp, yp) and with the direction dx, dy.


StraightLine2D

public StraightLine2D(LinearShape2D line,
                      Point2D point)
Define 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)
Define 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

public static final StraightLine2D create(Point2D point,
                                          double angle)
Creates a straight line going through a point and with a given angle.


create

public static final StraightLine2D create(Point2D p1,
                                          Point2D p2)
Creates a straight line through 2 points.


create

public static final StraightLine2D create(Point2D origin,
                                          Vector2D direction)
Creates a straight line through a point and with a given direction vector.


createStraightLine2D

@Deprecated
public static final StraightLine2D createStraightLine2D(Point2D p1,
                                                                   Point2D p2)
Deprecated. use create(Point2D, Point2D) instead


createMedian

public static final StraightLine2D createMedian(Point2D p1,
                                                Point2D p2)
Creates a median between 2 points.

Parameters:
p1 - one point
p2 - another point
Returns:
the median of points p1 and p2
Since:
0.6.3

createMedian2D

@Deprecated
public static final StraightLine2D createMedian2D(Point2D p1,
                                                             Point2D p2)
Deprecated. since 0.6.3, use createMedian instead

Creates a median between 2 points.

Parameters:
p1 - one point
p2 - another point
Returns:
the median of points p1 and p2

createStraightLine2D

@Deprecated
public static final StraightLine2D createStraightLine2D(Point2D point,
                                                                   double dx,
                                                                   double dy)
Deprecated. since 0.6.3, use create() instead

Return a new Straight line going through the given point, and with the specified direction vector.


createParallel

public static final StraightLine2D createParallel(LinearShape2D line,
                                                  Point2D point)
Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.

Since:
0.6.3

createParallelLine2D

@Deprecated
public static final StraightLine2D createParallelLine2D(LinearShape2D line,
                                                                   Point2D point)
Deprecated. since 0.6.3, use createParallel() instead

Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.


createParallel

public static final StraightLine2D createParallel(LinearShape2D linear,
                                                  double d)
Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.

Since:
0.6.3

createParallelLine2D

@Deprecated
public static final StraightLine2D createParallelLine2D(LinearShape2D linear,
                                                                   double d)
Deprecated. since 0.6.3, use createParallel() instead

Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.


createPerpendicular

public static final StraightLine2D createPerpendicular(LinearShape2D linear,
                                                       Point2D point)
Return a new Straight line, perpendicular to a straight object (ray, straight line or edge), and going through the given point.

Since:
0.6.3

createOrthogonalLine2D

@Deprecated
public static final StraightLine2D createOrthogonalLine2D(LinearShape2D linear,
                                                                     Point2D point)
Deprecated. since 0.6.3, use createPerpendicular instead

Return a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.


createCartesian

public static final StraightLine2D createCartesian(double a,
                                                   double b,
                                                   double c)
Return a new Straight line, with the given coefficient of the cartesian equation (a*x + b*y + c = 0).


createCartesianLine2D

@Deprecated
public static final StraightLine2D createCartesianLine2D(double a,
                                                                    double b,
                                                                    double c)
Deprecated. since 0.6.3, use createCartesian instead

Return a new Straight line, with the given coefficient of the cartesian equation (a*x + b*y + c = 0).


getIntersection

public static final Point2D getIntersection(Point2D p1,
                                            Point2D p2,
                                            Point2D p3,
                                            Point2D p4)
Compute 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.


setLine

@Deprecated
public void setLine(double x0,
                               double y0,
                               double dx,
                               double dy)
Deprecated. lines will become imutable in a future release


setPoints

@Deprecated
public void setPoints(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Deprecated. lines will become imutable in a future release


setLine

@Deprecated
public void setLine(Point2D p1,
                               Point2D p2)
Deprecated. lines will become imutable in a future release


setLine

@Deprecated
public void setLine(LinearShape2D linear)
Deprecated. lines will become imutable in a future release


setCartesianEquation

@Deprecated
public void setCartesianEquation(double a,
                                            double b,
                                            double c)
Deprecated. lines will become imutable in a future release


getParallel

public StraightLine2D getParallel(Point2D point)
Returns a new Straight line, parallel to another straight object (ray, straight line or edge), and going through the given point.


getParallel

public StraightLine2D getParallel(double d)
Return the parallel line located at a distance d. 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:
getParallel in interface CircleLine2D
Specified by:
getParallel in interface CirculinearContinuousCurve2D
Specified by:
getParallel in interface CirculinearContour2D
Specified by:
getParallel in interface CirculinearCurve2D
Specified by:
getParallel in interface CirculinearElement2D
Specified by:
getParallel in interface ContinuousCirculinearCurve2D
Parameters:
d - the distance between the original curve and he parallel curve.
Returns:
the parallel curve

getPerpendicular

public StraightLine2D getPerpendicular(Point2D point)
Return a new Straight line, parallel to another straigth object (ray, straight line or edge), and going through the given point.

Overrides:
getPerpendicular in class AbstractLine2D
Parameters:
point - the point to go through
Returns:
the perpendicular through the point

transform

public CircleLine2D transform(CircleInversion2D inv)
Description copied from interface: CirculinearShape2D
Transforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.

Specified by:
transform in interface CircleLine2D
Specified by:
transform in interface CirculinearBoundary2D
Specified by:
transform in interface CirculinearContinuousCurve2D
Specified by:
transform in interface CirculinearContour2D
Specified by:
transform in interface CirculinearCurve2D
Specified by:
transform in interface CirculinearElement2D
Specified by:
transform in interface CirculinearShape2D
Specified by:
transform in interface ContinuousCirculinearCurve2D
Overrides:
transform in class AbstractLine2D
Parameters:
inv - the circle inversion
Returns:
the transformed shape

getBoundaryCurves

public Collection<ContinuousBoundary2D> getBoundaryCurves()
Description copied from interface: Boundary2D
Returns the different continuous curves composing the boundary

Specified by:
getBoundaryCurves in interface Boundary2D

getDomain

public Domain2D getDomain()
Description copied from interface: Boundary2D
Returns the domain delimited by this boundary.

Specified by:
getDomain in interface Boundary2D
Returns:
the domain delimited by this boundary

fill

public void fill(Graphics2D g2)
Specified by:
fill in interface Boundary2D

getWindingAngle

public double getWindingAngle(Point2D point)
Description copied from interface: OrientedCurve2D
Return the angle portion that the curve turn around the given point. Result is a signed angle.

Specified by:
getWindingAngle in interface OrientedCurve2D
Overrides:
getWindingAngle in class AbstractLine2D
Parameters:
point - a point of the plane
Returns:
a signed angle

getAsPolyline

public Polyline2D getAsPolyline(int n)
Throws an exception when called.

Specified by:
getAsPolyline in interface ContinuousCurve2D
Overrides:
getAsPolyline in class AbstractContinuousCurve2D
Parameters:
n - the number of line segments
Returns:
a polyline with n line segments.

getFirstPoint

public Point2D getFirstPoint()
Throws an infiniteShapeException

Specified by:
getFirstPoint in interface Curve2D
Overrides:
getFirstPoint in class AbstractContinuousCurve2D
Returns:
the first point of the curve

getLastPoint

public Point2D getLastPoint()
Throws an infiniteShapeException

Specified by:
getLastPoint in interface Curve2D
Overrides:
getLastPoint in class AbstractContinuousCurve2D
Returns:
the last point of the curve.

getSingularPoints

public Collection<Point2D> getSingularPoints()
Returns an empty list of points.

Specified by:
getSingularPoints in interface Curve2D
Overrides:
getSingularPoints in class AbstractSmoothCurve2D
Returns:
a collection of Point2D.
See Also:
Curve2D.getSingularPoints()

isSingular

public boolean isSingular(double pos)
Returns false, whatever the position.

Specified by:
isSingular in interface Curve2D
Overrides:
isSingular in class AbstractSmoothCurve2D
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)

getT0

public double getT0()
Returns the parameter of the first point of the line, which is always Double.NEGATIVE_INFINITY.

Specified by:
getT0 in interface Curve2D

getT1

public double getT1()
Returns the parameter of the last point of the line, which is always Double.POSITIVE_INFINITY.

Specified by:
getT1 in interface Curve2D

getPoint

public Point2D getPoint(double t)
Gets the point specified with the parametric representation of the line.

Specified by:
getPoint in interface Curve2D

getContinuousCurves

public Collection<? extends StraightLine2D> getContinuousCurves()
Need to override to cast the type.

Specified by:
getContinuousCurves in interface CirculinearBoundary2D
Specified by:
getContinuousCurves in interface CirculinearCurve2D
Specified by:
getContinuousCurves in interface Curve2D
Overrides:
getContinuousCurves in class AbstractLine2D
Returns:
a collection of continuous curves.

getReverseCurve

public StraightLine2D getReverseCurve()
Returns the straight line with same origin but with opposite direction vector.

Specified by:
getReverseCurve in interface CircleLine2D
Specified by:
getReverseCurve in interface CirculinearBoundary2D
Specified by:
getReverseCurve in interface CirculinearContinuousCurve2D
Specified by:
getReverseCurve in interface CirculinearContour2D
Specified by:
getReverseCurve in interface CirculinearCurve2D
Specified by:
getReverseCurve in interface CirculinearElement2D
Specified by:
getReverseCurve in interface ContinuousCirculinearCurve2D
Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface Curve2D
Specified by:
getReverseCurve in interface SmoothCurve2D
Specified by:
getReverseCurve in interface Boundary2D
Specified by:
getReverseCurve in interface ContinuousBoundary2D
Specified by:
getReverseCurve in interface ContinuousOrientedCurve2D
Specified by:
getReverseCurve in interface OrientedCurve2D
Specified by:
getReverseCurve in interface SmoothBoundary2D
Specified by:
getReverseCurve in interface SmoothOrientedCurve2D

appendPath

public GeneralPath appendPath(GeneralPath path)
Description copied from interface: ContinuousCurve2D
Append the path of the curve to the given path.

Specified by:
appendPath in interface ContinuousCurve2D
Parameters:
path - a path to modify
Returns:
the modified path

isBounded

public boolean isBounded()
Always returns false, because a line is not bounded.

Specified by:
isBounded in interface Shape2D

getDistance

public double getDistance(double x,
                          double y)
Returns the distance of the point (x, y) to this straight line.

Specified by:
getDistance in interface Shape2D
Overrides:
getDistance in class AbstractLine2D
Parameters:
x - x-coordinate of the point
y - y-coordinate of the point
Returns:
distance between this object and the point (x,y)

getBoundingBox

public Box2D getBoundingBox()
Description copied from interface: Shape2D
Returns the bounding box of the shape.

Specified by:
getBoundingBox in interface Shape2D
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:
transform in interface ContinuousCurve2D
Specified by:
transform in interface Curve2D
Specified by:
transform in interface SmoothCurve2D
Specified by:
transform in interface Boundary2D
Specified by:
transform in interface ContinuousBoundary2D
Specified by:
transform in interface ContinuousOrientedCurve2D
Specified by:
transform in interface OrientedCurve2D
Specified by:
transform in interface SmoothBoundary2D
Specified by:
transform in interface SmoothOrientedCurve2D
Specified by:
transform in interface LinearShape2D
Specified by:
transform in interface Shape2D
Specified by:
transform in class AbstractLine2D
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.

Specified by:
contains in interface Shape2D

contains

public boolean contains(Point2D p)
Returns true if the point p lies on the line, with precision given by Shape2D.ACCURACY.

Specified by:
contains in interface Shape2D
Overrides:
contains in class AbstractLine2D

getGeneralPath

public GeneralPath getGeneralPath()
Throws an infiniteShapeException


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

clone

public StraightLine2D clone()
Description copied from class: AbstractLine2D
Ensures public declaration of clone(), and ensures valid return type.

Specified by:
clone in interface Curve2D
Specified by:
clone in class AbstractLine2D
Returns:
the cloned curve


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.