|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.geom2d.line.StraightObject2D
public abstract class StraightObject2D
Base class for straight curves, such as straight lines, rays, or edges.
Internal representation of straight objects is parametric : (x0, y0) is a point in the object, and (dx, dy) is a direction vector of the line.
If the line is defined by two point, we can set (x0,y0) to the first point, and (dx,dy) to the vector (p1, p2).
Then, coordinates for a point (x,y) such as x=x0+t*dx and y=y0+t=dy, t between 0 and 1 give a point inside p1 and p2, t<0 give a point 'before' p1, and t>1 give a point 'after' p2, so it is convenient to easily manage edges, rays and straight lines.
At the difference of LineArc2D, this class is not necessarily connex (it can be the union of several colinear line segments).
| Field Summary | |
|---|---|
protected double |
dx
Direction vector of the line. dx and dy should not be both zero. |
protected double |
dy
Direction vector of the line. dx and dy should not be both zero. |
protected double |
x0
Coordinates of starting point of the line |
protected double |
y0
Coordinates of starting point of the line |
| 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 | |
|---|---|
StraightObject2D()
|
|
| Method Summary | |
|---|---|
boolean |
contains(double x,
double y)
Returns true if the point (x, y) lies on the line covering the object, with precision given by Shape2D.ACCURACY. |
boolean |
contains(double x,
double y,
double w,
double h)
Returns false, because a line cannot contain a rectangle. |
boolean |
contains(java.awt.geom.Rectangle2D r)
Returns false, because a line cannot contain a rectangle. |
double[] |
getCartesianEquation()
Returns the coefficient of the cartesian representation of the line. |
double |
getDistance(double x,
double y)
Get the distance of the StraightObject2d to the given point. |
double |
getDistance(Point2D p)
Get the distance of the StraightObject2d to the given point. |
double |
getHorizontalAngle()
Gets Angle with axis (O,i), counted counter-clockwise. |
Point2D |
getIntersection(StraightObject2D line)
Returns the unique intersection with a straight object. |
static Point2D |
getIntersection(StraightObject2D l1,
StraightObject2D l2)
Returns the unique intersection of two straight objects. |
java.util.Collection<Point2D> |
getIntersections(StraightObject2D line)
Return the intersection points of the curve with the specified line. |
Point2D |
getOrigin()
|
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. |
StraightLine2D |
getPerpendicular(Point2D point)
Create a straight line perpendicular to this object, and going through the given point. |
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 |
getPositionOnLine(double x,
double y)
Compute position on the line, that is the number t such that if the point belong to the line, it location is given by x=x0+t*dx and y=y0+t*dy. |
double |
getPositionOnLine(Point2D point)
|
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. |
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 a set of smooth curves. |
StraightLine2D |
getSupportLine()
returns one straight line which contains this straight object. |
Point2D |
getSymmetric(double x,
double y)
Return the symmetric of point with coordinate (x, y) relative to this straight line. |
Point2D |
getSymmetric(Point2D p)
Return the symmetric of point p relative to this straight line. |
Vector2D |
getVector()
|
boolean |
isClosed()
Always returns false, because we can not come back to starting point if we always go straight ... |
boolean |
isColinear(StraightObject2D line)
|
static boolean |
isColinear(StraightObject2D line1,
StraightObject2D line2)
Test if the two linear objects are located on the same straight line. |
boolean |
isInside(Point2D p)
return true if the given point lies to the left of the line when travelling along the line in the direcion given by its direction vector. |
boolean |
isParallel(StraightObject2D line)
Test if the this object is parallel to the given one. |
static boolean |
isParallel(StraightObject2D line1,
StraightObject2D line2)
Test if the two linear objects are parallel. |
abstract StraightObject2D |
transform(AffineTransform2D transform)
Transforms the curve by an affine transform. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface math.geom2d.curve.SmoothOrientedCurve2D |
|---|
clip, getReverseCurve, getSubCurve |
| Methods inherited from interface math.geom2d.curve.SmoothCurve2D |
|---|
getCurvature, getTangent |
| Methods inherited from interface math.geom2d.curve.ContinuousCurve2D |
|---|
appendPath, getAsPolyline |
| Methods inherited from interface math.geom2d.curve.OrientedCurve2D |
|---|
getWindingAngle, isInside |
| Methods inherited from interface math.geom2d.curve.Curve2D |
|---|
getContinuousCurves, getFirstPoint, getLastPoint, getPoint, getPoint, getPosition, getT0, getT1, project |
| Methods inherited from interface math.geom2d.Shape2D |
|---|
getBoundingBox, getDistance, isBounded |
| Methods inherited from interface java.awt.Shape |
|---|
contains, getBounds, getBounds2D, getPathIterator, getPathIterator, intersects, intersects |
| Field Detail |
|---|
protected double x0
protected double y0
protected double dx
protected double dy
| Constructor Detail |
|---|
public StraightObject2D()
| Method Detail |
|---|
public static final Point2D getIntersection(StraightObject2D l1,
StraightObject2D l2)
public static final boolean isColinear(StraightObject2D line1,
StraightObject2D line2)
public static final boolean isParallel(StraightObject2D line1,
StraightObject2D line2)
public Point2D getOrigin()
public Vector2D getVector()
public boolean isColinear(StraightObject2D line)
public boolean isParallel(StraightObject2D line)
public boolean isClosed()
isClosed in interface ContinuousCurve2Dpublic java.util.Collection<? extends SmoothCurve2D> getSmoothPieces()
getSmoothPieces in interface ContinuousCurve2Dpublic double getDistance(Point2D p)
public double getDistance(double x,
double y)
getDistance in interface Shape2Dx - , y : position of point
public double getSignedDistance(java.awt.geom.Point2D p)
getSignedDistance in interface OrientedCurve2Dp - a point of the plane
public double getSignedDistance(double x,
double y)
getSignedDistance in interface OrientedCurve2Dx - x-coord of a pointy - y-coord of a point
public boolean isInside(Point2D p)
p - the point to test
public double[][] getParametric()
[ x0 dx ]
[ y0 dy ]
It can be easily extended to higher dimensions and/or higher polynomial forms.
public double[] getCartesianEquation()
public double[] getPolarCoefficients()
public double[] getSignedPolarCoefficients()
public double getHorizontalAngle()
public double getPositionOnLine(Point2D point)
public double getPositionOnLine(double x,
double y)
If the point does not belong to the line, the method returns the position of its projection on the line.
public java.util.Collection<Point2D> getIntersections(StraightObject2D line)
getIntersections in interface Curve2Dpublic Point2D getIntersection(StraightObject2D line)
public Point2D getProjectedPoint(Point2D p)
p - a point outside the line (if point p lies on the line, it is returned)
public StraightLine2D getSupportLine()
public Point2D getProjectedPoint(double x,
double y)
x - : coordinate x of point to be projectedy - : coordinate y of point to be projected
public Point2D getSymmetric(Point2D p)
p - a point outside the line (if point p lies on the line, it is returned)
public Point2D getSymmetric(double x,
double y)
x - : coordinate x of point to be projectedy - : coordinate y of point to be projected
public StraightLine2D getParallel(Point2D point)
point - : the point to go through
public StraightLine2D getPerpendicular(Point2D point)
point - the point to go through
public boolean contains(double x,
double y)
contains in interface java.awt.Shape
public boolean contains(double x,
double y,
double w,
double h)
contains in interface java.awt.Shapepublic boolean contains(java.awt.geom.Rectangle2D r)
contains in interface java.awt.Shapepublic abstract StraightObject2D transform(AffineTransform2D transform)
Curve2D
transform in interface ContinuousCurve2Dtransform in interface ContinuousOrientedCurve2Dtransform in interface Curve2Dtransform in interface OrientedCurve2Dtransform in interface SmoothCurve2Dtransform in interface SmoothOrientedCurve2Dtransform in interface Shape2Dtransform - an affine transform
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||