caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 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 "SkIntersections.h" |
| 8 | #include "SkPathOpsCubic.h" |
| 9 | #include "SkPathOpsLine.h" |
| 10 | |
| 11 | /* |
| 12 | Find the interection of a line and cubic by solving for valid t values. |
| 13 | |
| 14 | Analogous to line-quadratic intersection, solve line-cubic intersection by |
| 15 | representing the cubic as: |
| 16 | x = a(1-t)^3 + 2b(1-t)^2t + c(1-t)t^2 + dt^3 |
| 17 | y = e(1-t)^3 + 2f(1-t)^2t + g(1-t)t^2 + ht^3 |
| 18 | and the line as: |
| 19 | y = i*x + j (if the line is more horizontal) |
| 20 | or: |
| 21 | x = i*y + j (if the line is more vertical) |
| 22 | |
| 23 | Then using Mathematica, solve for the values of t where the cubic intersects the |
| 24 | line: |
| 25 | |
| 26 | (in) Resultant[ |
| 27 | a*(1 - t)^3 + 3*b*(1 - t)^2*t + 3*c*(1 - t)*t^2 + d*t^3 - x, |
| 28 | e*(1 - t)^3 + 3*f*(1 - t)^2*t + 3*g*(1 - t)*t^2 + h*t^3 - i*x - j, x] |
| 29 | (out) -e + j + |
| 30 | 3 e t - 3 f t - |
| 31 | 3 e t^2 + 6 f t^2 - 3 g t^2 + |
| 32 | e t^3 - 3 f t^3 + 3 g t^3 - h t^3 + |
| 33 | i ( a - |
| 34 | 3 a t + 3 b t + |
| 35 | 3 a t^2 - 6 b t^2 + 3 c t^2 - |
| 36 | a t^3 + 3 b t^3 - 3 c t^3 + d t^3 ) |
| 37 | |
| 38 | if i goes to infinity, we can rewrite the line in terms of x. Mathematica: |
| 39 | |
| 40 | (in) Resultant[ |
| 41 | a*(1 - t)^3 + 3*b*(1 - t)^2*t + 3*c*(1 - t)*t^2 + d*t^3 - i*y - j, |
| 42 | e*(1 - t)^3 + 3*f*(1 - t)^2*t + 3*g*(1 - t)*t^2 + h*t^3 - y, y] |
| 43 | (out) a - j - |
| 44 | 3 a t + 3 b t + |
| 45 | 3 a t^2 - 6 b t^2 + 3 c t^2 - |
| 46 | a t^3 + 3 b t^3 - 3 c t^3 + d t^3 - |
| 47 | i ( e - |
| 48 | 3 e t + 3 f t + |
| 49 | 3 e t^2 - 6 f t^2 + 3 g t^2 - |
| 50 | e t^3 + 3 f t^3 - 3 g t^3 + h t^3 ) |
| 51 | |
| 52 | Solving this with Mathematica produces an expression with hundreds of terms; |
| 53 | instead, use Numeric Solutions recipe to solve the cubic. |
| 54 | |
| 55 | The near-horizontal case, in terms of: Ax^3 + Bx^2 + Cx + D == 0 |
| 56 | A = (-(-e + 3*f - 3*g + h) + i*(-a + 3*b - 3*c + d) ) |
| 57 | B = 3*(-( e - 2*f + g ) + i*( a - 2*b + c ) ) |
| 58 | C = 3*(-(-e + f ) + i*(-a + b ) ) |
| 59 | D = (-( e ) + i*( a ) + j ) |
| 60 | |
| 61 | The near-vertical case, in terms of: Ax^3 + Bx^2 + Cx + D == 0 |
| 62 | A = ( (-a + 3*b - 3*c + d) - i*(-e + 3*f - 3*g + h) ) |
| 63 | B = 3*( ( a - 2*b + c ) - i*( e - 2*f + g ) ) |
| 64 | C = 3*( (-a + b ) - i*(-e + f ) ) |
| 65 | D = ( ( a ) - i*( e ) - j ) |
| 66 | |
| 67 | For horizontal lines: |
| 68 | (in) Resultant[ |
| 69 | a*(1 - t)^3 + 3*b*(1 - t)^2*t + 3*c*(1 - t)*t^2 + d*t^3 - j, |
| 70 | e*(1 - t)^3 + 3*f*(1 - t)^2*t + 3*g*(1 - t)*t^2 + h*t^3 - y, y] |
| 71 | (out) e - j - |
| 72 | 3 e t + 3 f t + |
| 73 | 3 e t^2 - 6 f t^2 + 3 g t^2 - |
| 74 | e t^3 + 3 f t^3 - 3 g t^3 + h t^3 |
| 75 | */ |
| 76 | |
| 77 | class LineCubicIntersections { |
| 78 | public: |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 79 | enum PinTPoint { |
| 80 | kPointUninitialized, |
| 81 | kPointInitialized |
| 82 | }; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 83 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 84 | LineCubicIntersections(const SkDCubic& c, const SkDLine& l, SkIntersections* i) |
| 85 | : fCubic(c) |
| 86 | , fLine(l) |
| 87 | , fIntersections(i) |
| 88 | , fAllowNear(true) { |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame^] | 89 | i->setMax(3); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 90 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 91 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 92 | void allowNear(bool allow) { |
| 93 | fAllowNear = allow; |
| 94 | } |
| 95 | |
| 96 | // see parallel routine in line quadratic intersections |
| 97 | int intersectRay(double roots[3]) { |
| 98 | double adj = fLine[1].fX - fLine[0].fX; |
| 99 | double opp = fLine[1].fY - fLine[0].fY; |
| 100 | SkDCubic r; |
| 101 | for (int n = 0; n < 4; ++n) { |
| 102 | r[n].fX = (fCubic[n].fY - fLine[0].fY) * adj - (fCubic[n].fX - fLine[0].fX) * opp; |
| 103 | } |
| 104 | double A, B, C, D; |
| 105 | SkDCubic::Coefficients(&r[0].fX, &A, &B, &C, &D); |
| 106 | return SkDCubic::RootsValidT(A, B, C, D, roots); |
| 107 | } |
| 108 | |
| 109 | int intersect() { |
| 110 | addExactEndPoints(); |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 111 | if (fAllowNear) { |
| 112 | addNearEndPoints(); |
| 113 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 114 | double rootVals[3]; |
| 115 | int roots = intersectRay(rootVals); |
| 116 | for (int index = 0; index < roots; ++index) { |
| 117 | double cubicT = rootVals[index]; |
| 118 | double lineT = findLineT(cubicT); |
| 119 | SkDPoint pt; |
| 120 | if (pinTs(&cubicT, &lineT, &pt, kPointUninitialized)) { |
| 121 | #if ONE_OFF_DEBUG |
| 122 | SkDPoint cPt = fCubic.ptAtT(cubicT); |
| 123 | SkDebugf("%s pt=(%1.9g,%1.9g) cPt=(%1.9g,%1.9g)\n", __FUNCTION__, pt.fX, pt.fY, |
| 124 | cPt.fX, cPt.fY); |
| 125 | #endif |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame^] | 126 | for (int inner = 0; inner < fIntersections->used(); ++inner) { |
| 127 | if (fIntersections->pt(inner) != pt) { |
| 128 | continue; |
| 129 | } |
| 130 | double existingCubicT = (*fIntersections)[0][inner]; |
| 131 | if (cubicT == existingCubicT) { |
| 132 | goto skipInsert; |
| 133 | } |
| 134 | // check if midway on cubic is also same point. If so, discard this |
| 135 | double cubicMidT = (existingCubicT + cubicT) / 2; |
| 136 | SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT); |
| 137 | if (cubicMidPt.approximatelyEqual(pt)) { |
| 138 | goto skipInsert; |
| 139 | } |
| 140 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 141 | fIntersections->insert(cubicT, lineT, pt); |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame^] | 142 | skipInsert: |
| 143 | ; |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 144 | } |
| 145 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 146 | return fIntersections->used(); |
| 147 | } |
| 148 | |
| 149 | int horizontalIntersect(double axisIntercept, double roots[3]) { |
| 150 | double A, B, C, D; |
| 151 | SkDCubic::Coefficients(&fCubic[0].fY, &A, &B, &C, &D); |
| 152 | D -= axisIntercept; |
| 153 | return SkDCubic::RootsValidT(A, B, C, D, roots); |
| 154 | } |
| 155 | |
| 156 | int horizontalIntersect(double axisIntercept, double left, double right, bool flipped) { |
| 157 | addExactHorizontalEndPoints(left, right, axisIntercept); |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 158 | if (fAllowNear) { |
| 159 | addNearHorizontalEndPoints(left, right, axisIntercept); |
| 160 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 161 | double rootVals[3]; |
| 162 | int roots = horizontalIntersect(axisIntercept, rootVals); |
| 163 | for (int index = 0; index < roots; ++index) { |
| 164 | double cubicT = rootVals[index]; |
| 165 | SkDPoint pt = fCubic.ptAtT(cubicT); |
| 166 | double lineT = (pt.fX - left) / (right - left); |
| 167 | if (pinTs(&cubicT, &lineT, &pt, kPointInitialized)) { |
| 168 | fIntersections->insert(cubicT, lineT, pt); |
| 169 | } |
| 170 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 171 | if (flipped) { |
| 172 | fIntersections->flip(); |
| 173 | } |
| 174 | return fIntersections->used(); |
| 175 | } |
| 176 | |
| 177 | int verticalIntersect(double axisIntercept, double roots[3]) { |
| 178 | double A, B, C, D; |
| 179 | SkDCubic::Coefficients(&fCubic[0].fX, &A, &B, &C, &D); |
| 180 | D -= axisIntercept; |
| 181 | return SkDCubic::RootsValidT(A, B, C, D, roots); |
| 182 | } |
| 183 | |
| 184 | int verticalIntersect(double axisIntercept, double top, double bottom, bool flipped) { |
| 185 | addExactVerticalEndPoints(top, bottom, axisIntercept); |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 186 | if (fAllowNear) { |
| 187 | addNearVerticalEndPoints(top, bottom, axisIntercept); |
| 188 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 189 | double rootVals[3]; |
| 190 | int roots = verticalIntersect(axisIntercept, rootVals); |
| 191 | for (int index = 0; index < roots; ++index) { |
| 192 | double cubicT = rootVals[index]; |
| 193 | SkDPoint pt = fCubic.ptAtT(cubicT); |
| 194 | double lineT = (pt.fY - top) / (bottom - top); |
| 195 | if (pinTs(&cubicT, &lineT, &pt, kPointInitialized)) { |
| 196 | fIntersections->insert(cubicT, lineT, pt); |
| 197 | } |
| 198 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 199 | if (flipped) { |
| 200 | fIntersections->flip(); |
| 201 | } |
| 202 | return fIntersections->used(); |
| 203 | } |
| 204 | |
| 205 | protected: |
| 206 | |
| 207 | void addExactEndPoints() { |
| 208 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 209 | double lineT = fLine.exactPoint(fCubic[cIndex]); |
| 210 | if (lineT < 0) { |
| 211 | continue; |
| 212 | } |
| 213 | double cubicT = (double) (cIndex >> 1); |
| 214 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 215 | } |
| 216 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 217 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 218 | void addNearEndPoints() { |
| 219 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 220 | double cubicT = (double) (cIndex >> 1); |
| 221 | if (fIntersections->hasT(cubicT)) { |
| 222 | continue; |
| 223 | } |
| 224 | double lineT = fLine.nearPoint(fCubic[cIndex]); |
| 225 | if (lineT < 0) { |
| 226 | continue; |
| 227 | } |
| 228 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 229 | } |
| 230 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 231 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 232 | void addExactHorizontalEndPoints(double left, double right, double y) { |
| 233 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 234 | double lineT = SkDLine::ExactPointH(fCubic[cIndex], left, right, y); |
| 235 | if (lineT < 0) { |
| 236 | continue; |
| 237 | } |
| 238 | double cubicT = (double) (cIndex >> 1); |
| 239 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 240 | } |
| 241 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 242 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 243 | void addNearHorizontalEndPoints(double left, double right, double y) { |
| 244 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 245 | double cubicT = (double) (cIndex >> 1); |
| 246 | if (fIntersections->hasT(cubicT)) { |
| 247 | continue; |
| 248 | } |
| 249 | double lineT = SkDLine::NearPointH(fCubic[cIndex], left, right, y); |
| 250 | if (lineT < 0) { |
| 251 | continue; |
| 252 | } |
| 253 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
| 254 | } |
| 255 | // FIXME: see if line end is nearly on cubic |
| 256 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 257 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 258 | void addExactVerticalEndPoints(double top, double bottom, double x) { |
| 259 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 260 | double lineT = SkDLine::ExactPointV(fCubic[cIndex], top, bottom, x); |
| 261 | if (lineT < 0) { |
| 262 | continue; |
| 263 | } |
| 264 | double cubicT = (double) (cIndex >> 1); |
| 265 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 266 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 267 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 268 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 269 | void addNearVerticalEndPoints(double top, double bottom, double x) { |
| 270 | for (int cIndex = 0; cIndex < 4; cIndex += 3) { |
| 271 | double cubicT = (double) (cIndex >> 1); |
| 272 | if (fIntersections->hasT(cubicT)) { |
| 273 | continue; |
| 274 | } |
| 275 | double lineT = SkDLine::NearPointV(fCubic[cIndex], top, bottom, x); |
| 276 | if (lineT < 0) { |
| 277 | continue; |
| 278 | } |
| 279 | fIntersections->insert(cubicT, lineT, fCubic[cIndex]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 280 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 281 | // FIXME: see if line end is nearly on cubic |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 282 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 283 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 284 | double findLineT(double t) { |
| 285 | SkDPoint xy = fCubic.ptAtT(t); |
| 286 | double dx = fLine[1].fX - fLine[0].fX; |
| 287 | double dy = fLine[1].fY - fLine[0].fY; |
| 288 | if (fabs(dx) > fabs(dy)) { |
| 289 | return (xy.fX - fLine[0].fX) / dx; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 290 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 291 | return (xy.fY - fLine[0].fY) / dy; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 292 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 293 | |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 294 | bool pinTs(double* cubicT, double* lineT, SkDPoint* pt, PinTPoint ptSet) { |
| 295 | if (!approximately_one_or_less(*lineT)) { |
| 296 | return false; |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 297 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 298 | if (!approximately_zero_or_more(*lineT)) { |
| 299 | return false; |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 300 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 301 | double cT = *cubicT = SkPinT(*cubicT); |
| 302 | double lT = *lineT = SkPinT(*lineT); |
| 303 | if (lT == 0 || lT == 1 || (ptSet == kPointUninitialized && cT != 0 && cT != 1)) { |
| 304 | *pt = fLine.ptAtT(lT); |
| 305 | } else if (ptSet == kPointUninitialized) { |
| 306 | *pt = fCubic.ptAtT(cT); |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 307 | } |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 308 | SkPoint gridPt = pt->asSkPoint(); |
| 309 | if (gridPt == fLine[0].asSkPoint()) { |
| 310 | *lineT = 0; |
| 311 | } else if (gridPt == fLine[1].asSkPoint()) { |
| 312 | *lineT = 1; |
| 313 | } |
| 314 | if (gridPt == fCubic[0].asSkPoint() && approximately_equal(*cubicT, 0)) { |
| 315 | *cubicT = 0; |
| 316 | } else if (gridPt == fCubic[3].asSkPoint() && approximately_equal(*cubicT, 1)) { |
| 317 | *cubicT = 1; |
| 318 | } |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 319 | return true; |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 320 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 321 | |
| 322 | private: |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 323 | const SkDCubic& fCubic; |
| 324 | const SkDLine& fLine; |
| 325 | SkIntersections* fIntersections; |
| 326 | bool fAllowNear; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 327 | }; |
| 328 | |
| 329 | int SkIntersections::horizontal(const SkDCubic& cubic, double left, double right, double y, |
| 330 | bool flipped) { |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 331 | SkDLine line = {{{ left, y }, { right, y }}}; |
| 332 | LineCubicIntersections c(cubic, line, this); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 333 | return c.horizontalIntersect(y, left, right, flipped); |
| 334 | } |
| 335 | |
| 336 | int SkIntersections::vertical(const SkDCubic& cubic, double top, double bottom, double x, |
| 337 | bool flipped) { |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 338 | SkDLine line = {{{ x, top }, { x, bottom }}}; |
| 339 | LineCubicIntersections c(cubic, line, this); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 340 | return c.verticalIntersect(x, top, bottom, flipped); |
| 341 | } |
| 342 | |
| 343 | int SkIntersections::intersect(const SkDCubic& cubic, const SkDLine& line) { |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 344 | LineCubicIntersections c(cubic, line, this); |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 345 | c.allowNear(fAllowNear); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 346 | return c.intersect(); |
| 347 | } |
| 348 | |
| 349 | int SkIntersections::intersectRay(const SkDCubic& cubic, const SkDLine& line) { |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 350 | LineCubicIntersections c(cubic, line, this); |
caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 351 | fUsed = c.intersectRay(fT[0]); |
| 352 | for (int index = 0; index < fUsed; ++index) { |
caryclark@google.com | 4fdbb22 | 2013-07-23 15:27:41 +0000 | [diff] [blame] | 353 | fPt[index] = cubic.ptAtT(fT[0][index]); |
caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 354 | } |
| 355 | return fUsed; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 356 | } |