int intersect() { addEndPoints(); double rootVals[2]; int roots = intersectRay(rootVals); for (int index = 0; index < roots; ++index) { double quadT = rootVals[index]; double lineT = findLineT(quadT); if (pinTs(quadT, lineT)) { intersections.insert(quadT, lineT); } } return intersections.fUsed; }
int intersect() { addEndPoints(); double rootVals[2]; int roots = intersectRay(rootVals); for (int index = 0; index < roots; ++index) { double quadT = rootVals[index]; double lineT = findLineT(quadT); if (PinTs(&quadT, &lineT)) { SkDPoint pt = line.xyAtT(lineT); intersections->insert(quadT, lineT, pt); } } return intersections->used(); }
int intersect() { addExactEndPoints(); if (fAllowNear) { addNearEndPoints(); } double rootVals[3]; int roots = intersectRay(rootVals); for (int index = 0; index < roots; ++index) { double cubicT = rootVals[index]; double lineT = findLineT(cubicT); SkDPoint pt; if (pinTs(&cubicT, &lineT, &pt, kPointUninitialized) && uniqueAnswer(cubicT, pt)) { fIntersections->insert(cubicT, lineT, pt); } } checkCoincident(); return fIntersections->used(); }
int intersect() { addExactEndPoints(); if (fAllowNear) { addNearEndPoints(); } if (fIntersections->used() == 2) { // FIXME : need sharable code that turns spans into coincident if middle point is on } else { double rootVals[2]; int roots = intersectRay(rootVals); for (int index = 0; index < roots; ++index) { double quadT = rootVals[index]; double lineT = findLineT(quadT); SkDPoint pt; if (pinTs(&quadT, &lineT, &pt, kPointUninitialized)) { fIntersections->insert(quadT, lineT, pt); } } } return fIntersections->used(); }
int intersect() { /* solve by rotating line+quad so line is horizontal, then finding the roots set up matrix to rotate quad to x-axis |cos(a) -sin(a)| |sin(a) cos(a)| note that cos(a) = A(djacent) / Hypoteneuse sin(a) = O(pposite) / Hypoteneuse since we are computing Ts, we can ignore hypoteneuse, the scale factor: | A -O | | O A | A = line[1].x - line[0].x (adjacent side of the right triangle) O = line[1].y - line[0].y (opposite side of the right triangle) for each of the three points (e.g. n = 0 to 2) quad[n].y' = (quad[n].y - line[0].y) * A - (quad[n].x - line[0].x) * O */ double adj = line[1].x - line[0].x; double opp = line[1].y - line[0].y; double r[3]; for (int n = 0; n < 3; ++n) { r[n] = (quad[n].y - line[0].y) * adj - (quad[n].x - line[0].x) * opp; } double A = r[2]; double B = r[1]; double C = r[0]; A += C - 2 * B; // A = a - 2*b + c B -= C; // B = -(b - c) int roots = quadraticRoots(A, B, C, intersections.fT[0]); for (int index = 0; index < roots; ) { double lineT = findLineT(intersections.fT[0][index]); if (lineIntersects(lineT, index, roots)) { ++index; } } return roots; }