caryclark@google.com | 9e49fb6 | 2012-08-27 14:11:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 7 | #include "CurveIntersection.h" |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 8 | #include "Intersection_Tests.h" |
| 9 | #include "QuadraticIntersection_TestData.h" |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 10 | |
caryclark@google.com | b45a1b4 | 2012-05-18 20:50:33 +0000 | [diff] [blame] | 11 | static const Quadratic testSet[] = { |
| 12 | {{8.0000000000000071, 8.0000000000000071}, |
| 13 | {8.7289570079366854, 8.7289570079366889}, |
| 14 | {9.3914917259458743, 9.0593802763083691}}, |
| 15 | {{8.0000000000000142, 8.0000000000000142}, |
| 16 | {8.1250000000000107, 8.1250000000000071}, |
| 17 | {8.2500000000000071, 8.2187500000000053}} |
| 18 | }; |
| 19 | |
| 20 | static void oneOffTest() { |
| 21 | const Quadratic& quad1 = testSet[0]; |
| 22 | const Quadratic& quad2 = testSet[1]; |
| 23 | double minT = 0; |
| 24 | double maxT = 1; |
| 25 | bezier_clip(quad1, quad2, minT, maxT); |
| 26 | } |
| 27 | |
caryclark@google.com | a3f05fa | 2012-06-01 17:44:28 +0000 | [diff] [blame] | 28 | static void standardTestCases() { |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 29 | for (size_t index = 0; index < quadraticTests_count; ++index) { |
| 30 | const Quadratic& quad1 = quadraticTests[index][0]; |
| 31 | const Quadratic& quad2 = quadraticTests[index][1]; |
| 32 | Quadratic reduce1, reduce2; |
| 33 | int order1 = reduceOrder(quad1, reduce1); |
| 34 | int order2 = reduceOrder(quad2, reduce2); |
| 35 | if (order1 < 3) { |
| 36 | printf("%s [%d] quad1 order=%d\n", __FUNCTION__, (int)index, order1); |
| 37 | } |
| 38 | if (order2 < 3) { |
| 39 | printf("%s [%d] quad2 order=%d\n", __FUNCTION__, (int)index, order2); |
| 40 | } |
| 41 | if (order1 == 3 && order2 == 3) { |
| 42 | double minT = 0; |
| 43 | double maxT = 1; |
| 44 | bezier_clip(reduce1, reduce2, minT, maxT); |
| 45 | } |
| 46 | } |
| 47 | } |
caryclark@google.com | b45a1b4 | 2012-05-18 20:50:33 +0000 | [diff] [blame] | 48 | |
| 49 | void QuadraticBezierClip_Test() { |
| 50 | oneOffTest(); |
| 51 | standardTestCases(); |
| 52 | } |