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 "Intersections.h" |
| 4 | #include "QuadraticIntersection_TestData.h" |
| 5 | #include "TestUtilities.h" |
| 6 | |
| 7 | const int firstQuadIntersectionTest = 9; |
| 8 | |
| 9 | void QuadraticIntersection_Test() { |
| 10 | for (size_t index = firstQuadIntersectionTest; index < quadraticTests_count; ++index) { |
| 11 | const Quadratic& quad1 = quadraticTests[index][0]; |
| 12 | const Quadratic& quad2 = quadraticTests[index][1]; |
| 13 | Quadratic reduce1, reduce2; |
| 14 | int order1 = reduceOrder(quad1, reduce1); |
| 15 | int order2 = reduceOrder(quad2, reduce2); |
| 16 | if (order1 < 3) { |
| 17 | printf("[%d] quad1 order=%d\n", (int) index, order1); |
| 18 | } |
| 19 | if (order2 < 3) { |
| 20 | printf("[%d] quad2 order=%d\n", (int) index, order2); |
| 21 | } |
| 22 | if (order1 == 3 && order2 == 3) { |
| 23 | Intersections intersections; |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame^] | 24 | intersect(reduce1, reduce2, intersections); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 25 | if (intersections.intersected()) { |
| 26 | for (int pt = 0; pt < intersections.used(); ++pt) { |
| 27 | double tt1 = intersections.fT[0][pt]; |
| 28 | double tx1, ty1; |
| 29 | xy_at_t(quad1, tt1, tx1, ty1); |
| 30 | double tt2 = intersections.fT[1][pt]; |
| 31 | double tx2, ty2; |
| 32 | xy_at_t(quad2, tt2, tx2, ty2); |
| 33 | if (!approximately_equal(tx1, tx2)) { |
| 34 | printf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", |
| 35 | __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2); |
| 36 | } |
| 37 | if (!approximately_equal(ty1, ty2)) { |
| 38 | printf("%s [%d,%d] y!= t1=%g (%g,%g) t2=%g (%g,%g)\n", |
| 39 | __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |