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

Side by Side Diff: src/pathops/SkQuarticRoot.cpp

Issue 23542056: path ops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: verbose + mutex around file number access Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathWriter.cpp ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c 1 // from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c
2 /* 2 /*
3 * Roots3And4.c 3 * Roots3And4.c
4 * 4 *
5 * Utility functions to find cubic and quartic roots, 5 * Utility functions to find cubic and quartic roots,
6 * coefficients are passed like this: 6 * coefficients are passed like this:
7 * 7 *
8 * c[0] + c[1]*x + c[2]*x^2 + c[3]*x^3 + c[4]*x^4 = 0 8 * c[0] + c[1]*x + c[2]*x^2 + c[3]*x^3 + c[4]*x^4 = 0
9 * 9 *
10 * The functions return the number of non-complex roots and 10 * The functions return the number of non-complex roots and
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 } 146 }
147 /* resubstitute */ 147 /* resubstitute */
148 const double sub = a / 4; 148 const double sub = a / 4;
149 for (int i = 0; i < num; ++i) { 149 for (int i = 0; i < num; ++i) {
150 s[i] -= sub; 150 s[i] -= sub;
151 } 151 }
152 // eliminate duplicates 152 // eliminate duplicates
153 for (int i = 0; i < num - 1; ++i) { 153 for (int i = 0; i < num - 1; ++i) {
154 for (int j = i + 1; j < num; ) { 154 for (int j = i + 1; j < num; ) {
155 if (AlmostEqualUlps(s[i], s[j])) { 155 if (AlmostDequalUlps(s[i], s[j])) {
156 if (j < --num) { 156 if (j < --num) {
157 s[j] = s[num]; 157 s[j] = s[num];
158 } 158 }
159 } else { 159 } else {
160 ++j; 160 ++j;
161 } 161 }
162 } 162 }
163 } 163 }
164 return num; 164 return num;
165 } 165 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathWriter.cpp ('k') | tests/PathOpsCubicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698