blob: b918400d88f238bfb4b0b9069cbccb3b8f56ebf9 [file] [log] [blame]
caryclark@google.comd88e0892012-03-27 13:23:51 +00001#ifndef CubicIntersection_DEFINE
2#define CubicIntersection_DEFINE
3
caryclark@google.com639df892012-01-10 21:46:10 +00004#include "DataTypes.h"
5
6class Intersections;
7
8// unit-testable utilities
9bool bezier_clip(const Cubic& cubic1, const Cubic& cubic2, double& minT, double& maxT);
10bool bezier_clip(const Quadratic& q1, const Quadratic& q2, double& minT, double& maxT);
11void chop_at(const Cubic& src, CubicPair& dst, double t);
12void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
13int convex_hull(const Cubic& cubic, char order[4]);
14bool convex_x_hull(const Cubic& cubic, char connectTo0[2], char connectTo3[2]);
caryclark@google.com639df892012-01-10 21:46:10 +000015bool implicit_matches(const Cubic& cubic1, const Cubic& cubic2);
16bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2);
caryclark@google.com639df892012-01-10 21:46:10 +000017void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
18void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
19void tangent(const Cubic& cubic, double t, _Point& result);
20void tangent(const Quadratic& cubic, double t, _Point& result);
21
caryclark@google.com27accef2012-01-25 18:57:23 +000022// utilities used only for unit testing
23bool point_on_parameterized_curve(const Cubic& cubic, const _Point& point);
24bool point_on_parameterized_curve(const Quadratic& quad, const _Point& point);
25
caryclark@google.com639df892012-01-10 21:46:10 +000026// main functions
27enum ReduceOrder_Flags {
28 kReduceOrder_NoQuadraticsAllowed,
29 kReduceOrder_QuadraticsAllowed
30};
31int reduceOrder(const Cubic& cubic, Cubic& reduction, ReduceOrder_Flags );
caryclark@google.com27accef2012-01-25 18:57:23 +000032int reduceOrder(const _Line& line, _Line& reduction);
caryclark@google.com639df892012-01-10 21:46:10 +000033int reduceOrder(const Quadratic& quad, Quadratic& reduction);
caryclark@google.com27accef2012-01-25 18:57:23 +000034//bool intersectStart(const Cubic& cubic1, const Cubic& cubic2, Intersections& );
caryclark@google.com639df892012-01-10 21:46:10 +000035bool intersectStartT(const Cubic& cubic1, const Cubic& cubic2, Intersections& );
caryclark@google.com27accef2012-01-25 18:57:23 +000036bool intersectStart(const Cubic& cubic, const _Line& line, Intersections& );
caryclark@google.com639df892012-01-10 21:46:10 +000037bool intersectStart(const Quadratic& q1, const Quadratic& q2, Intersections& );
caryclark@google.com27accef2012-01-25 18:57:23 +000038bool intersectStart(const Quadratic& quad, const _Line& line, Intersections& );
caryclark@google.comd88e0892012-03-27 13:23:51 +000039
40#endif