blob: eedd6a45bf22ae69ecbbb3ba1ef9af064faabd8a [file] [log] [blame]
caryclark@google.com9e49fb62012-08-27 14:11:33 +00001/*
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.comc6825902012-02-03 22:07:47 +00007#include "CurveIntersection.h"
caryclark@google.com27accef2012-01-25 18:57:23 +00008#include "Intersection_Tests.h"
caryclark@google.comc6825902012-02-03 22:07:47 +00009#include "Parameterization_Test.h"
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000010#include "QuadraticUtilities.h"
caryclark@google.com639df892012-01-10 21:46:10 +000011
12const Quadratic quadratics[] = {
13 {{0, 0}, {1, 0}, {1, 1}},
14};
15
16const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]);
17
18int firstQuadraticCoincidenceTest = 0;
19
20void 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.com27accef2012-01-25 18:57:23 +000029 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.comaa358312013-01-29 20:28:49 +000037 SkDebugf("%s %zu [%zu,%zu] %zu parameterization failed\n",
caryclark@google.com27accef2012-01-25 18:57:23 +000038 __FUNCTION__, index, one, two, inner);
39 }
40 }
41 if (!implicit_matches(*quads[one], *quads[two])) {
caryclark@google.comaa358312013-01-29 20:28:49 +000042 SkDebugf("%s %zu [%zu,%zu] coincidence failed\n", __FUNCTION__,
caryclark@google.com27accef2012-01-25 18:57:23 +000043 index, one, two);
44 }
45 }
caryclark@google.com639df892012-01-10 21:46:10 +000046 }
47 }
48}