blob: db227cfafd503d2d91220e5044b0fdbbab6e7a3e [file] [log] [blame]
caryclark@google.comd88e0892012-03-27 13:23:51 +00001#ifndef CurveIntersection_DEFINE
2#define CurveIntersection_DEFINE
3
caryclark@google.comc6825902012-02-03 22:07:47 +00004#include "DataTypes.h"
5
6class Intersections;
7
8// unit-testable utilities
caryclark@google.comfa0588f2012-04-26 21:01:06 +00009double axialIntersect(const Quadratic& q1, const _Point& p, bool vert);
caryclark@google.comc6825902012-02-03 22:07:47 +000010bool bezier_clip(const Cubic& cubic1, const Cubic& cubic2, double& minT, double& maxT);
11bool bezier_clip(const Quadratic& q1, const Quadratic& q2, double& minT, double& maxT);
12void chop_at(const Cubic& src, CubicPair& dst, double t);
13void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
14int convex_hull(const Cubic& cubic, char order[4]);
15bool convex_x_hull(const Cubic& cubic, char connectTo0[2], char connectTo3[2]);
16bool implicit_matches(const Cubic& cubic1, const Cubic& cubic2);
17bool implicit_matches(const _Line& line1, const _Line& line2);
caryclark@google.com78e17132012-04-17 11:40:34 +000018bool implicit_matches_ulps(const _Line& one, const _Line& two, int ulps);
caryclark@google.comc6825902012-02-03 22:07:47 +000019bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2);
20void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
caryclark@google.com6680fb12012-02-07 22:10:51 +000021void sub_divide(const _Line& src, double t1, double t2, _Line& dst);
caryclark@google.comc6825902012-02-03 22:07:47 +000022void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
23void tangent(const Cubic& cubic, double t, _Point& result);
24void tangent(const _Line& line, _Point& result);
25void tangent(const Quadratic& quad, double t, _Point& result);
26
27// main functions
28enum ReduceOrder_Flags {
29 kReduceOrder_NoQuadraticsAllowed,
30 kReduceOrder_QuadraticsAllowed
31};
32int reduceOrder(const Cubic& cubic, Cubic& reduction, ReduceOrder_Flags );
33int reduceOrder(const _Line& line, _Line& reduction);
34int reduceOrder(const Quadratic& quad, Quadratic& reduction);
35int horizontalIntersect(const Cubic& cubic, double y, double tRange[3]);
caryclark@google.com198e0542012-03-30 18:47:02 +000036int horizontalIntersect(const Cubic& cubic, double left, double right, double y,
37 double tRange[3]);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000038int horizontalIntersect(const Cubic& cubic, double left, double right, double y,
39 bool flipped, Intersections&);
40int horizontalIntersect(const _Line& line, double left, double right,
41 double y, bool flipped, Intersections& );
caryclark@google.com198e0542012-03-30 18:47:02 +000042int horizontalIntersect(const Quadratic& quad, double left, double right,
43 double y, double tRange[2]);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000044int horizontalIntersect(const Quadratic& quad, double left, double right,
45 double y, bool flipped, Intersections& );
caryclark@google.comc6825902012-02-03 22:07:47 +000046bool intersect(const Cubic& cubic1, const Cubic& cubic2, Intersections& );
47int intersect(const Cubic& cubic, const _Line& line, double cRange[3], double lRange[3]);
48bool intersect(const Quadratic& q1, const Quadratic& q2, Intersections& );
49bool intersect(const Quadratic& quad, const _Line& line, Intersections& );
caryclark@google.com15fa1382012-05-07 20:49:36 +000050bool isLinear(const Quadratic& quad, int startIndex, int endIndex);
51bool isLinear(const Cubic& cubic, int startIndex, int endIndex);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000052double leftMostT(const Cubic& , double startT, double endT);
53double leftMostT(const _Line& , double startT, double endT);
54double leftMostT(const Quadratic& , double startT, double endT);
55int verticalIntersect(const Cubic& cubic, double top, double bottom, double x,
56 bool flipped, Intersections& );
57int verticalIntersect(const _Line& line, double top, double bottom, double x,
58 bool flipped, Intersections& );
59int verticalIntersect(const Quadratic& quad, double top, double bottom,
60 double x, bool flipped, Intersections& );
caryclark@google.comd88e0892012-03-27 13:23:51 +000061
62#endif