caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 1 | #include "CurveIntersection.h" |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 2 | #include "Intersection_Tests.h" |
| 3 | #include "QuadraticIntersection_TestData.h" |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 4 | |
caryclark@google.com | b45a1b4 | 2012-05-18 20:50:33 +0000 | [diff] [blame] | 5 | static 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 | |
| 14 | static 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.com | a3f05fa | 2012-06-01 17:44:28 +0000 | [diff] [blame^] | 22 | static void standardTestCases() { |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 23 | 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.com | b45a1b4 | 2012-05-18 20:50:33 +0000 | [diff] [blame] | 42 | |
| 43 | void QuadraticBezierClip_Test() { |
| 44 | oneOffTest(); |
| 45 | standardTestCases(); |
| 46 | } |