caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 1 | #include "CubicIntersection.h" |
| 2 | #include "CubicIntersection_Tests.h" |
| 3 | #include "TestUtilities.h" |
| 4 | |
| 5 | const Quadratic quadratics[] = { |
| 6 | {{0, 0}, {1, 0}, {1, 1}}, |
| 7 | }; |
| 8 | |
| 9 | const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]); |
| 10 | |
| 11 | int firstCubicCoincidenceTest = 0; |
| 12 | |
| 13 | void CubicCoincidence_Test() { |
| 14 | // split large quadratic |
| 15 | // upscale quadratics to cubics |
| 16 | // compare original, parts, to see if the are coincident |
| 17 | for (size_t index = firstCubicCoincidenceTest; index < quadratics_count; ++index) { |
| 18 | const Quadratic& test = quadratics[index]; |
| 19 | QuadraticPair split; |
| 20 | chop_at(test, split, 0.5); |
| 21 | Quadratic midThird; |
| 22 | sub_divide(test, 1.0/3, 2.0/3, midThird); |
| 23 | Cubic whole, first, second, mid; |
| 24 | quad_to_cubic(test, whole); |
| 25 | quad_to_cubic(split.first(), first); |
| 26 | quad_to_cubic(split.second(), second); |
| 27 | quad_to_cubic(midThird, mid); |
| 28 | if (!implicit_matches(whole, first)) { |
| 29 | printf("%s-1 %d\n", __FUNCTION__, (int)index); |
| 30 | } |
| 31 | if (!implicit_matches(whole, second)) { |
| 32 | printf("%s-2 %d\n", __FUNCTION__, (int)index); |
| 33 | } |
| 34 | if (!implicit_matches(mid, first)) { |
| 35 | printf("%s-3 %d\n", __FUNCTION__, (int)index); |
| 36 | } |
| 37 | if (!implicit_matches(mid, second)) { |
| 38 | printf("%s-4 %d\n", __FUNCTION__, (int)index); |
| 39 | } |
| 40 | if (!implicit_matches(first, second)) { |
| 41 | printf("%s-5 %d\n", __FUNCTION__, (int)index); |
| 42 | } |
| 43 | } |
| 44 | } |