math.geom2d.line
Class LineArc2D
java.lang.Object
math.geom2d.line.StraightObject2D
math.geom2d.line.LineArc2D
- All Implemented Interfaces:
- java.awt.Shape, ContinuousCurve2D, ContinuousOrientedCurve2D, Curve2D, OrientedCurve2D, SmoothCurve2D, SmoothOrientedCurve2D, Shape2D
- Direct Known Subclasses:
- LineSegment2D, Ray2D, StraightLine2D
public class LineArc2D
- extends StraightObject2D
- implements SmoothCurve2D, ContinuousOrientedCurve2D
LineArc2D is a generic class to represent edges, straight lines, and rays.
It is defeined as a StraightObject2D : origin point, and direction vector.
Moreover, two internal variables t0 and t1 define the limit of the object
(with t0
- Author:
- dlegland
|
Field Summary |
protected double |
t0
|
protected double |
t1
|
|
Constructor Summary |
LineArc2D(double x1,
double y1,
double dx,
double dy,
double t0,
double t1)
Construct a line arc by the coordinate of two points and two positions
on the line. |
LineArc2D(LineArc2D line)
Construcion by copy of another line arc |
LineArc2D(Point2D point1,
Point2D point2,
double t0,
double t1)
|
LineArc2D(StraightObject2D 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 |
|
Method Summary |
java.awt.geom.GeneralPath |
appendPath(java.awt.geom.GeneralPath path)
append a line to the current path. |
CurveSet2D<? extends LineArc2D> |
clip(Box2D box)
Clip the circle arc by a box. |
boolean |
contains(double xp,
double yp)
Returns true if the point (x, y) lies on the line covering the object, with
precision given by Shape2D.ACCURACY. |
boolean |
contains(java.awt.geom.Point2D pt)
|
boolean |
equals(LineArc2D arc)
Compare two edges, and returns true if they have the two same vertices. |
boolean |
equals(java.lang.Object obj)
|
Polyline2D |
getAsPolyline(int n)
Returns an approximation of the curve as a polyline with n
line segments. |
Box2D |
getBoundingBox()
Returns the bounding box of the shape. |
java.awt.Rectangle |
getBounds()
Return bounding box of the shape. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return more precise bounds for the shape. |
java.util.Collection<ContinuousCurve2D> |
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)
Get the distance of the point (x, y) to this object. |
double |
getDistance(java.awt.geom.Point2D p)
Get the distance of the point (x, y) to this object. |
Point2D |
getFirstPoint()
Return the first point of the edge. |
java.awt.geom.GeneralPath |
getInnerPath()
|
Point2D |
getLastPoint()
Return the last point of the edge. |
double |
getLength()
Returns the length of the edge. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t)
Return pathiterator for this line arc. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
Return pathiterator for this line arc. |
Point2D |
getPoint(double t)
Gets the point from a parametric representation of the curve. |
Point2D |
getPoint(double t,
Point2D point)
Same as getPoint(t), but gives the point as a parameter. |
Point2D |
getPoint1()
Return the first point of the edge. |
Point2D |
getPoint2()
Return the last point of the edge. |
double |
getPosition(Point2D point)
Gets the position of the point on the line arc. |
LineArc2D |
getReverseCurve()
Returns the line arc which have the same trace, but has the inverse
parametrization. |
java.util.Collection<? extends SmoothCurve2D> |
getSmoothPieces()
Returns an array containing the curve itself. |
LineArc2D |
getSubCurve(double t0,
double t1)
Return a new LineArc2D, which is the portion of the linearc delimited
by parameters t0 and t1. |
double |
getT0()
Returns the parameter of the first point of the edge, arbitrarly set to 0. |
double |
getT1()
Returns the parameter of the last point of the edge, arbitraly set to 1. |
Vector2D |
getTangent(double t)
|
double |
getWindingAngle(java.awt.geom.Point2D point)
Return the angle portion that the curve turn around the given point. |
double |
getX1()
|
double |
getX2()
|
double |
getY1()
|
double |
getY2()
|
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the Line intersects the interior of a specified rectangular area. |
boolean |
intersects(java.awt.geom.Rectangle2D r)
Tests if the Line intersects the interior of a specified rectangle2D. |
boolean |
isBounded()
return true if both t0 and t1 are different from infinity. |
boolean |
isInside(java.awt.geom.Point2D p)
return true if the given point lies to the left of the line when travaling along
the line in the direcion given by its direction vector. |
double |
project(Point2D point)
Gets the position of the closest point on the line arc. |
java.lang.String |
toString()
|
LineArc2D |
transform(AffineTransform2D trans)
Transforms the curve by an affine transform. |
| Methods inherited from class math.geom2d.line.StraightObject2D |
contains, contains, getCartesianEquation, getDistance, getHorizontalAngle, getIntersection, getIntersection, getIntersections, getOrigin, getParallel, getParametric, getPerpendicular, getPolarCoefficients, getPositionOnLine, getPositionOnLine, getProjectedPoint, getProjectedPoint, getSignedDistance, getSignedDistance, getSignedPolarCoefficients, getSupportLine, getSymmetric, getSymmetric, getVector, isClosed, isColinear, isColinear, isInside, isParallel, isParallel |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.Shape |
contains, contains |
t0
protected double t0
t1
protected double t1
LineArc2D
public LineArc2D(Point2D point1,
Point2D point2,
double t0,
double t1)
- Parameters:
point1 - the point located at t=0point2 - the point located at t=1t0 - the lower bound of line arc parameterizationt1 - the upper bound of line arc parameterization
LineArc2D
public LineArc2D(StraightObject2D 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 linet0 - the lower bound of line arc parameterizationt1 - the upper bound of line arc parameterization
LineArc2D
public LineArc2D(LineArc2D line)
- Construcion 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 coordinate of two points and two positions
on the line.
- Parameters:
x1 - the x-coordinate of the first pointy1 - the y-coordinate of the first pointx2 - the x-coordinate of the second pointy2 - the y-coordinate of the second pointt0 - the starting position of the arct1 - the ending position of the arc
getLength
public double getLength()
- Returns the length of the edge.
getPoint1
public Point2D getPoint1()
- Return the first point of the edge. In the case of a line, or a ray
starting from -infinity, returns Point2D.INFINITY_POINT.
- Returns:
- the first point of the arc
getPoint2
public Point2D getPoint2()
- Return the last point of the edge. In the case of a line, or a ray
ending at infinity, returns Point2D.INFINITY_POINT.
- Returns:
- the last point of the arc.
getX1
public double getX1()
getY1
public double getY1()
getX2
public double getX2()
getY2
public double getY2()
getTangent
public Vector2D getTangent(double t)
- Specified by:
getTangent in interface SmoothCurve2D
getCurvature
public double getCurvature(double t)
- returns 0 as every straight object.
- Specified by:
getCurvature in interface SmoothCurve2D
getAsPolyline
public Polyline2D getAsPolyline(int n)
- Description copied from interface:
ContinuousCurve2D
- Returns an approximation of the curve as a polyline with
n
line segments. If the curve is closed, the method should return an
instance of ClosedPolyline2D.
- Specified by:
getAsPolyline in interface ContinuousCurve2D
- Parameters:
n - the number of line segments
- Returns:
- a closed polyline with
n line segments.
getSmoothPieces
public java.util.Collection<? extends SmoothCurve2D> getSmoothPieces()
- Returns an array containing the curve itself.
- Specified by:
getSmoothPieces in interface ContinuousCurve2D- Overrides:
getSmoothPieces in class StraightObject2D
getWindingAngle
public double getWindingAngle(java.awt.geom.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
- Parameters:
point - a point of the plane
- Returns:
- a signed angle
isInside
public boolean isInside(java.awt.geom.Point2D p)
- return true if the given point lies to the left of the line when travaling along
the line in the direcion given by its direction vector.
- Specified by:
isInside in interface OrientedCurve2D
- Parameters:
p - the point to test
- Returns:
- true if point p lies on the 'left' of the line.
getT0
public double getT0()
- Returns the parameter of the first point of the edge, arbitrarly set to 0.
- Specified by:
getT0 in interface Curve2D
getT1
public double getT1()
- Returns the parameter of the last point of the edge, arbitraly set to 1.
- Specified by:
getT1 in interface Curve2D
getPoint
public Point2D getPoint(double t)
- Description copied from interface:
Curve2D
- Gets the point from a parametric representation of 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:
getPoint in interface Curve2D
getPoint
public Point2D getPoint(double t,
Point2D point)
- Description copied from interface:
Curve2D
- Same as getPoint(t), but gives the point as a parameter. This avoids
repetitive memory allocations.
- Specified by:
getPoint in interface Curve2D
getFirstPoint
public Point2D getFirstPoint()
- Return the first point of the edge. In the case of a line, or a ray
starting from -infinity, returns Point2D.INFINITY_POINT.
- Specified by:
getFirstPoint in interface Curve2D
- Returns:
- the last point of the arc
getLastPoint
public Point2D getLastPoint()
- Return the last point of the edge. In the case of a line, or a ray
ending at infinity, returns Point2D.INFINITY_POINT.
- Specified by:
getLastPoint in interface Curve2D
- Returns:
- the last point of the arc
getPosition
public double getPosition(Point2D point)
- Gets the position of the 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 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.
- Specified by:
project in interface Curve2D
- Parameters:
point - a point to project
- Returns:
- the position of the closest orthogonal projection
getReverseCurve
public LineArc2D getReverseCurve()
- Returns the line arc which have the same trace, but has the inverse
parametrization.
- Specified by:
getReverseCurve in interface ContinuousCurve2D- Specified by:
getReverseCurve in interface ContinuousOrientedCurve2D- Specified by:
getReverseCurve in interface Curve2D- Specified by:
getReverseCurve in interface OrientedCurve2D- Specified by:
getReverseCurve in interface SmoothCurve2D- Specified by:
getReverseCurve in interface SmoothOrientedCurve2D
getContinuousCurves
public java.util.Collection<ContinuousCurve2D> getContinuousCurves()
- Description copied from interface:
Curve2D
- Returns the collection of continuous curves which constitute this curve.
- Specified by:
getContinuousCurves in interface Curve2D
- Returns:
- a collection of continuous curves.
getSubCurve
public LineArc2D getSubCurve(double t0,
double t1)
- Return a new LineArc2D, which is the portion of the linearc delimited
by parameters t0 and t1.
- Specified by:
getSubCurve in interface ContinuousCurve2D- Specified by:
getSubCurve in interface ContinuousOrientedCurve2D- Specified by:
getSubCurve in interface Curve2D- Specified by:
getSubCurve in interface SmoothCurve2D- 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.
isBounded
public boolean isBounded()
- return true if both t0 and t1 are different from infinity.
- Specified by:
isBounded in interface Shape2D
getDistance
public double getDistance(java.awt.geom.Point2D p)
- Get the distance of the point (x, y) to this object.
- Specified by:
getDistance in interface Shape2D
getDistance
public double getDistance(double x,
double y)
- Get the distance of the point (x, y) to this object.
- Specified by:
getDistance in interface Shape2D- Overrides:
getDistance in class StraightObject2D
- Parameters:
x - , y : position of point
- Returns:
- distance between this object and the point (x,y)
clip
public CurveSet2D<? extends LineArc2D> clip(Box2D box)
- Clip the circle arc by a box. The result is an instance of
CurveSet2D, which
contains only instances of LineArc2D. If the ellipse arc is not
clipped, the result is an instance of
CurveSet2D which contains 0 curves.
- Specified by:
clip in interface ContinuousCurve2D- Specified by:
clip in interface ContinuousOrientedCurve2D- Specified by:
clip in interface Curve2D- Specified by:
clip in interface OrientedCurve2D- Specified by:
clip in interface SmoothCurve2D- Specified by:
clip in interface SmoothOrientedCurve2D- Specified by:
clip in interface Shape2D
- Parameters:
box - the clipping box
- Returns:
- the clipped shape
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.
contains
public boolean contains(java.awt.geom.Point2D pt)
- Specified by:
contains in interface java.awt.Shape
contains
public boolean contains(double xp,
double yp)
- Description copied from class:
StraightObject2D
- Returns true if the point (x, y) lies on the line covering the object, with
precision given by Shape2D.ACCURACY.
- Specified by:
contains in interface java.awt.Shape- Overrides:
contains in class StraightObject2D
getBounds
public java.awt.Rectangle getBounds()
- Return bounding box of the shape.
- Specified by:
getBounds in interface java.awt.Shape
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D()
- Return more precise bounds for the shape.
- Specified by:
getBounds2D in interface java.awt.Shape
getInnerPath
public java.awt.geom.GeneralPath getInnerPath()
appendPath
public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
- append a line to the current path. If t0 or t1 is infinite,
does not append anything.
- Specified by:
appendPath in interface ContinuousCurve2D
- Parameters:
path - the path to modify
- Returns:
- the modified path
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t)
- Return pathiterator for this line arc.
- Specified by:
getPathIterator in interface java.awt.Shape
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
- Return pathiterator for this line arc.
- Specified by:
getPathIterator in interface java.awt.Shape
intersects
public boolean intersects(double x,
double y,
double w,
double h)
- Tests if the Line intersects the interior of a specified rectangular area.
- Specified by:
intersects in interface java.awt.Shape
intersects
public boolean intersects(java.awt.geom.Rectangle2D r)
- Tests if the Line intersects the interior of a specified rectangle2D.
- Specified by:
intersects in interface java.awt.Shape
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 ContinuousOrientedCurve2D- Specified by:
transform in interface Curve2D- Specified by:
transform in interface OrientedCurve2D- Specified by:
transform in interface SmoothCurve2D- Specified by:
transform in interface SmoothOrientedCurve2D- Specified by:
transform in interface Shape2D- Specified by:
transform in class StraightObject2D
- Parameters:
trans - an affine transform
- Returns:
- the transformed shape
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals in class java.lang.Object
equals
public boolean equals(LineArc2D arc)
- Compare two edges, and returns true if they have the two same vertices.
- Parameters:
arc - : the line arcs to compare to.
- Returns:
- true if extremities of both edges are the same.