caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame^] | 1 | #ifndef CubicIntersection_DEFINE |
| 2 | #define CubicIntersection_DEFINE |
| 3 | |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 4 | #include "DataTypes.h" |
| 5 | |
| 6 | class Intersections; |
| 7 | |
| 8 | // unit-testable utilities |
| 9 | bool bezier_clip(const Cubic& cubic1, const Cubic& cubic2, double& minT, double& maxT); |
| 10 | bool bezier_clip(const Quadratic& q1, const Quadratic& q2, double& minT, double& maxT); |
| 11 | void chop_at(const Cubic& src, CubicPair& dst, double t); |
| 12 | void chop_at(const Quadratic& src, QuadraticPair& dst, double t); |
| 13 | int convex_hull(const Cubic& cubic, char order[4]); |
| 14 | bool convex_x_hull(const Cubic& cubic, char connectTo0[2], char connectTo3[2]); |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 15 | bool implicit_matches(const Cubic& cubic1, const Cubic& cubic2); |
| 16 | bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2); |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 17 | void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst); |
| 18 | void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst); |
| 19 | void tangent(const Cubic& cubic, double t, _Point& result); |
| 20 | void tangent(const Quadratic& cubic, double t, _Point& result); |
| 21 | |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 22 | // utilities used only for unit testing |
| 23 | bool point_on_parameterized_curve(const Cubic& cubic, const _Point& point); |
| 24 | bool point_on_parameterized_curve(const Quadratic& quad, const _Point& point); |
| 25 | |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 26 | // main functions |
| 27 | enum ReduceOrder_Flags { |
| 28 | kReduceOrder_NoQuadraticsAllowed, |
| 29 | kReduceOrder_QuadraticsAllowed |
| 30 | }; |
| 31 | int reduceOrder(const Cubic& cubic, Cubic& reduction, ReduceOrder_Flags ); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 32 | int reduceOrder(const _Line& line, _Line& reduction); |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 33 | int reduceOrder(const Quadratic& quad, Quadratic& reduction); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 34 | //bool intersectStart(const Cubic& cubic1, const Cubic& cubic2, Intersections& ); |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 35 | bool intersectStartT(const Cubic& cubic1, const Cubic& cubic2, Intersections& ); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 36 | bool intersectStart(const Cubic& cubic, const _Line& line, Intersections& ); |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 37 | bool intersectStart(const Quadratic& q1, const Quadratic& q2, Intersections& ); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 38 | bool intersectStart(const Quadratic& quad, const _Line& line, Intersections& ); |
caryclark@google.com | d88e089 | 2012-03-27 13:23:51 +0000 | [diff] [blame^] | 39 | |
| 40 | #endif |