Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: experimental/Intersection/LineParameteters_Test.cpp

Issue 867213004: remove prototype pathops code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 */
7 #include "Intersection_Tests.h"
8 #include "LineParameters.h"
9
10
11 // tests to verify that distance calculations are coded correctly
12 const Cubic tests[] = {
13 {{0, 0}, {1, 1}, {2, 2}, {0, 3}},
14 {{0, 0}, {1, 1}, {2, 2}, {3, 0}},
15 {{0, 0}, {5, 0}, {-2,4}, {3, 4}},
16 {{0, 2}, {1, 0}, {2, 0}, {3, 0}},
17 {{0, .2}, {1, 0}, {2, 0}, {3, 0}},
18 {{0, .02}, {1, 0}, {2, 0}, {3, 0}},
19 {{0, .002}, {1, 0}, {2, 0}, {3, 0}},
20 {{0, .0002}, {1, 0}, {2, 0}, {3, 0}},
21 {{0, .00002}, {1, 0}, {2, 0}, {3, 0}},
22 {{0, PointEpsilon * 2}, {1, 0}, {2, 0}, {3, 0}},
23 };
24
25 const double answers[][2] = {
26 {1, 2},
27 {1, 2},
28 {4, 4},
29 {1.1094003924, 0.5547001962},
30 {0.133038021, 0.06651901052},
31 {0.0133330370, 0.006666518523},
32 {0.001333333037, 0.0006666665185},
33 {0.000133333333, 6.666666652e-05},
34 {1.333333333e-05, 6.666666667e-06},
35 {1.333333333e-06, 6.666666667e-07},
36 };
37
38 const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
39
40 static size_t firstLineParameterTest = 0;
41
42 void LineParameter_Test() {
43 for (size_t index = firstLineParameterTest; index < tests_count; ++index) {
44 LineParameters lineParameters;
45 const Cubic& cubic = tests[index];
46 lineParameters.cubicEndPoints(cubic);
47 double denormalizedDistance[2];
48 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1);
49 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2);
50 double normalSquared = lineParameters.normalSquared();
51 size_t inner;
52 for (inner = 0; inner < 2; ++inner) {
53 double distSq = denormalizedDistance[inner];
54 distSq *= distSq;
55 double answersSq = answers[index][inner];
56 answersSq *= answersSq;
57 if (AlmostEqualUlps(distSq, normalSquared * answersSq)) {
58 continue;
59 }
60 SkDebugf("%s [%d,%d] denormalizedDistance:%g != answer:%g"
61 " distSq:%g answerSq:%g normalSquared:%g\n",
62 __FUNCTION__, (int)index, (int)inner,
63 denormalizedDistance[inner], answers[index][inner],
64 distSq, answersSq, normalSquared);
65 }
66 lineParameters.normalize();
67 double normalizedDistance[2];
68 normalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1);
69 normalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2);
70 for (inner = 0; inner < 2; ++inner) {
71 if (AlmostEqualUlps(fabs(normalizedDistance[inner]), answers[index][ inner])) {
72 continue;
73 }
74 SkDebugf("%s [%d,%d] normalizedDistance:%1.10g != answer:%g\n",
75 __FUNCTION__, (int)index, (int)inner,
76 normalizedDistance[inner], answers[index][inner]);
77 }
78 }
79 }
OLDNEW
« no previous file with comments | « experimental/Intersection/LineParameters.h ('k') | experimental/Intersection/LineQuadraticIntersection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698