blob: df239dc4b23facb47ee7e9eac72406ae85b42679 [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.com639df892012-01-10 21:46:10 +000010
11const Quadratic quadratics[] = {
12 {{0, 0}, {1, 0}, {1, 1}},
13};
14
15const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]);
16
17int firstQuadraticCoincidenceTest = 0;
18
19void QuadraticCoincidence_Test() {
20 // split large quadratic
21 // compare original, parts, to see if the are coincident
22 for (size_t index = firstQuadraticCoincidenceTest; index < quadratics_count; ++index) {
23 const Quadratic& test = quadratics[index];
24 QuadraticPair split;
25 chop_at(test, split, 0.5);
26 Quadratic midThird;
27 sub_divide(test, 1.0/3, 2.0/3, midThird);
caryclark@google.com27accef2012-01-25 18:57:23 +000028 const Quadratic* quads[] = {
29 &test, &midThird, &split.first(), &split.second()
30 };
31 size_t quadsCount = sizeof(quads) / sizeof(quads[0]);
32 for (size_t one = 0; one < quadsCount; ++one) {
33 for (size_t two = 0; two < quadsCount; ++two) {
34 for (size_t inner = 0; inner < 3; inner += 2) {
35 if (!point_on_parameterized_curve(*quads[one], (*quads[two])[inner])) {
rmistry@google.comd6176b02012-08-23 18:14:13 +000036 printf("%s %zu [%zu,%zu] %zu parameterization failed\n",
caryclark@google.com27accef2012-01-25 18:57:23 +000037 __FUNCTION__, index, one, two, inner);
38 }
39 }
40 if (!implicit_matches(*quads[one], *quads[two])) {
41 printf("%s %zu [%zu,%zu] coincidence failed\n", __FUNCTION__,
42 index, one, two);
43 }
44 }
caryclark@google.com639df892012-01-10 21:46:10 +000045 }
46 }
47}