Modifier and Type | Class and Description |
---|---|
static class |
Line2d.IntersectionResult
The result of a line intersection.
|
static class |
Line2d.IntersectionType
The type of a result of a line intersection
|
Modifier and Type | Field and Description |
---|---|
Point2d |
begin
Start point of line
|
Point2d |
end
End point of line
|
Constructor and Description |
---|
Line2d()
Construct a line
|
Line2d(float x1,
float y1,
float x2,
float y2)
Construct a line
|
Line2d(Point2d begin,
Point2d end)
Construct a line
|
Modifier and Type | Method and Description |
---|---|
Polyline |
asPolyline()
Convert the path to a polyline representation
|
Point2d |
begin()
Get the beginning of the path
|
Point2d |
calculateCentroid()
Calculate the centroid of the shape
|
double |
calculateHorizontalAngle()
Returns the angle (radians) this line makes with a horizontal line
|
double |
calculateLength()
Calculate the length of the path
|
Rectangle |
calculateRegularBoundingBox()
Compute the regular (oriented to the axes) bounding box of the shape.
|
double |
calculateVerticalAngle()
Returns the angle (radians) this line makes with a vertical line
|
Line2d |
clone() |
static double |
distance(float p1x,
float p1y,
float p2x,
float p2y)
Get the Euclidean distance between two points
|
static double |
distance(Point2d p1,
Point2d p2)
Get the Euclidean distance between two points
|
float |
distanceToLine(Point2d p)
Returns the shortest distance between the point and this line.
|
Point2d |
end()
Get the end of the path
|
boolean |
equals(Object other) |
Point2d |
getBeginPoint()
Get the start point
|
Point2d |
getEndPoint()
Get the end point
|
double |
getHeight() |
Line2d.IntersectionResult |
getIntersection(Line2d otherLine)
Calculates the intersection point of this line and another line
|
Line2d |
getNormal()
Returns a line that is at 90 degrees to the original line.
|
Line2d |
getNormal(Point2d p)
Returns a line that is at 90 degrees to the original line and also passes
through the given point.
|
double |
getWidth() |
int |
hashCode() |
boolean |
isInLine(Point2d p,
float tolerance)
Tests whether the given point lies on this line.
|
boolean |
isOnLine(Point2d p,
float tolerance)
Tests whether the given point lies on this line.
|
static Line2d |
lineFromRotation(int x1,
int y1,
double theta,
int length)
Create a line of a given length that starts at a point and has a given
angle.
|
Iterator<Line2d> |
lineIterator()
Convert the path to a iterated polyline representation
|
Line2d |
lineWithinSquare(Rectangle r)
Given a rectangle, return the line that actually fits inside the
rectangle for this line
|
double |
maxX() |
double |
maxY() |
double |
minX() |
double |
minY() |
Point2d |
reflectAroundLine(Point2d pointToReflect)
Reflects a point around a this line.
|
void |
scale(float sc)
Scale the shape by the given amount about (0,0).
|
void |
scale(Point2d centre,
float sc)
Scale the shape by the given amount about the given point.
|
void |
scaleCentroid(float sc)
Scale the shape about its centroid.
|
void |
setBeginPoint(Point2d begin)
Set the start point
|
Point2d |
setEndPoint()
Get the end point
|
void |
setEndPoint(Point2d end)
Set the end point
|
String |
toString() |
Point2dImpl |
toUnitVector()
Convert the line to a unit vector
|
Line2d |
transform(Jama.Matrix transform)
Transform a line.
|
void |
translate(float x,
float y)
Translate the shapes position
|
public Line2d()
public Line2d(Point2d begin, Point2d end)
begin
- start pointend
- end pointpublic Line2d(float x1, float y1, float x2, float y2)
x1
- x-ordinate of start pointy1
- y-ordinate of start pointx2
- x-ordinate of end pointy2
- y-ordinate of end pointpublic void setBeginPoint(Point2d begin)
begin
- start pointpublic void setEndPoint(Point2d end)
end
- end pointpublic Point2d getBeginPoint()
public Point2d getEndPoint()
public Point2d setEndPoint()
public Line2d.IntersectionResult getIntersection(Line2d otherLine)
otherLine
- The other line segmentLine2d.IntersectionResult
public Point2d reflectAroundLine(Point2d pointToReflect)
pointToReflect
- The point to reflectpublic Line2d lineWithinSquare(Rectangle r)
r
- the boundspublic static double distance(Point2d p1, Point2d p2)
p1
- the first pointp2
- the second pointpublic static double distance(float p1x, float p1y, float p2x, float p2y)
p1x
- the first pointp1y
- the first pointp2x
- the second pointp2y
- the first pointpublic static Line2d lineFromRotation(int x1, int y1, double theta, int length)
x1
- x-ordinate of starting pointy1
- y-ordinate of starting pointtheta
- angle in radianslength
- line lengthpublic double calculateLength()
Path2d
calculateLength
in interface Path2d
public double calculateHorizontalAngle()
public double calculateVerticalAngle()
public Line2d transform(Jama.Matrix transform)
transform
in interface GeometricObject2d
transform
- the transform matrix.public Line2d getNormal()
public Line2d getNormal(Point2d p)
p
- A point that must exist on the normal linepublic void translate(float x, float y)
GeometricObject2d
translate
in interface GeometricObject2d
x
- x-translationy
- y-translationpublic boolean isInLine(Point2d p, float tolerance)
p
- The point to test.tolerance
- The tolerance to use in the testpublic Rectangle calculateRegularBoundingBox()
GeometricObject2d
calculateRegularBoundingBox
in interface GeometricObject2d
public void scale(float sc)
GeometricObject2d
scale
in interface GeometricObject2d
sc
- the scale factor.public void scale(Point2d centre, float sc)
GeometricObject2d
scale
in interface GeometricObject2d
centre
- the centre of the scaling operationsc
- the scale factorpublic void scaleCentroid(float sc)
GeometricObject2d
scaleCentroid
in interface GeometricObject2d
sc
- the scale factorpublic Point2d calculateCentroid()
GeometricObject2d
calculateCentroid
in interface GeometricObject2d
public double minX()
minX
in interface GeometricObject2d
public double minY()
minY
in interface GeometricObject2d
public double maxX()
maxX
in interface GeometricObject2d
public double maxY()
maxY
in interface GeometricObject2d
public double getWidth()
getWidth
in interface GeometricObject2d
public double getHeight()
getHeight
in interface GeometricObject2d
public Point2dImpl toUnitVector()
public Point2d begin()
Path2d
public Polyline asPolyline()
Path2d
asPolyline
in interface Path2d
public Iterator<Line2d> lineIterator()
Path2d
lineIterator
in interface Path2d
public boolean isOnLine(Point2d p, float tolerance)
p
- The point to test.tolerance
- The tolerance to use in the testpublic float distanceToLine(Point2d p)
p
- The point to test.