blob: 94d86ea7600a06e1c548382518f0a6379d680a60 [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.com8dcf1142012-07-02 20:27:02 +00008#include "CurveUtilities.h"
caryclark@google.com639df892012-01-10 21:46:10 +00009#include "CubicIntersection_TestData.h"
caryclark@google.com27accef2012-01-25 18:57:23 +000010#include "Intersection_Tests.h"
caryclark@google.com639df892012-01-10 21:46:10 +000011#include "Intersections.h"
12#include "TestUtilities.h"
13
14const int firstCubicIntersectionTest = 9;
15
16void CubicIntersection_Test() {
17 for (size_t index = firstCubicIntersectionTest; index < tests_count; ++index) {
18 const Cubic& cubic1 = tests[index][0];
19 const Cubic& cubic2 = tests[index][1];
20 Cubic reduce1, reduce2;
21 int order1 = reduceOrder(cubic1, reduce1, kReduceOrder_NoQuadraticsAllowed);
22 int order2 = reduceOrder(cubic2, reduce2, kReduceOrder_NoQuadraticsAllowed);
23 if (order1 < 4) {
caryclark@google.com27accef2012-01-25 18:57:23 +000024 printf("%s [%d] cubic1 order=%d\n", __FUNCTION__, (int) index, order1);
25 continue;
caryclark@google.com639df892012-01-10 21:46:10 +000026 }
27 if (order2 < 4) {
caryclark@google.com27accef2012-01-25 18:57:23 +000028 printf("%s [%d] cubic2 order=%d\n", __FUNCTION__, (int) index, order2);
29 continue;
caryclark@google.com639df892012-01-10 21:46:10 +000030 }
caryclark@google.com27accef2012-01-25 18:57:23 +000031 if (implicit_matches(reduce1, reduce2)) {
32 printf("%s [%d] coincident\n", __FUNCTION__, (int) index);
33 continue;
34 }
35 Intersections tIntersections;
caryclark@google.comc6825902012-02-03 22:07:47 +000036 intersect(reduce1, reduce2, tIntersections);
caryclark@google.com27accef2012-01-25 18:57:23 +000037 if (!tIntersections.intersected()) {
38 printf("%s [%d] no intersection\n", __FUNCTION__, (int) index);
39 continue;
40 }
41 for (int pt = 0; pt < tIntersections.used(); ++pt) {
42 double tt1 = tIntersections.fT[0][pt];
43 double tx1, ty1;
44 xy_at_t(cubic1, tt1, tx1, ty1);
45 double tt2 = tIntersections.fT[1][pt];
46 double tx2, ty2;
47 xy_at_t(cubic2, tt2, tx2, ty2);
caryclark@google.com6d0032a2013-01-04 19:41:13 +000048 if (!AlmostEqualUlps(tx1, tx2)) {
caryclark@google.com27accef2012-01-25 18:57:23 +000049 printf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
50 __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2);
51 }
caryclark@google.com6d0032a2013-01-04 19:41:13 +000052 if (!AlmostEqualUlps(ty1, ty2)) {
caryclark@google.com27accef2012-01-25 18:57:23 +000053 printf("%s [%d,%d] y!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
54 __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2);
caryclark@google.com639df892012-01-10 21:46:10 +000055 }
56 }
57 }
58}
caryclark@google.com73ca6242013-01-17 21:02:47 +000059
caryclark@google.com9f602912013-01-24 21:47:16 +000060#define ONE_OFF_DEBUG 1
61
caryclark@google.com73ca6242013-01-17 21:02:47 +000062static void oneOff(const Cubic& cubic1, const Cubic& cubic2) {
63 SkTDArray<Quadratic> quads1;
64 cubic_to_quadratics(cubic1, calcPrecision(cubic1), quads1);
caryclark@google.com9f602912013-01-24 21:47:16 +000065#if ONE_OFF_DEBUG
caryclark@google.com73ca6242013-01-17 21:02:47 +000066 for (int index = 0; index < quads1.count(); ++index) {
67 const Quadratic& q = quads1[index];
caryclark@google.com9f602912013-01-24 21:47:16 +000068 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].x, q[0].y,
caryclark@google.com73ca6242013-01-17 21:02:47 +000069 q[1].x, q[1].y, q[2].x, q[2].y);
70 }
71 SkDebugf("\n");
caryclark@google.com9f602912013-01-24 21:47:16 +000072#endif
caryclark@google.com73ca6242013-01-17 21:02:47 +000073 SkTDArray<Quadratic> quads2;
74 cubic_to_quadratics(cubic2, calcPrecision(cubic2), quads2);
caryclark@google.com9f602912013-01-24 21:47:16 +000075#if ONE_OFF_DEBUG
caryclark@google.com73ca6242013-01-17 21:02:47 +000076 for (int index = 0; index < quads2.count(); ++index) {
77 const Quadratic& q = quads2[index];
caryclark@google.com9f602912013-01-24 21:47:16 +000078 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].x, q[0].y,
caryclark@google.com73ca6242013-01-17 21:02:47 +000079 q[1].x, q[1].y, q[2].x, q[2].y);
80 }
81 SkDebugf("\n");
caryclark@google.com9f602912013-01-24 21:47:16 +000082#endif
caryclark@google.com73ca6242013-01-17 21:02:47 +000083 Intersections intersections2;
84 intersect2(cubic1, cubic2, intersections2);
85 for (int pt = 0; pt < intersections2.used(); ++pt) {
86 double tt1 = intersections2.fT[0][pt];
caryclark@google.com05c4bad2013-01-19 13:22:39 +000087 _Point xy1, xy2;
88 xy_at_t(cubic1, tt1, xy1.x, xy1.y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000089 int pt2 = intersections2.fFlip ? intersections2.used() - pt - 1 : pt;
90 double tt2 = intersections2.fT[1][pt2];
caryclark@google.com05c4bad2013-01-19 13:22:39 +000091 xy_at_t(cubic2, tt2, xy2.x, xy2.y);
caryclark@google.com9f602912013-01-24 21:47:16 +000092#if ONE_OFF_DEBUG
caryclark@google.com73ca6242013-01-17 21:02:47 +000093 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1.9g\n", __FUNCTION__,
caryclark@google.com05c4bad2013-01-19 13:22:39 +000094 tt1, xy1.x, xy1.y, xy2.x, xy2.y, tt2);
caryclark@google.com9f602912013-01-24 21:47:16 +000095#endif
caryclark@google.com05c4bad2013-01-19 13:22:39 +000096 assert(xy1.approximatelyEqual(xy2));
caryclark@google.com73ca6242013-01-17 21:02:47 +000097 }
98}
99
100static const Cubic testSet[] = {
caryclark@google.com85ec74c2013-01-28 19:25:51 +0000101{{0, 0}, {0, 1}, {1, 1}, {1, 0}},
102{{1, 0}, {0, 0}, {0, 1}, {1, 1}},
103
104{{95.837747722788592, 45.025976907939643}, {16.564570095652982, 0.72959763963222402}, {63.209855865319199, 68.047528419665767}, {57.640240647662544, 59.524565264361243}},
105{{51.593891741518817, 38.53849970667553}, {62.34752929878772, 74.924924725166022}, {74.810149322641152, 34.17966562983564}, {29.368398119401373, 94.66719277886078}},
106
107{{39.765160968417838, 33.060396198677083}, {5.1922921581157908, 66.854301452103215}, {31.619281802149157, 25.269248720849514}, {81.541621071073038, 70.025341524754353}},
108{{46.078911165743556, 48.259962651999651}, {20.24450549867214, 49.403916182650214}, {0.26325131778756683, 24.46489805563581}, {15.915006546264051, 83.515023059917155}},
109
caryclark@google.com9f602912013-01-24 21:47:16 +0000110{{65.454505973241524, 93.881892270353575}, {45.867360264932437, 92.723972719499827}, {2.1464054482739447, 74.636369140183717}, {33.774068594804994, 40.770872887582925}},
111{{72.963387832494163, 95.659300729473728}, {11.809496633619768, 82.209921247423594}, {13.456139067865974, 57.329313623406605}, {36.060621606214262, 70.867335643091849}},
112
113{{32.484981432782945, 75.082940782924624}, {42.467313093350882, 48.131159948246157}, {3.5963115764764657, 43.208665839959245}, {79.442476890721579, 89.709102357602262}},
114{{18.98573861410177, 93.308887208490106}, {40.405250173250792, 91.039661826118675}, {8.0467721950480584, 42.100282172719147}, {40.883324221187891, 26.030185504830527}},
115
116{{7.5374809128872498, 82.441702896003477}, {22.444346930107265, 22.138854312775123}, {66.76091829629658, 50.753805856571446}, {78.193478508942519, 97.7932997968948}},
117{{97.700573130371311, 53.53260215070685}, {87.72443481149358, 84.575876772671876}, {19.215031396232092, 47.032676472809484}, {11.989686410869325, 10.659507480757082}},
118
119{{26.192053931854691, 9.8504326817814416}, {10.174241480498686, 98.476562741434464}, {21.177712558385782, 33.814968789841501}, {75.329030899018534, 55.02231980442177}},
120{{56.222082700683771, 24.54395039218662}, {95.589995289030483, 81.050822735322086}, {28.180450866082897, 28.837706255185282}, {60.128952916771617, 87.311672180570511}},
121
122{{42.449716172390481, 52.379709366885805}, {27.896043159019225, 48.797373636065686}, {92.770268299044233, 89.899302036454571}, {12.102066544863426, 99.43241951960718}},
123{{45.77532924980639, 45.958701495993274}, {37.458701356062065, 68.393691335056758}, {37.569326692060258, 27.673713456687381}, {60.674866037757539, 62.47349659096146}},
124
caryclark@google.com73ca6242013-01-17 21:02:47 +0000125{{67.426548091427676, 37.993772624988935}, {23.483695892376684, 90.476863174921306}, {35.597065061143162, 79.872482633158796}, {75.38634169631932, 18.244890038969412}},
126{{61.336508189019057, 82.693132843213675}, {44.639380902349664, 54.074825790745592}, {16.815615499771951, 20.049704667203923}, {41.866884958868326, 56.735503699973002}},
127
128{{67.4265481, 37.9937726}, {23.4836959, 90.4768632}, {35.5970651, 79.8724826}, {75.3863417, 18.24489}},
129{{61.3365082, 82.6931328}, {44.6393809, 54.0748258}, {16.8156155, 20.0497047}, {41.866885, 56.7355037}},
130
131{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, {18.5656052, 32.1268808}},
132{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, {56.4860195, 60.529264}},
133};
134
135const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]);
136
137void CubicIntersection_OneOffTest() {
138 for (size_t outer = 0; outer < testSetCount - 1; ++outer) {
caryclark@google.com9f602912013-01-24 21:47:16 +0000139#if ONE_OFF_DEBUG
caryclark@google.com73ca6242013-01-17 21:02:47 +0000140 SkDebugf("%s quads1[%d]\n", __FUNCTION__, outer);
caryclark@google.com9f602912013-01-24 21:47:16 +0000141#endif
caryclark@google.com73ca6242013-01-17 21:02:47 +0000142 const Cubic& cubic1 = testSet[outer];
143 for (size_t inner = outer + 1; inner < testSetCount; ++inner) {
caryclark@google.com9f602912013-01-24 21:47:16 +0000144#if ONE_OFF_DEBUG
caryclark@google.com73ca6242013-01-17 21:02:47 +0000145 SkDebugf("%s quads2[%d]\n", __FUNCTION__, inner);
caryclark@google.com9f602912013-01-24 21:47:16 +0000146#endif
caryclark@google.com73ca6242013-01-17 21:02:47 +0000147 const Cubic& cubic2 = testSet[inner];
148 oneOff(cubic1, cubic2);
149 }
150 }
151}
152
153#define DEBUG_CRASH 1
154
155class CubicChopper {
156public:
157
158// only finds one intersection
159CubicChopper(const Cubic& c1, const Cubic& c2)
160 : cubic1(c1)
161 , cubic2(c2)
162 , depth(0) {
163}
164
165bool intersect(double minT1, double maxT1, double minT2, double maxT2) {
166 Cubic sub1, sub2;
167 // FIXME: carry last subdivide and reduceOrder result with cubic
168 sub_divide(cubic1, minT1, maxT1, sub1);
169 sub_divide(cubic2, minT2, maxT2, sub2);
170 Intersections i;
171 intersect2(sub1, sub2, i);
172 if (i.used() == 0) {
173 return false;
174 }
175 double x1, y1, x2, y2;
176 t1 = minT1 + i.fT[0][0] * (maxT1 - minT1);
177 t2 = minT2 + i.fT[1][0] * (maxT2 - minT2);
178 xy_at_t(cubic1, t1, x1, y1);
179 xy_at_t(cubic2, t2, x2, y2);
180 if (AlmostEqualUlps(x1, x2) && AlmostEqualUlps(y1, y2)) {
181 return true;
182 }
183 double half1 = (minT1 + maxT1) / 2;
184 double half2 = (minT2 + maxT2) / 2;
185 ++depth;
186 bool result;
187 if (depth & 1) {
188 result = intersect(minT1, half1, minT2, maxT2) || intersect(half1, maxT1, minT2, maxT2)
189 || intersect(minT1, maxT1, minT2, half2) || intersect(minT1, maxT1, half2, maxT2);
190 } else {
191 result = intersect(minT1, maxT1, minT2, half2) || intersect(minT1, maxT1, half2, maxT2)
192 || intersect(minT1, half1, minT2, maxT2) || intersect(half1, maxT1, minT2, maxT2);
193 }
194 --depth;
195 return result;
196}
197
198const Cubic& cubic1;
199const Cubic& cubic2;
200double t1;
201double t2;
202int depth;
203};
204
205#define TRY_OLD 0 // old way fails on test == 1
206
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000207void CubicIntersection_RandTestOld() {
caryclark@google.com73ca6242013-01-17 21:02:47 +0000208 srand(0);
209 const int tests = 1000000; // 10000000;
210 double largestFactor = DBL_MAX;
211 for (int test = 0; test < tests; ++test) {
212 Cubic cubic1, cubic2;
213 for (int i = 0; i < 4; ++i) {
214 cubic1[i].x = (double) rand() / RAND_MAX * 100;
215 cubic1[i].y = (double) rand() / RAND_MAX * 100;
216 cubic2[i].x = (double) rand() / RAND_MAX * 100;
217 cubic2[i].y = (double) rand() / RAND_MAX * 100;
218 }
219 if (test == 2513) { // the pair crosses three times, but the quadratic approximation
220 continue; // only sees one -- should be OK to ignore the other two?
221 }
222 if (test == 12932) { // this exposes a weakness when one cubic touches the other but
223 continue; // does not touch the quad approximation. Captured in qc.htm as cubic15
224 }
225 #if DEBUG_CRASH
226 char str[1024];
227 sprintf(str, "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n"
228 "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n",
229 cubic1[0].x, cubic1[0].y, cubic1[1].x, cubic1[1].y, cubic1[2].x, cubic1[2].y,
230 cubic1[3].x, cubic1[3].y,
231 cubic2[0].x, cubic2[0].y, cubic2[1].x, cubic2[1].y, cubic2[2].x, cubic2[2].y,
232 cubic2[3].x, cubic2[3].y);
233 #endif
234 _Rect rect1, rect2;
235 rect1.setBounds(cubic1);
236 rect2.setBounds(cubic2);
237 bool boundsIntersect = rect1.left <= rect2.right && rect2.left <= rect2.right
238 && rect1.top <= rect2.bottom && rect2.top <= rect1.bottom;
239 Intersections i1, i2;
240 #if TRY_OLD
241 bool oldIntersects = intersect(cubic1, cubic2, i1);
242 #else
243 bool oldIntersects = false;
244 #endif
245 if (test == -1) {
246 SkDebugf("ready...\n");
247 }
248 bool newIntersects = intersect2(cubic1, cubic2, i2);
249 if (!boundsIntersect && (oldIntersects || newIntersects)) {
250 SkDebugf("%s %d unexpected intersection boundsIntersect=%d oldIntersects=%d"
251 " newIntersects=%d\n%s %s\n", __FUNCTION__, test, boundsIntersect,
252 oldIntersects, newIntersects, __FUNCTION__, str);
253 assert(0);
254 }
255 if (oldIntersects && !newIntersects) {
256 SkDebugf("%s %d missing intersection oldIntersects=%d newIntersects=%d\n%s %s\n",
257 __FUNCTION__, test, oldIntersects, newIntersects, __FUNCTION__, str);
258 assert(0);
259 }
260 if (!oldIntersects && !newIntersects) {
261 continue;
262 }
263 if (i2.used() > 1) {
264 continue;
265 // just look at single intercepts for simplicity
266 }
267 Intersections self1, self2; // self-intersect checks
268 if (intersect(cubic1, self1)) {
269 continue;
270 }
271 if (intersect(cubic2, self2)) {
272 continue;
273 }
274 // binary search for range necessary to enclose real intersection
275 CubicChopper c(cubic1, cubic2);
276 bool result = c.intersect(0, 1, 0, 1);
277 if (!result) {
278 // FIXME: a failure here probably means that a core routine used by CubicChopper is failing
279 continue;
280 }
281 double delta1 = fabs(c.t1 - i2.fT[0][0]);
282 double delta2 = fabs(c.t2 - i2.fT[1][0]);
283 double calc1 = calcPrecision(cubic1);
284 double calc2 = calcPrecision(cubic2);
285 double factor1 = calc1 / delta1;
286 double factor2 = calc2 / delta2;
287 SkDebugf("%s %d calc1=%1.9g delta1=%1.9g factor1=%1.9g calc2=%1.9g delta2=%1.9g"
288 " factor2=%1.9g\n", __FUNCTION__, test,
289 calc1, delta1, factor1, calc2, delta2, factor2);
290 if (factor1 < largestFactor) {
291 SkDebugf("WE HAVE A WINNER! %1.9g\n", factor1);
292 SkDebugf("%s\n", str);
293 oneOff(cubic1, cubic2);
294 largestFactor = factor1;
295 }
296 if (factor2 < largestFactor) {
297 SkDebugf("WE HAVE A WINNER! %1.9g\n", factor2);
298 SkDebugf("%s\n", str);
299 oneOff(cubic1, cubic2);
300 largestFactor = factor2;
301 }
302 }
303}
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000304
305void CubicIntersection_RandTest() {
306 srand(0);
caryclark@google.com85ec74c2013-01-28 19:25:51 +0000307 const int tests = 10000000;
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000308 for (int test = 0; test < tests; ++test) {
309 Cubic cubic1, cubic2;
310 for (int i = 0; i < 4; ++i) {
311 cubic1[i].x = (double) rand() / RAND_MAX * 100;
312 cubic1[i].y = (double) rand() / RAND_MAX * 100;
313 cubic2[i].x = (double) rand() / RAND_MAX * 100;
314 cubic2[i].y = (double) rand() / RAND_MAX * 100;
315 }
316 #if DEBUG_CRASH
317 char str[1024];
318 sprintf(str, "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n"
319 "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n",
320 cubic1[0].x, cubic1[0].y, cubic1[1].x, cubic1[1].y, cubic1[2].x, cubic1[2].y,
321 cubic1[3].x, cubic1[3].y,
322 cubic2[0].x, cubic2[0].y, cubic2[1].x, cubic2[1].y, cubic2[2].x, cubic2[2].y,
323 cubic2[3].x, cubic2[3].y);
324 #endif
325 _Rect rect1, rect2;
326 rect1.setBounds(cubic1);
327 rect2.setBounds(cubic2);
328 bool boundsIntersect = rect1.left <= rect2.right && rect2.left <= rect2.right
329 && rect1.top <= rect2.bottom && rect2.top <= rect1.bottom;
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000330 if (test == -1) {
331 SkDebugf("ready...\n");
332 }
333 Intersections intersections2;
334 bool newIntersects = intersect2(cubic1, cubic2, intersections2);
335 if (!boundsIntersect && newIntersects) {
336 SkDebugf("%s %d unexpected intersection boundsIntersect=%d "
337 " newIntersects=%d\n%s %s\n", __FUNCTION__, test, boundsIntersect,
338 newIntersects, __FUNCTION__, str);
339 assert(0);
340 }
341 for (int pt = 0; pt < intersections2.used(); ++pt) {
342 double tt1 = intersections2.fT[0][pt];
343 _Point xy1, xy2;
344 xy_at_t(cubic1, tt1, xy1.x, xy1.y);
345 int pt2 = intersections2.fFlip ? intersections2.used() - pt - 1 : pt;
346 double tt2 = intersections2.fT[1][pt2];
347 xy_at_t(cubic2, tt2, xy2.x, xy2.y);
caryclark@google.com9f602912013-01-24 21:47:16 +0000348 #if 0
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000349 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1.9g\n", __FUNCTION__,
350 tt1, xy1.x, xy1.y, xy2.x, xy2.y, tt2);
caryclark@google.com9f602912013-01-24 21:47:16 +0000351 #endif
caryclark@google.com05c4bad2013-01-19 13:22:39 +0000352 assert(xy1.approximatelyEqual(xy2));
353 }
354 }
355}
caryclark@google.com9f602912013-01-24 21:47:16 +0000356
357static Cubic deltaTestSet[] = {
358 {{1, 4}, {1, 4.*2/3}, {1, 4.*1/3}, {1, 0}},
359 {{0, 3}, {1, 2}, {2, 1}, {3, 0}},
360 {{1, 4}, {1, 4.*2/3}, {1, 4.*1/3}, {1, 0}},
361 {{3.5, 1}, {2.5, 2}, {1.5, 3}, {0.5, 4}}
362};
363
364size_t deltaTestSetLen = sizeof(deltaTestSet) / sizeof(deltaTestSet[0]);
365
366static double deltaTestSetT[] = {
367 3./8,
368 5./12,
369 6./8,
370 9./12
371};
372
373size_t deltaTestSetTLen = sizeof(deltaTestSetT) / sizeof(deltaTestSetT[0]);
374
375static double expectedT[] = {
376 0.5,
377 1./3,
378 1./8,
379 5./6
380};
381
382size_t expectedTLen = sizeof(expectedT) / sizeof(expectedT[0]);
383
384// FIXME: this test no longer valid -- does not take minimum scale contribution into account
385void CubicIntersection_ComputeDeltaTest() {
386 SkASSERT(deltaTestSetLen == deltaTestSetTLen);
387 SkASSERT(expectedTLen == deltaTestSetTLen);
388 for (size_t index = 0; index < deltaTestSetLen; index += 2) {
389 const Cubic& c1 = deltaTestSet[index];
390 const Cubic& c2 = deltaTestSet[index + 1];
391 double t1 = deltaTestSetT[index];
392 double t2 = deltaTestSetT[index + 1];
393 double d1, d2;
394 computeDelta(c1, t1, 1, c2, t2, 1, d1, d2);
395 SkASSERT(approximately_equal(t1 + d1, expectedT[index])
396 || approximately_equal(t1 - d1, expectedT[index]));
397 SkASSERT(approximately_equal(t2 + d2, expectedT[index + 1])
398 || approximately_equal(t2 - d2, expectedT[index + 1]));
399 }
400}