blob: c42cfc6b0bce045c9b90e7e9714522cf2d409869 [file] [log] [blame]
caryclark@google.comc6825902012-02-03 22:07:47 +00001#include "CurveIntersection.h"
caryclark@google.com27accef2012-01-25 18:57:23 +00002#include "Intersection_Tests.h"
3#include "QuadraticIntersection_TestData.h"
caryclark@google.com639df892012-01-10 21:46:10 +00004
caryclark@google.comb45a1b42012-05-18 20:50:33 +00005static const Quadratic testSet[] = {
6 {{8.0000000000000071, 8.0000000000000071},
7 {8.7289570079366854, 8.7289570079366889},
8 {9.3914917259458743, 9.0593802763083691}},
9 {{8.0000000000000142, 8.0000000000000142},
10 {8.1250000000000107, 8.1250000000000071},
11 {8.2500000000000071, 8.2187500000000053}}
12};
13
14static void oneOffTest() {
15 const Quadratic& quad1 = testSet[0];
16 const Quadratic& quad2 = testSet[1];
17 double minT = 0;
18 double maxT = 1;
19 bezier_clip(quad1, quad2, minT, maxT);
20}
21
caryclark@google.coma3f05fa2012-06-01 17:44:28 +000022static void standardTestCases() {
caryclark@google.com27accef2012-01-25 18:57:23 +000023 for (size_t index = 0; index < quadraticTests_count; ++index) {
24 const Quadratic& quad1 = quadraticTests[index][0];
25 const Quadratic& quad2 = quadraticTests[index][1];
26 Quadratic reduce1, reduce2;
27 int order1 = reduceOrder(quad1, reduce1);
28 int order2 = reduceOrder(quad2, reduce2);
29 if (order1 < 3) {
30 printf("%s [%d] quad1 order=%d\n", __FUNCTION__, (int)index, order1);
31 }
32 if (order2 < 3) {
33 printf("%s [%d] quad2 order=%d\n", __FUNCTION__, (int)index, order2);
34 }
35 if (order1 == 3 && order2 == 3) {
36 double minT = 0;
37 double maxT = 1;
38 bezier_clip(reduce1, reduce2, minT, maxT);
39 }
40 }
41}
caryclark@google.comb45a1b42012-05-18 20:50:33 +000042
43void QuadraticBezierClip_Test() {
44 oneOffTest();
45 standardTestCases();
46}