public class BinarySearchIntersectionIdentifier extends IntersectionIdentifier
IntersectionIdentifier uses a 2D binary search to hone in on potential intersections.
It breaks curves up according to their critical points, so each curve segment is guaranteed to only move in 1 general direction between any two give t values. TODO warning: this project is buggy. The CurveIntersectionApp can be used to highlight several instances where two cubic curves do not produce intersections (even though the human eye can tell they should). Also sometimes exceptions are thrown. The simplest starting point for these issues is: Curve 1: m 100.0 100.0 c 125.0 125.0 125.0 275.0 100.0 300.0 Curve 2: m 113.0 120.0 c 88.0 145.0 88.0 295.0 113.0 320.0
IntersectionIdentifier.IntersectionListener , IntersectionIdentifier.Return , IntersectionIdentifier.SimpleIntersectionListener | Constructor and Description |
|---|
BinarySearchIntersectionIdentifier()
|
| Modifier and Type | Method and Description |
|---|---|
int |
cubicCubic(double ax1, double bx1, double cx1, double dx1, double ay1, double by1, double cy1, double dy1, double ax2, double bx2, double cx2, double dx2, double ay2, double by2, double cy2, double dy2, double[] dest, int offset, IntersectionIdentifier
Identify the intersection(s) of two cubic curves, expressed as parametric equations.
|
int |
lineCubic(double ax1, double bx1, double ay1, double by1, double ax2, double bx2, double cx2, double dx2, double ay2, double by2, double cy2, double dy2, double[] dest, int offset, IntersectionIdentifier
Identify the intersection(s) of a line and a cubic curve, expressed as parametric equations.
|
int |
lineQuadratic(double ax1, double bx1, double ay1, double by1, double ax2, double bx2, double cx2, double ay2, double by2, double cy2, double[] dest, int offset, IntersectionIdentifier
Identify the intersection(s) of a line and a parabola, expressed as parametric equations.
|
int |
quadraticCubic(double ax1, double bx1, double cx1, double ay1, double by1, double cy1, double ax2, double bx2, double cx2, double dx2, double ay2, double by2, double cy2, double dy2, double[] dest, int offset, IntersectionIdentifier
Identify the intersection(s) of a parabola and a cubic curve, expressed as parametric equations.
|
int |
quadraticQuadratic(double ax1, double bx1, double cx1, double ay1, double by1, double cy1, double ax2, double bx2, double cx2, double ay2, double by2, double cy2, double[] dest, int offset, IntersectionIdentifier
Identify the intersection(s) of two parabolas, expressed as parametric equations.
|
cubicCubicBezier, get, getIntersections, getIntersections, lineCubicBezier, lineLine, lineLineBezier, lineQuadraticBezier, quadraticCubicBezier, quadraticQuadraticBezier, setpublic int lineQuadratic(double ax1,
double bx1,
double ay1,
double by1,
double ax2,
double bx2,
double cx2,
double ay2,
double by2,
double cy2,
double[] dest,
int offset,
IntersectionIdentifier.Return returnType)
IntersectionIdentifier
lineQuadratic in class
IntersectionIdentifier
ax1 - the coefficient "ax1" in the equation "x1(t1) = ax1*t1+bx1"
bx1 - the coefficient "bx1" in the equation "x1(t1) = ax1*t1+bx1"
ay1 - the coefficient "ay1" in the equation "y1(t1) = ay1*t1+by1"
by1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1+by1"
ax2 - the coefficient "ax2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
bx2 - the coefficient "bx2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
cx2 - the coefficient "cx2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
ay2 - the coefficient "ay2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
by2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
cy2 - the coefficient "cy2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
dest - the destination to write the time intersections in.
offset - the offset in the array to start writing at.
returnType - the type of data to store in
dest.
public int lineCubic(double ax1,
double bx1,
double ay1,
double by1,
double ax2,
double bx2,
double cx2,
double dx2,
double ay2,
double by2,
double cy2,
double dy2,
double[] dest,
int offset,
IntersectionIdentifier.Return returnType)
IntersectionIdentifier
lineCubic in class
IntersectionIdentifier
ax1 - the coefficient "ax1" in the equation "x1(t1) = ax1*t1+bx1"
bx1 - the coefficient "bx1" in the equation "x1(t1) = ax1*t1+bx1"
ay1 - the coefficient "ay1" in the equation "y1(t1) = ay1*t1+by1"
by1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1+by1"
ax2 - the coefficient "ax2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
bx2 - the coefficient "bx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
cx2 - the coefficient "cx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
dx2 - the coefficient "dx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
ay2 - the coefficient "ay2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
by2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
cy2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dy2 - the coefficient "dy2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dest - the destination to write the time intersections in.
offset - the offset in the array to start writing at.
returnType - the type of data to store in
dest.
public int quadraticQuadratic(double ax1,
double bx1,
double cx1,
double ay1,
double by1,
double cy1,
double ax2,
double bx2,
double cx2,
double ay2,
double by2,
double cy2,
double[] dest,
int offset,
IntersectionIdentifier.Return returnType)
IntersectionIdentifier
quadraticQuadratic in class
IntersectionIdentifier
ax1 - the coefficient "ax1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
bx1 - the coefficient "bx1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
cx1 - the coefficient "cx1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
ay1 - the coefficient "ay1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
by1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
cy1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
ax2 - the coefficient "ax2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
bx2 - the coefficient "bx2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
cx2 - the coefficient "cx2" in the equation "x2(t2) = ax2*t2*t2+bx2*t2+cx2"
ay2 - the coefficient "ay2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
by2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
cy2 - the coefficient "cy2" in the equation "y2(t2) = ay2*t2*t2+by2*t2+cy2"
dest - the destination to write the time intersections in.
offset - the offset in the array to start writing at.
returnType - the type of data to store in
dest.
public int quadraticCubic(double ax1,
double bx1,
double cx1,
double ay1,
double by1,
double cy1,
double ax2,
double bx2,
double cx2,
double dx2,
double ay2,
double by2,
double cy2,
double dy2,
double[] dest,
int offset,
IntersectionIdentifier.Return returnType)
IntersectionIdentifier
quadraticCubic in class
IntersectionIdentifier
ax1 - the coefficient "ax1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
bx1 - the coefficient "bx1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
cx1 - the coefficient "cx1" in the equation "x1(t1) = ax1*t1*t1+bx1*t1+cx1"
ay1 - the coefficient "ay1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
by1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
cy1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1+by1*t1+cy1"
ax2 - the coefficient "ax2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
bx2 - the coefficient "bx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
cx2 - the coefficient "cx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
dx2 - the coefficient "dx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
ay2 - the coefficient "ay2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
by2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
cy2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dy2 - the coefficient "dy2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dest - the destination to write the time intersections in.
offset - the offset in the array to start writing at.
returnType - the type of data to store in
dest.
public int cubicCubic(double ax1,
double bx1,
double cx1,
double dx1,
double ay1,
double by1,
double cy1,
double dy1,
double ax2,
double bx2,
double cx2,
double dx2,
double ay2,
double by2,
double cy2,
double dy2,
double[] dest,
int offset,
IntersectionIdentifier.Return returnType)
IntersectionIdentifier
cubicCubic in class
IntersectionIdentifier
ax1 - the coefficient "ax1" in the equation "x1(t1) = ax1*t1*t1*t1+bx1*t1*t1+cx1*t1+dx1"
bx1 - the coefficient "bx1" in the equation "x1(t1) = ax1*t1*t1*t1+bx1*t1*t1+cx1*t1+dx1"
cx1 - the coefficient "cx1" in the equation "x1(t1) = ax1*t1*t1*t1+bx1*t1*t1+cx1*t1+dx1"
dx1 - the coefficient "dx1" in the equation "x1(t1) = ax1*t1*t1*t1+bx1*t1*t1+cx1*t1+dx1"
ay1 - the coefficient "ay1" in the equation "y1(t1) = ay1*t1*t1*t1+by1*t1*t1+cy1*t1+dy1"
by1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1*t1+by1*t1*t1+cy1*t1+dy1"
cy1 - the coefficient "by1" in the equation "y1(t1) = ay1*t1*t1*t1+by1*t1*t1+cy1*t1+dy1"
dy1 - the coefficient "dy1" in the equation "y1(t1) = ay1*t1*t1*t1+by1*t1*t1+cy1*t1+dy1"
ax2 - the coefficient "ax2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
bx2 - the coefficient "bx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
cx2 - the coefficient "cx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
dx2 - the coefficient "dx2" in the equation "x2(t2) = ax2*t2*t2*t2+bx2*t2*t2+cx2*t2+dx2"
ay2 - the coefficient "ay2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
by2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
cy2 - the coefficient "by2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dy2 - the coefficient "dy2" in the equation "y2(t2) = ay2*t2*t2*t2+by2*t2*t2+cy2*t2+dy2"
dest - the destination to write the time intersections in.
offset - the offset in the array to start writing at.
returnType - the type of data to store in
dest.