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" |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame] | 9 | #include "Parameterization_Test.h" |
caryclark@google.com | 9d5f99b | 2013-01-22 12:55:54 +0000 | [diff] [blame] | 10 | #include "QuadraticUtilities.h" |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 11 | |
| 12 | const Quadratic quadratics[] = { |
| 13 | {{0, 0}, {1, 0}, {1, 1}}, |
| 14 | }; |
| 15 | |
| 16 | const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]); |
| 17 | |
| 18 | int firstQuadraticCoincidenceTest = 0; |
| 19 | |
| 20 | void QuadraticCoincidence_Test() { |
| 21 | // split large quadratic |
| 22 | // compare original, parts, to see if the are coincident |
| 23 | for (size_t index = firstQuadraticCoincidenceTest; index < quadratics_count; ++index) { |
| 24 | const Quadratic& test = quadratics[index]; |
| 25 | QuadraticPair split; |
| 26 | chop_at(test, split, 0.5); |
| 27 | Quadratic midThird; |
| 28 | sub_divide(test, 1.0/3, 2.0/3, midThird); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 29 | const Quadratic* quads[] = { |
| 30 | &test, &midThird, &split.first(), &split.second() |
| 31 | }; |
| 32 | size_t quadsCount = sizeof(quads) / sizeof(quads[0]); |
| 33 | for (size_t one = 0; one < quadsCount; ++one) { |
| 34 | for (size_t two = 0; two < quadsCount; ++two) { |
| 35 | for (size_t inner = 0; inner < 3; inner += 2) { |
| 36 | if (!point_on_parameterized_curve(*quads[one], (*quads[two])[inner])) { |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 37 | SkDebugf("%s %zu [%zu,%zu] %zu parameterization failed\n", |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 38 | __FUNCTION__, index, one, two, inner); |
| 39 | } |
| 40 | } |
| 41 | if (!implicit_matches(*quads[one], *quads[two])) { |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 42 | SkDebugf("%s %zu [%zu,%zu] coincidence failed\n", __FUNCTION__, |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 43 | index, one, two); |
| 44 | } |
| 45 | } |
caryclark@google.com | 639df89 | 2012-01-10 21:46:10 +0000 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | } |