math.geom2d.line
Class LineArc2D

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.LineArc2D
All Implemented Interfaces:
java.lang.Cloneable, CirculinearContinuousCurve2D, CirculinearCurve2D, CirculinearElement2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, SmoothCurve2D, ContinuousOrientedCurve2D, OrientedCurve2D, SmoothOrientedCurve2D, GeometricObject2D, LinearElement2D, LinearShape2D, Shape2D

public class LineArc2D
extends AbstractLine2D
implements SmoothOrientedCurve2D, java.lang.Cloneable

LineArc2D is a generic class to represent edges, straight lines, and rays. It is defined like other linear shapes: origin point, and direction vector. Moreover, two internal variables t0 and t1 define the limit of the object (with t0

  • t0=0 and t1=1: this is an edge.
  • t0=-inf and t1=inf: this is a straight line.
  • t0=0 and t1=inf: this is a ray.
  • t0=-inf and 0: this is an inverted ray.
  • Author:
    dlegland

    Field Summary
     
    Fields inherited from interface math.geom2d.Shape2D
    ACCURACY
     
    Constructor Summary
    LineArc2D(double x1, double y1, double dx, double dy, double t0, double t1)
              Construct a line arc by the parameters of the supporting line and two positions on the line.
    LineArc2D(LineArc2D line)
              Construction by copy of another line arc
    LineArc2D(LinearShape2D line, double t0, double t1)
              Construct a line arc contained in the same straight line as first argument, with bounds of arc given by t0 and t1
    LineArc2D(Point2D point1, Point2D point2, double t0, double t1)
               
     
    Method Summary
     boolean almostEquals(GeometricObject2D obj, double eps)
              Checks if the two objects are similar up to a given threshold value.
     java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
              Appends a line to the current path.
     Box2D boundingBox()
              Returns the bounding box of this line arc.
     LineArc2D clone()
              Ensures public declaration of clone(), and ensures valid return type.
     boolean contains(double xp, double yp)
              Checks if the shape contains the planar point defined by (x,y).
     boolean contains(Point2D pt)
              Checks if the shape contains the given point.
     java.util.Collection<? extends LineArc2D> continuousCurves()
              Returns a collection of lines containing only this line.
    static LineArc2D create(Point2D p1, Point2D p2, double t0, double t1)
              Static factory for creating a new LineArc2D
     boolean equals(java.lang.Object obj)
               
     Point2D firstPoint()
              Returns the first point of the edge.
     java.awt.geom.GeneralPath getGeneralPath()
               
     double getT0()
              Deprecated. replaced by t0() (since 0.11.1).
     double getT1()
              Deprecated. replaced by t1() (since 0.11.1).
     double getX1()
               
     double getX2()
               
     double getY1()
               
     double getY2()
               
     boolean isBounded()
              Returns true if both t0 and t1 are different from infinity.
     boolean isSingular(double pos)
              Returns always false, as a smooth curve does not have singular points by definition.
     Point2D lastPoint()
              Returns the last point of the edge.
     double length()
              Returns the length of the line arc.
     LineArc2D parallel(double d)
              Creates a new curve, formed by the points with parameterization: p(t) = c(t) + d*n(t)/|n(t)|, with p(t) being a point of the original curve, n(t) the normal of the curve, and |n| being the norm of n.
     Point2D point(double t)
              Returns the point located at the given position on the curve.
     LineArc2D reverse()
              Returns the line arc which have the same trace, but has the inverse parameterization.
     java.util.Collection<Point2D> singularPoints()
              Returns an empty set of Point2D, as a smooth curve does not have singular points by definition.
     LineArc2D subCurve(double t0, double t1)
              Returns a new LineArc2D, which is the portion of this LineArc2D delimited by parameters t0 and t1.
     double t0()
              Returns the parameter of the first point of the line arc, arbitrarily set to 0.
     double t1()
              Returns the parameter of the last point of the line arc, arbitrarily set to 1.
     java.lang.String toString()
               
     LineArc2D transform(AffineTransform2D trans)
              Transforms the curve by an affine transform.
     
    Methods inherited from class math.geom2d.line.AbstractLine2D
    buffer, cartesianEquation, clip, curvature, direction, distance, distance, getIntersection, getSymmetric, getSymmetric, horizontalAngle, intersection, intersections, isClosed, isColinear, isColinear, isEmpty, isInside, isParallel, isParallel, length, origin, parallel, parametric, perpendicular, polarCoefficients, polarCoefficientsSigned, position, position, positionOnLine, positionOnLine, project, projectedPoint, projectedPoint, signedDistance, signedDistance, smoothPieces, supportingLine, tangent, transform, windingAngle
     
    Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D
    leftTangent, normal, rightTangent, vertices
     
    Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
    asAwtShape, asPolyline, draw
     
    Methods inherited from class java.lang.Object
    getClass, hashCode, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface math.geom2d.domain.SmoothOrientedCurve2D
    clip
     
    Methods inherited from interface math.geom2d.curve.SmoothCurve2D
    normal, tangent
     
    Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
    asPolyline, curvature, isClosed, leftTangent, rightTangent, smoothPieces
     
    Methods inherited from interface math.geom2d.domain.OrientedCurve2D
    isInside, signedDistance, signedDistance, windingAngle
     
    Methods inherited from interface math.geom2d.curve.Curve2D
    asAwtShape, draw, intersections, position, project, vertices
     
    Methods inherited from interface math.geom2d.Shape2D
    distance, distance, isEmpty
     

    Constructor Detail

    LineArc2D

    public LineArc2D(Point2D point1,
                     Point2D point2,
                     double t0,
                     double t1)
    Parameters:
    point1 - the point located at t=0
    point2 - the point located at t=1
    t0 - the lower bound of line arc parameterization
    t1 - the upper bound of line arc parameterization

    LineArc2D

    public LineArc2D(LinearShape2D line,
                     double t0,
                     double t1)
    Construct a line arc contained in the same straight line as first argument, with bounds of arc given by t0 and t1

    Parameters:
    line - an object defining the supporting line
    t0 - the lower bound of line arc parameterization
    t1 - the upper bound of line arc parameterization

    LineArc2D

    public LineArc2D(LineArc2D line)
    Construction by copy of another line arc

    Parameters:
    line - the line to copy

    LineArc2D

    public LineArc2D(double x1,
                     double y1,
                     double dx,
                     double dy,
                     double t0,
                     double t1)
    Construct a line arc by the parameters of the supporting line and two positions on the line.

    Parameters:
    x1 - the x-coordinate of the first point
    y1 - the y-coordinate of the first point
    dx - the x-coordinate of the direction vector
    dy - the y-coordinate of the direction vector
    t0 - the starting position of the arc
    t1 - the ending position of the arc
    Method Detail

    create

    public static LineArc2D create(Point2D p1,
                                   Point2D p2,
                                   double t0,
                                   double t1)
    Static factory for creating a new LineArc2D

    Since:
    0.8.1

    length

    public double length()
    Returns the length of the line arc.

    Specified by:
    length in interface CirculinearCurve2D
    Overrides:
    length in class AbstractLine2D
    Returns:
    the length of the curve

    getX1

    public double getX1()

    getY1

    public double getY1()

    getX2

    public double getX2()

    getY2

    public double getY2()

    parallel

    public LineArc2D parallel(double d)
    Description copied from interface: CirculinearCurve2D
    Creates a new curve, formed by the points with parameterization: p(t) = c(t) + d*n(t)/|n(t)|, with p(t) being a point of the original curve, n(t) the normal of the curve, and |n| being the norm of n.
    In the case of a continuous curve formed by several smooth circulinear elements, the parallels of contiguous elements are joined by a circle arc.

    Specified by:
    parallel in interface CirculinearContinuousCurve2D
    Specified by:
    parallel in interface CirculinearCurve2D
    Specified by:
    parallel in interface CirculinearElement2D
    Parameters:
    d - the distance between the original curve and he parallel curve.
    Returns:
    the parallel curve

    t0

    public double t0()
    Returns the parameter of the first point of the line arc, arbitrarily set to 0.

    Specified by:
    t0 in interface Curve2D

    getT0

    @Deprecated
    public double getT0()
    Deprecated. replaced by t0() (since 0.11.1).

    Specified by:
    getT0 in interface Curve2D

    t1

    public double t1()
    Returns the parameter of the last point of the line arc, arbitrarily set to 1.

    Specified by:
    t1 in interface Curve2D

    getT1

    @Deprecated
    public double getT1()
    Deprecated. replaced by t1() (since 0.11.1).

    Specified by:
    getT1 in interface Curve2D

    point

    public Point2D point(double t)
    Description copied from interface: Curve2D
    Returns the point located at the given position on the curve. If the parameter lies outside the definition range, the parameter corresponding to the closest bound is used instead. This method can be used to draw an approximated outline of a curve, by selecting multiple values for t and drawing lines between them.

    Specified by:
    point in interface Curve2D

    firstPoint

    public Point2D firstPoint()
    Returns the first point of the edge. In the case of a line, or a ray starting from -infinity, throws an UnboundedShape2DException.

    Specified by:
    firstPoint in interface Curve2D
    Overrides:
    firstPoint in class AbstractContinuousCurve2D
    Returns:
    the last point of the arc
    See Also:
    Curve2D.t0(), Curve2D.point(double)

    lastPoint

    public Point2D lastPoint()
    Returns the last point of the edge. In the case of a line, or a ray ending at infinity, throws an UnboundedShape2DException.

    Specified by:
    lastPoint in interface Curve2D
    Overrides:
    lastPoint in class AbstractContinuousCurve2D
    Returns:
    the last point of the arc
    See Also:
    Curve2D.t1(), Curve2D.point(double)

    singularPoints

    public java.util.Collection<Point2D> singularPoints()
    Description copied from class: AbstractSmoothCurve2D
    Returns an empty set of Point2D, as a smooth curve does not have singular points by definition.

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

    isSingular

    public boolean isSingular(double pos)
    Description copied from class: AbstractSmoothCurve2D
    Returns always false, as a smooth curve does not have singular points by definition.

    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)

    continuousCurves

    public java.util.Collection<? extends LineArc2D> continuousCurves()
    Description copied from class: AbstractLine2D
    Returns a collection of lines containing only this line.

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

    reverse

    public LineArc2D reverse()
    Returns the line arc which have the same trace, but has the inverse parameterization.

    Specified by:
    reverse in interface CirculinearContinuousCurve2D
    Specified by:
    reverse in interface CirculinearCurve2D
    Specified by:
    reverse in interface CirculinearElement2D
    Specified by:
    reverse in interface ContinuousCurve2D
    Specified by:
    reverse in interface Curve2D
    Specified by:
    reverse in interface SmoothCurve2D
    Specified by:
    reverse in interface ContinuousOrientedCurve2D
    Specified by:
    reverse in interface OrientedCurve2D
    Specified by:
    reverse in interface SmoothOrientedCurve2D

    subCurve

    public LineArc2D subCurve(double t0,
                              double t1)
    Returns a new LineArc2D, which is the portion of this LineArc2D delimited by parameters t0 and t1.

    Specified by:
    subCurve in interface CirculinearContinuousCurve2D
    Specified by:
    subCurve in interface CirculinearCurve2D
    Specified by:
    subCurve in interface CirculinearElement2D
    Specified by:
    subCurve in interface ContinuousCurve2D
    Specified by:
    subCurve in interface Curve2D
    Specified by:
    subCurve in interface SmoothCurve2D
    Specified by:
    subCurve in interface ContinuousOrientedCurve2D
    Specified by:
    subCurve in interface SmoothOrientedCurve2D
    Specified by:
    subCurve in interface LinearElement2D
    Overrides:
    subCurve in class AbstractLine2D
    Parameters:
    t0 - position of the start of the sub-curve
    t1 - position of the end of the sub-curve
    Returns:
    the portion of original curve comprised between t0 and t1.

    isBounded

    public boolean isBounded()
    Returns true if both t0 and t1 are different from infinity.

    Specified by:
    isBounded in interface Shape2D

    boundingBox

    public Box2D boundingBox()
    Returns the bounding box of this line arc.

    Specified by:
    boundingBox in interface Shape2D
    Returns:
    the bounding box of the shape.

    contains

    public boolean contains(Point2D pt)
    Description copied from interface: Shape2D
    Checks if the shape contains the given point.

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

    contains

    public boolean contains(double xp,
                            double yp)
    Description copied from interface: Shape2D
    Checks if the shape contains the planar point defined by (x,y).

    Specified by:
    contains in interface Shape2D

    getGeneralPath

    public java.awt.geom.GeneralPath getGeneralPath()

    appendPath

    public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
    Appends a line to the current path. If t0 or t1 is infinite, throws a new UnboundedShape2DException.

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

    transform

    public LineArc2D transform(AffineTransform2D trans)
    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 LinearElement2D
    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

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object

    almostEquals

    public boolean almostEquals(GeometricObject2D obj,
                                double eps)
    Description copied from interface: GeometricObject2D
    Checks 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:
    almostEquals in interface GeometricObject2D
    Parameters:
    obj - the object to compare
    eps - a threshold value, for example the minimal coordinate difference
    Returns:
    true if both object have the same value up to the threshold

    equals

    public boolean equals(java.lang.Object obj)
    Overrides:
    equals in class java.lang.Object

    clone

    public LineArc2D 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