public class CompGeom
extends java.lang.Object
Constructor and Description |
---|
CompGeom() |
Modifier and Type | Method and Description |
---|---|
static int |
arcArcIntersect(double arc1x1, double arc1y1, double arc1x2, double arc1y2, double c1x, double c1y, double r1, double arc2x1, double arc2y1, double arc2x2, double arc2y2, double c2x, double c2y, double r2, double[] result1, double[] result2)
Finds the open-set intersection(s) of two arc segments, if any.
|
static boolean |
areSegmentsParallel(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, boolean sameSenseOnly) |
static boolean |
areSegmentsParallel(Point2DD a1, Point2DD a2, Point2DD b1, Point2DD b2, boolean sameSenseOnly)
Finds whether two line segments are parallel or, optionally, anti-parallel.
|
static void |
augmentMBR(Point2DD[] mbrAdd, Point2DD[] mbrTarget)
Expands target MBR to encompass added one.
|
static void |
augmentMBR(Point2DD p, Point2DD[] mbrTarget)
Expands target MBR to encompass an added point.
|
static void |
crossProduct(double[] r1, double[] r2, double[] result)
3-D crossproduct via arrays.
|
static double |
crossProduct(double x1, double y1, double x2, double y2) |
static double |
crossProduct(Point2DD p1, Point2DD p2) |
static double |
dotProduct(double x1, double y1, double x2, double y2) |
static double |
dotProduct(Point2DD p1, Point2DD p2) |
static boolean |
incPointInPolygon(Point2DD p, Point2DD[] q, boolean state)
Incremental Point in Polygon routine taking a string of coordinates representing a part (or all) of a ring boundary.
|
static boolean |
inLineRange(double px, double py, double x1, double y1, double x2, double y2)
computes whether the test point is on the open set of the input line segment with the assumption that the point is already known to be on the infinite line of which the line segment is a part.
|
static boolean |
inSector(double px, double py, double sp1x, double sp1y, double sp2x, double sp2y, double sp3x, double sp3y)
inSector determines whether a line drawn from the middle vertex of a triad of vertices to a test point lies within the sector defined by the triad.
|
static boolean |
inSector(Point2DD p, Point2DD[] sectorPoints)
inSector determines whether a line drawn from the middle vertex of a triad of vertices to a test point lies within the sector defined by the triad.
|
static int |
lineArcIntersect(double x1, double y1, double x2, double y2, double arc_x1, double arc_y1, double arc_x2, double arc_y2, double xc, double yc, double r, double[] result1, double[] result2)
Finds the open-set intersection of line and arc segments, if any.
|
static boolean |
lineLineIntersect(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, double[] c)
Finds the open-set intersection of two line segments, if any.
|
static boolean |
lineLineIntersect(Point2DD a1, Point2DD a2, Point2DD b1, Point2DD b2, Point2DD c)
Finds the open-set intersection of two line segments, if any.
|
static void |
main(java.lang.String[] args) |
static boolean |
pointInMBR(double px, double py, double[][] mbr)
Determines if a point is within the bounds of the specified rectangle.
|
static boolean |
pointInMBR(Point2DD p, Point2DD[] mbr)
Determines if a point is within the bounds of the specified rectangle.
|
public static double dotProduct(double x1, double y1, double x2, double y2)
public static double crossProduct(double x1, double y1, double x2, double y2)
public static void crossProduct(double[] r1, double[] r2, double[] result)
public static boolean inSector(Point2DD p, Point2DD[] sectorPoints)
p
- The test pointsectorPoints
- The triad to be tested. Vertex [0] and [2] are the endpoints. Vertex [1] is the central vertex.public static boolean inLineRange(double px, double py, double x1, double y1, double x2, double y2)
If the point is equal to one of the endpoints this routine will return false;
px
- The test point x valuepy
- The test point y valuex1
- x value of line segment point 1y1
- y value of line segment point 1x2
- x value of line segment point 2y2
- y value of line segment point 2public static boolean inSector(double px, double py, double sp1x, double sp1y, double sp2x, double sp2y, double sp3x, double sp3y)
px
- The test point x valuepy
- The test point y valuesp1x
- x value of triad point 1sp1y
- y value of triad point 1sp2x
- x value of triad point 2, the central vertexsp2y
- y value of triad point 2sp3x
- x value of triad point 3sp3y
- y value of triad point 3public static void augmentMBR(Point2DD[] mbrAdd, Point2DD[] mbrTarget)
mbrAdd
- the one to be addedmbrTarget
- the one that is augmented if necessarypublic static void augmentMBR(Point2DD p, Point2DD[] mbrTarget)
p
- the point to be addedmbrTarget
- the one that is augmented if necessarypublic static boolean pointInMBR(Point2DD p, Point2DD[] mbr) throws java.lang.Exception
p
- the point to be tested.mbr
- an array of Point2DD. [0] is the rectangle lower left corner. [1] is the rectangle upper right corner.java.lang.Exception
public static boolean pointInMBR(double px, double py, double[][] mbr)
px
- x component of the point to be tested.py
- y component of the point to be tested.mbr
- a 2x2 array of doubles. First index is x,y. Second is min,maxpublic static boolean incPointInPolygon(Point2DD p, Point2DD[] q, boolean state)
p
- The test pointq
- The portion or all of the polygon perimeterstate
- the current in/out status of the determination. Set false intitiallypublic static int lineArcIntersect(double x1, double y1, double x2, double y2, double arc_x1, double arc_y1, double arc_x2, double arc_y2, double xc, double yc, double r, double[] result1, double[] result2)
return values 0 -- no intersections
-1 -- one touching (tangent) intersection
1 -- one crossing intersection
2 -- two crossing intersections; in-order on both segments
-2 -- two crossing intersections; opposite order (placed in-order on the line)
Resulting intersections are placed in the result1 and result2 arrays.
x1
- x value of first endpoint of line segmenty1
- y value of first endpoint of line segmentx2
- x value of second endpoint of line segmenty2
- y value of second endpoint of line segmentarc_x1
- x of first endpoint of arc in counter-clockwise sensearc_y1
- y of first endpoint of arc in counter-clockwise sensearc_x2
- x of second endpoint of arc in counter-clockwise sensearc_y2
- y of second endpoint of arc in counter-clockwise sensexc
- x value of center of arc segmentyc
- y value of center of arc segmentr
- radius of arcresult1
- a 2-D array of intersection x,y pair if there are one or more open set intersections. Will be allocated here if not allocated by caller.result2
- a 2-D array of intersection x,y pair if there are two open set intersections. Will be allocated here if not allocated by caller.public static int arcArcIntersect(double arc1x1, double arc1y1, double arc1x2, double arc1y2, double c1x, double c1y, double r1, double arc2x1, double arc2y1, double arc2x2, double arc2y2, double c2x, double c2y, double r2, double[] result1, double[] result2)
return values 0 -- no intersections
-1 -- one touching (tangent) intersection
1 -- one crossing intersection
2 -- two crossing intersections; in-order on both segments
-2 -- two crossing intersections; opposite order (placed in-order on the first arc)
Resulting intersections are placed in the result1 and result2 arrays.
x1
- x value of first endpoint of line segmenty1
- y value of first endpoint of line segmentx2
- x value of second endpoint of line segmenty2
- y value of second endpoint of line segmentarc_x1
- x of first endpoint of arc in counter-clockwise sensearc_y1
- y of first endpoint of arc in counter-clockwise sensearc_x2
- x of second endpoint of arc in counter-clockwise sensearc_y2
- y of second endpoint of arc in counter-clockwise sensexc
- x value of center of arc segmentyc
- y value of center of arc segmentr
- radius of arcresult1
- a 2-D array of intersection x,y pair if there are one or more open set intersections. Will be allocated here if not allocated by caller.result2
- a 2-D array of intersection x,y pair if there are two open set intersections. Will be allocated here if not allocated by caller.public static boolean lineLineIntersect(Point2DD a1, Point2DD a2, Point2DD b1, Point2DD b2, Point2DD c)
a1
- the first endpoint of line segment aa2
- the second endpoint of line segment ab1
- the first endpoint of line segment bb2
- the second endpoint of line segment bc
- the intersection (if any). May pass null; if non-null, may be overwritten even if result is false.public static boolean lineLineIntersect(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, double[] c)
a1x
- the first endpoint x-value of line segment aa1y
- the first endpoint y-value of line segment aa2x
- the first endpoint x-value of line segment aa2y
- the first endpoint y-value of line segment ab1x
- the first endpoint x-value of line segment bb1y
- the first endpoint y-value of line segment bb2x
- the first endpoint x-value of line segment bb2y
- the first endpoint y-value of line segment ac
- the intersection (if any). May pass null; if non-null, may be overwritten even if result is false.public static boolean areSegmentsParallel(Point2DD a1, Point2DD a2, Point2DD b1, Point2DD b2, boolean sameSenseOnly)
a1
- the first point of the a segmenta2
- the second point of the a segmentb1
- the first point of the b segmentb2
- the second point of the b segemntsameSenseOnly
- whether parallel only or both parallel/anti-parallel passpublic static boolean areSegmentsParallel(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, boolean sameSenseOnly)
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException