blob: a3d14ce44dd63bb80287a5fc666140f5cd920602 [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"
9#include "QuadraticIntersection_TestData.h"
caryclark@google.com639df892012-01-10 21:46:10 +000010
caryclark@google.comb45a1b42012-05-18 20:50:33 +000011static const Quadratic testSet[] = {
12 {{8.0000000000000071, 8.0000000000000071},
13 {8.7289570079366854, 8.7289570079366889},
14 {9.3914917259458743, 9.0593802763083691}},
15 {{8.0000000000000142, 8.0000000000000142},
16 {8.1250000000000107, 8.1250000000000071},
17 {8.2500000000000071, 8.2187500000000053}}
18};
19
20static void oneOffTest() {
21 const Quadratic& quad1 = testSet[0];
22 const Quadratic& quad2 = testSet[1];
23 double minT = 0;
24 double maxT = 1;
25 bezier_clip(quad1, quad2, minT, maxT);
26}
27
caryclark@google.coma3f05fa2012-06-01 17:44:28 +000028static void standardTestCases() {
caryclark@google.com27accef2012-01-25 18:57:23 +000029 for (size_t index = 0; index < quadraticTests_count; ++index) {
30 const Quadratic& quad1 = quadraticTests[index][0];
31 const Quadratic& quad2 = quadraticTests[index][1];
32 Quadratic reduce1, reduce2;
33 int order1 = reduceOrder(quad1, reduce1);
34 int order2 = reduceOrder(quad2, reduce2);
35 if (order1 < 3) {
36 printf("%s [%d] quad1 order=%d\n", __FUNCTION__, (int)index, order1);
37 }
38 if (order2 < 3) {
39 printf("%s [%d] quad2 order=%d\n", __FUNCTION__, (int)index, order2);
40 }
41 if (order1 == 3 && order2 == 3) {
42 double minT = 0;
43 double maxT = 1;
44 bezier_clip(reduce1, reduce2, minT, maxT);
45 }
46 }
47}
caryclark@google.comb45a1b42012-05-18 20:50:33 +000048
49void QuadraticBezierClip_Test() {
50 oneOffTest();
51 standardTestCases();
52}