|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.geom2d.line.StraightObject2D
math.geom2d.line.LineObject2D
public class LineObject2D
Straight Object defined from 2 points. This object keep points reference in memory,
then changing location of point obtained with getPoint2() or
getPoint2() will change properties of line.
Moreover, type of object can change if one or both of the ending points are set
to null. It is then an easy way represent Straight Lines, Edges or
Rays in the same class. If both points exist, object is like an Edge2D. If one
only the two points is set to null , it is like a Ray2D, with
orientation depending one the missing point. If the two Points are set to
null , then the object is like a StraightLine2D.
Example :
// Create an Edge2D
LineObject2D line = new LineObject2D(new Point2D(0, 0), new Point2D(1, 2));
// Change direction of line, by changing second point :
line.getPoint2().setLocation(4, 5);
// Change position and direction of the line, by changing second point. 'line' is
// now the edge (2,3)-(4,5)
line.setPoint1(new Point2D(2, 3));
// Transform into Ray2D :
line.setPoint1(null);
// Transform into Line2D, going through (2,3) and (4,5) :
line.setPoint2(null);
This class is maybe slower than Edge2D or StraightLine2D, because parameters are updated each time a computation is made, causing lot of additional processing.
| Field Summary |
|---|
| Fields inherited from class math.geom2d.line.StraightObject2D |
|---|
dx, dy, x0, y0 |
| Fields inherited from interface math.geom2d.curve.ContinuousCurve2D |
|---|
CIRCLE, CLOSED_EDGE, LOOP, OPEN_EDGE |
| Fields inherited from interface math.geom2d.Shape2D |
|---|
ACCURACY, defaultClipWindow, EMPTY_SET |
| Constructor Summary | |
|---|---|
LineObject2D(double x1,
double y1,
double x2,
double y2)
Define a new Edge with two extremities. |
|
LineObject2D(Point2D point1,
Point2D point2)
Define a new Edge with two extremities. |
|
| Method Summary | |
|---|---|
java.awt.geom.GeneralPath |
appendPath(java.awt.geom.GeneralPath path)
Append the path of the curve to the given path. |
CurveSet2D<? extends LineArc2D> |
clip(Box2D box)
Clip the line object by a box. |
boolean |
contains(double x,
double y)
Return true if the point (x, y) lies on the line, with precision given by Shape2D.ACCURACY. |
boolean |
contains(double x,
double y,
double w,
double h)
Return false, because an line cannot contain a rectangle. |
boolean |
contains(java.awt.geom.Point2D p)
Return true if the point p lies on the line, with precision given by Shape2D.ACCURACY. |
boolean |
equals(LineObject2D edge)
Two LineObject2D are equals if the share the two same points, in the same order. |
boolean |
equals(java.lang.Object obj)
|
Polyline2D |
getAsPolyline(int n)
Returns an approximation of the curve as a polyline with n
line segments. |
ContinuousOrientedCurve2D[] |
getBoundaryCurves()
|
Box2D |
getBoundingBox()
Return more precise bounds for the LineObject. |
java.awt.Rectangle |
getBounds()
Return bounding box of the shape. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return more precise bounds for the shape. |
double[] |
getCartesianEquation()
Returns the coefficient of the cartesian representation of the line. |
Shape2D |
getClippedShape(Box2D box)
|
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 edge. |
double |
getDistance(java.awt.geom.Point2D p)
Get the distance of the point (x, y) to this edge. |
Point2D |
getFirstPoint()
Get the first point of the curve. |
double |
getHorizontalAngle()
Gets Angle with axis (O,i), counted counter-clockwise. |
java.awt.geom.GeneralPath |
getInnerPath()
|
Point2D |
getLastPoint()
Get the last point of the curve. |
double |
getLength()
Returns the length of the edge. |
Point2D |
getOtherPoint(Point2D point)
Return the opposite vertex of the edge. |
StraightLine2D |
getParallel(Point2D point)
Create a straight line parallel to this object, and going through the given point. |
double[][] |
getParametric()
Returns the matrix of parametric representation of the line. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t)
Return pathiterator for this edge. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
Return pathiterator for this edge. |
StraightLine2D |
getPerpendicular(Point2D point)
Create a straight line perpendicular to this object, and going through the given point. |
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[] |
getPolarCoefficients()
Returns two coefficients : the minimal distance between the straight line covering this object and the origin, and the angle of object with horizontal. |
double |
getPosition(Point2D point)
Gets position of the point on the line. |
Point2D |
getProjectedPoint(double x,
double y)
Return the projection of point p on the line. |
Point2D |
getProjectedPoint(Point2D p)
Return the projection of point p on the line. |
LineObject2D |
getReverseCurve()
return the line object which starts at point2 and ends at
point1. |
double |
getSignedDistance(double x,
double y)
Get the signed distance of the StraightObject2d to the given point. |
double |
getSignedDistance(java.awt.geom.Point2D p)
Get the signed distance of the StraightObject2d to the given point. |
double[] |
getSignedPolarCoefficients()
Returns the polar coefficients, but distance to origin can be negative : this allows representation of directed lines. |
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 line Object. |
double |
getT1()
Returns the parameter of the first point of the line Object. |
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 only if both point1 and point2
are not set to null. |
boolean |
isColinear(StraightObject2D line)
|
boolean |
isInside(java.awt.geom.Point2D point)
return true if the point is 'inside' the domain bounded by the curve. |
boolean |
isParallel(StraightObject2D line)
Test if the this object is parallel to the given one. |
boolean |
isPositivelyOriented(Point2D point)
|
double |
project(Point2D point)
Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. |
void |
setPoint1(Point2D point)
|
void |
setPoint2(Point2D point)
|
java.lang.String |
toString()
|
LineObject2D |
transform(AffineTransform2D trans)
Transforms the curve by an affine transform. |
| Methods inherited from class math.geom2d.line.StraightObject2D |
|---|
contains, getDistance, getIntersection, getIntersection, getIntersections, getOrigin, getPositionOnLine, getPositionOnLine, getSupportLine, getSymmetric, getSymmetric, getVector, isClosed, isColinear, isInside, isParallel |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LineObject2D(Point2D point1,
Point2D point2)
public LineObject2D(double x1,
double y1,
double x2,
double y2)
| Method Detail |
|---|
public boolean isBounded()
point1 and point2
are not set to null. If one of the two points is null, it is a Ray.
If both points are set to null, it is a Straight Line.
public boolean isColinear(StraightObject2D line)
isColinear in class StraightObject2Dpublic boolean isParallel(StraightObject2D line)
isParallel in class StraightObject2Dpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean equals(LineObject2D edge)
edge - : the edge to compare to.
public double getDistance(java.awt.geom.Point2D p)
public double getDistance(double x,
double y)
getDistance in interface Shape2DgetDistance in class StraightObject2Dx - , y : position of point
public double getSignedDistance(java.awt.geom.Point2D p)
StraightObject2D
getSignedDistance in interface OrientedCurve2DgetSignedDistance in class StraightObject2Dp - a point of the plane
public double getSignedDistance(double x,
double y)
StraightObject2D
getSignedDistance in interface OrientedCurve2DgetSignedDistance in class StraightObject2Dx - x-coord of a pointy - y-coord of a point
public boolean isPositivelyOriented(Point2D point)
public double[][] getParametric()
StraightObject2D[ x0 dx ]
[ y0 dy ]
It can be easily extended to higher dimensions and/or higher polynomial forms.
getParametric in class StraightObject2Dpublic double[] getCartesianEquation()
StraightObject2D
getCartesianEquation in class StraightObject2Dpublic double[] getPolarCoefficients()
StraightObject2D
getPolarCoefficients in class StraightObject2Dpublic double[] getSignedPolarCoefficients()
StraightObject2D
getSignedPolarCoefficients in class StraightObject2Dpublic double getHorizontalAngle()
StraightObject2D
getHorizontalAngle in class StraightObject2Dpublic Point2D getProjectedPoint(Point2D p)
StraightObject2D
getProjectedPoint in class StraightObject2Dp - a point outside the line (if point p lies on the line, it is returned)
public Point2D getProjectedPoint(double x,
double y)
StraightObject2D
getProjectedPoint in class StraightObject2Dx - : coordinate x of point to be projectedy - : coordinate y of point to be projected
public StraightLine2D getParallel(Point2D point)
getParallel in class StraightObject2Dpoint - the point to go through
public StraightLine2D getPerpendicular(Point2D point)
getPerpendicular in class StraightObject2Dpoint - : the point to go through
public Shape2D getClippedShape(Box2D box)
public CurveSet2D<? extends LineArc2D> clip(Box2D box)
box - the clipping box
public Box2D getBoundingBox()
public double getLength()
public Point2D getPoint1()
public Point2D getPoint2()
public double getX1()
public double getY1()
public double getX2()
public double getY2()
public Point2D getOtherPoint(Point2D point)
point - : one of the vertices of the edge
public Vector2D getTangent(double t)
public double getCurvature(double t)
public Polyline2D getAsPolyline(int n)
ContinuousCurve2Dn
line segments. If the curve is closed, the method should return an
instance of ClosedPolyline2D.
n - the number of line segments
n line segments.public java.util.Collection<? extends SmoothCurve2D> getSmoothPieces()
getSmoothPieces in interface ContinuousCurve2DgetSmoothPieces in class StraightObject2Dpublic ContinuousOrientedCurve2D[] getBoundaryCurves()
public double getWindingAngle(java.awt.geom.Point2D point)
OrientedCurve2D
point - a point of the plane
public boolean isInside(java.awt.geom.Point2D point)
OrientedCurve2D
point - a point in the plane
public double getT0()
public double getT1()
public Point2D getPoint(double t)
Curve2D
public Point2D getPoint(double t,
Point2D point)
Curve2D
public Point2D getFirstPoint()
public Point2D getLastPoint()
public double getPosition(Point2D point)
If point does not belong to edge, return Double.NaN. The current implementation
uses the direction with the biggest derivative, in order to avoid divisions
by zero.
t = (xp - x0)/dx <\code>, or equivalently : t = (yp - y0)/dy <\code>.
point - a point belonging to the curve
public double project(Point2D point)
Curve2D
point - a point to project
public LineObject2D getReverseCurve()
point2 and ends at
point1.
public java.util.Collection<ContinuousCurve2D> getContinuousCurves()
Curve2D
public LineArc2D getSubCurve(double t0,
double t1)
t0 - position of the start of the sub-curvet1 - position of the end of the sub-curve
public void setPoint1(Point2D point)
public void setPoint2(Point2D point)
public boolean contains(double x,
double y)
contains in interface java.awt.Shapecontains in class StraightObject2D
public boolean contains(double x,
double y,
double w,
double h)
contains in interface java.awt.Shapecontains in class StraightObject2Dpublic boolean contains(java.awt.geom.Point2D p)
public java.awt.Rectangle getBounds()
public java.awt.geom.Rectangle2D getBounds2D()
public java.awt.geom.GeneralPath getInnerPath()
public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
ContinuousCurve2D
path - a path to modify
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t)
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
public boolean intersects(double x,
double y,
double w,
double h)
public boolean intersects(java.awt.geom.Rectangle2D r)
public LineObject2D transform(AffineTransform2D trans)
Curve2D
transform in interface ContinuousCurve2Dtransform in interface ContinuousOrientedCurve2Dtransform in interface Curve2Dtransform in interface OrientedCurve2Dtransform in interface SmoothCurve2Dtransform in interface SmoothOrientedCurve2Dtransform in interface Shape2Dtransform in class StraightObject2Dtrans - an affine transform
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||