java.lang.Object
org.jhotdraw8.geom.intersect.IntersectLinePoint
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleargumentOnLine(double x1, double y1, double x2, double y2, double px, double py) Given a point p on a line, computes the value of the argument 't'.static IntersectionResultintersectLinePoint(double x0, double y0, double x1, double y1, double cx, double cy, double r) Computes the intersection between a line and a point with tolerance radius r.static IntersectionResultExintersectLinePointEx(double x0, double y0, double x1, double y1, double cx, double cy, double r) static booleanlineContainsPoint(double x1, double y1, double x2, double y2, double px, double py) static booleanlineContainsPoint(double x1, double y1, double x2, double y2, double px, double py, double tolerance) Tests if a point is inside a line segment.
-
Method Details
-
intersectLinePoint
public static IntersectionResult intersectLinePoint(double x0, double y0, double x1, double y1, double cx, double cy, double r) Computes the intersection between a line and a point with tolerance radius r.The returned intersection contain the parameters 't1' of the line in range [0,1].
The intersection will have one of the following status:
This method solves the last equation shown in the list below.
- p0 + (p1 - p0) · t1 , 0 ≤ t1 ≤ 1
: line equation in vector form - x0 + (x1 - x0) · t1, y0 + (y1 - y0) · t1
: line equation in matrix form - x0 + Δx · t1, y0 + Δy · t1
: partially compacted coefficients - fx, fy
: compacted coefficients in matrix form - (fx - cx)² + (fy - cy)² = 0
: distance to point equation with fx, fy coefficients inserted - Δx²·Δy²·t1²
+ 2·(Δx·(x0 - cx)+Δy·(y0 - cy))·t1
- 2·(x0·cx + y0·cy) + cx² + cy² + x0² + y0² = 0
: fx, fy coefficients expanded and equation reordered - a·t1² + b·t1 + c = 0, 0 ≤ t1 ≤ 1
: final quadratic polynomial - 2·a·t1 + b = 0, 0 ≤ t1 ≤ 1
: derivative
- Parameters:
x0- point 0 of the liney0- point 0 of the linex1- point 1 of the liney1- point 1 of the linecx- the center of the point p.xcy- the center of the point p.yr- the tolerance radius- Returns:
- computed intersection
- p0 + (p1 - p0) · t1 , 0 ≤ t1 ≤ 1
-
intersectLinePointEx
public static IntersectionResultEx intersectLinePointEx(double x0, double y0, double x1, double y1, double cx, double cy, double r) -
lineContainsPoint
public static boolean lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py) -
lineContainsPoint
public static boolean lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py, double tolerance) Tests if a point is inside a line segment.- Parameters:
x1- the x coordinate of point 1 on the liney1- the y coordinate of point 1 on the linex2- the x coordinate of point 2 on the liney2- the y coordinate of point 2 on the linepx- the x coordinate of the pointpy- the y coordinate of the pointtolerance- the maximal distance that the point may stray from the line- Returns:
- true if the line contains the point within the given tolerance
-
argumentOnLine
public static double argumentOnLine(double x1, double y1, double x2, double y2, double px, double py) Given a point p on a line, computes the value of the argument 't'.If the point p is not on the line it is projected perpendicularly on the line. In this case 't' may be outside of the range [0,1].
- Parameters:
x1- start of liney1- start of linex2- end of liney2- end of linepx- pointpy- point- Returns:
- argument 't' at point px,py on the line.
-