caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 1 | #ifndef CurveIntersection_DEFINE |
| 2 | #define CurveIntersection_DEFINE |
| 3 | |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 4 | #include "DataTypes.h" |
| 5 | |
| 6 | class Intersections; |
| 7 | |
| 8 | // unit-testable utilities |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 9 | double axialIntersect(const Quadratic& q1, const _Point& p, bool vert); |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 10 | bool bezier_clip(const Cubic& cubic1, const Cubic& cubic2, double& minT, double& maxT); |
| 11 | bool bezier_clip(const Quadratic& q1, const Quadratic& q2, double& minT, double& maxT); |
| 12 | void chop_at(const Cubic& src, CubicPair& dst, double t); |
| 13 | void chop_at(const Quadratic& src, QuadraticPair& dst, double t); |
| 14 | int convex_hull(const Cubic& cubic, char order[4]); |
| 15 | bool convex_x_hull(const Cubic& cubic, char connectTo0[2], char connectTo3[2]); |
| 16 | bool implicit_matches(const Cubic& cubic1, const Cubic& cubic2); |
| 17 | bool implicit_matches(const _Line& line1, const _Line& line2); |
caryclark@google.com | 78e1713 | 2012-04-17 11:40:34 +0000 | [diff] [blame] | 18 | bool implicit_matches_ulps(const _Line& one, const _Line& two, int ulps); |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 19 | bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2); |
| 20 | void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst); |
caryclark@google.com | 6680fb1 | 2012-02-07 22:10:51 +0000 | [diff] [blame] | 21 | void sub_divide(const _Line& src, double t1, double t2, _Line& dst); |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 22 | void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst); |
| 23 | void tangent(const Cubic& cubic, double t, _Point& result); |
| 24 | void tangent(const _Line& line, _Point& result); |
| 25 | void tangent(const Quadratic& quad, double t, _Point& result); |
| 26 | |
| 27 | // main functions |
| 28 | enum ReduceOrder_Flags { |
| 29 | kReduceOrder_NoQuadraticsAllowed, |
| 30 | kReduceOrder_QuadraticsAllowed |
| 31 | }; |
| 32 | int reduceOrder(const Cubic& cubic, Cubic& reduction, ReduceOrder_Flags ); |
| 33 | int reduceOrder(const _Line& line, _Line& reduction); |
| 34 | int reduceOrder(const Quadratic& quad, Quadratic& reduction); |
| 35 | int horizontalIntersect(const Cubic& cubic, double y, double tRange[3]); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame] | 36 | int horizontalIntersect(const Cubic& cubic, double left, double right, double y, |
| 37 | double tRange[3]); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 38 | int horizontalIntersect(const Cubic& cubic, double left, double right, double y, |
| 39 | bool flipped, Intersections&); |
| 40 | int horizontalIntersect(const _Line& line, double left, double right, |
| 41 | double y, bool flipped, Intersections& ); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame] | 42 | int horizontalIntersect(const Quadratic& quad, double left, double right, |
| 43 | double y, double tRange[2]); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 44 | int horizontalIntersect(const Quadratic& quad, double left, double right, |
| 45 | double y, bool flipped, Intersections& ); |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 46 | bool intersect(const Cubic& cubic1, const Cubic& cubic2, Intersections& ); |
| 47 | int intersect(const Cubic& cubic, const _Line& line, double cRange[3], double lRange[3]); |
| 48 | bool intersect(const Quadratic& q1, const Quadratic& q2, Intersections& ); |
| 49 | bool intersect(const Quadratic& quad, const _Line& line, Intersections& ); |
caryclark@google.com | 15fa138 | 2012-05-07 20:49:36 +0000 | [diff] [blame] | 50 | bool isLinear(const Quadratic& quad, int startIndex, int endIndex); |
| 51 | bool isLinear(const Cubic& cubic, int startIndex, int endIndex); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 52 | double leftMostT(const Cubic& , double startT, double endT); |
| 53 | double leftMostT(const _Line& , double startT, double endT); |
| 54 | double leftMostT(const Quadratic& , double startT, double endT); |
| 55 | int verticalIntersect(const Cubic& cubic, double top, double bottom, double x, |
| 56 | bool flipped, Intersections& ); |
| 57 | int verticalIntersect(const _Line& line, double top, double bottom, double x, |
| 58 | bool flipped, Intersections& ); |
| 59 | int verticalIntersect(const Quadratic& quad, double top, double bottom, |
| 60 | double x, bool flipped, Intersections& ); |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame] | 61 | |
| 62 | #endif |