bool SkDCubic::controlsContainedByEnds() const { SkDVector startTan = fPts[1] - fPts[0]; if (startTan.fX == 0 && startTan.fY == 0) { startTan = fPts[2] - fPts[0]; } SkDVector endTan = fPts[2] - fPts[3]; if (endTan.fX == 0 && endTan.fY == 0) { endTan = fPts[1] - fPts[3]; } if (startTan.dot(endTan) >= 0) { return false; } SkDLine startEdge = {{fPts[0], fPts[0]}}; startEdge[1].fX -= startTan.fY; startEdge[1].fY += startTan.fX; SkDLine endEdge = {{fPts[3], fPts[3]}}; endEdge[1].fX -= endTan.fY; endEdge[1].fY += endTan.fX; double leftStart1 = startEdge.isLeft(fPts[1]); if (leftStart1 * startEdge.isLeft(fPts[2]) < 0) { return false; } double leftEnd1 = endEdge.isLeft(fPts[1]); if (leftEnd1 * endEdge.isLeft(fPts[2]) < 0) { return false; } return leftStart1 * leftEnd1 >= 0; }
static void pointFinder(const SkDQuad& q1, const SkDQuad& q2) { for (int index = 0; index < 3; ++index) { double t = q1.nearestT(q2[index]); SkDPoint onQuad = q1.ptAtT(t); SkDebugf("%s t=%1.9g (%1.9g,%1.9g) dist=%1.9g\n", __FUNCTION__, t, onQuad.fX, onQuad.fY, onQuad.distance(q2[index])); double left[3]; left[0] = ((const SkDLine&) q1[0]).isLeft(q2[index]); left[1] = ((const SkDLine&) q1[1]).isLeft(q2[index]); SkDLine diag = {{q1[0], q1[2]}}; left[2] = diag.isLeft(q2[index]); SkDebugf("%s left=(%d, %d, %d) inHull=%s\n", __FUNCTION__, floatSign(left[0]), floatSign(left[1]), floatSign(left[2]), q1.pointInHull(q2[index]) ? "true" : "false"); } SkDebugf("\n"); }