本文整理汇总了C++中SkDPoint::approximatelyEqual方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDPoint::approximatelyEqual方法的具体用法?C++ SkDPoint::approximatelyEqual怎么用?C++ SkDPoint::approximatelyEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDPoint
的用法示例。
在下文中一共展示了SkDPoint::approximatelyEqual方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkASSERT
DEF_TEST(PathOpsDPoint, reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDPoint& pt = tests[index];
SkASSERT(ValidPoint(pt));
SkDPoint p = pt;
REPORTER_ASSERT(reporter, p == pt);
REPORTER_ASSERT(reporter, !(pt != pt));
SkDVector v = p - pt;
p += v;
REPORTER_ASSERT(reporter, p == pt);
p -= v;
REPORTER_ASSERT(reporter, p == pt);
REPORTER_ASSERT(reporter, p.approximatelyEqual(pt));
SkPoint sPt = pt.asSkPoint();
p.set(sPt);
REPORTER_ASSERT(reporter, p == pt);
REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt));
REPORTER_ASSERT(reporter, p.roughlyEqual(pt));
p.fX = p.fY = 0;
REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0);
REPORTER_ASSERT(reporter, p.approximatelyZero());
REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY);
REPORTER_ASSERT(reporter, approximately_equal(pt.distance(p),
sqrt(pt.fX * pt.fX + pt.fY * pt.fY)));
}
}
示例2: testLineIntersect
static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
const SkDLine& line, const double x, const double y) {
char pathStr[1024];
sk_bzero(pathStr, sizeof(pathStr));
char* str = pathStr;
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
str += sprintf(str, " path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX,
quad[1].fY, quad[2].fX, quad[2].fY);
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
str += sprintf(str, " path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
SkIntersections intersections;
bool flipped = false;
int result = doIntersect(intersections, quad, line, flipped);
bool found = false;
for (int index = 0; index < result; ++index) {
double quadT = intersections[0][index];
SkDPoint quadXY = quad.ptAtT(quadT);
double lineT = intersections[1][index];
SkDPoint lineXY = line.ptAtT(lineT);
if (quadXY.approximatelyEqual(lineXY)) {
found = true;
}
}
REPORTER_ASSERT(reporter, found);
}
示例3: cubicInsert
void SkIntersections::cubicInsert(double one, double two, const SkDPoint& pt,
const SkDCubic& cubic1, const SkDCubic& cubic2) {
for (int index = 0; index < fUsed; ++index) {
if (fT[0][index] == one) {
double oldTwo = fT[1][index];
if (oldTwo == two) {
return;
}
SkDPoint mid = cubic2.ptAtT((oldTwo + two) / 2);
if (mid.approximatelyEqual(fPt[index])) {
return;
}
}
if (fT[1][index] == two) {
SkDPoint mid = cubic1.ptAtT((fT[0][index] + two) / 2);
if (mid.approximatelyEqual(fPt[index])) {
return;
}
}
}
insert(one, two, pt);
}
示例4: testOneOffs
static void testOneOffs(skiatest::Reporter* reporter) {
bool flipped = false;
for (size_t index = 0; index < oneOffs_count; ++index) {
const SkDConic& conic = oneOffs[index].conic;
SkASSERT(ValidConic(conic));
const SkDLine& line = oneOffs[index].line;
SkASSERT(ValidLine(line));
SkIntersections intersections;
int result = doIntersect(intersections, conic, line, flipped);
for (int inner = 0; inner < result; ++inner) {
double conicT = intersections[0][inner];
SkDPoint conicXY = conic.ptAtT(conicT);
double lineT = intersections[1][inner];
SkDPoint lineXY = line.ptAtT(lineT);
if (!conicXY.approximatelyEqual(lineXY)) {
conicXY.approximatelyEqual(lineXY);
SkDebugf("");
}
REPORTER_ASSERT(reporter, conicXY.approximatelyEqual(lineXY));
}
}
}
示例5: testOneOffs
static void testOneOffs(skiatest::Reporter* reporter) {
bool flipped = false;
for (size_t index = 0; index < oneOffs_count; ++index) {
const QuadPts& q = oneOffs[index].quad;
SkDQuad quad;
quad.debugSet(q.fPts);
SkASSERT(ValidQuad(quad));
const SkDLine& line = oneOffs[index].line;
SkASSERT(ValidLine(line));
SkIntersections intersections;
int result = doIntersect(intersections, quad, line, flipped);
for (int inner = 0; inner < result; ++inner) {
double quadT = intersections[0][inner];
SkDPoint quadXY = quad.ptAtT(quadT);
double lineT = intersections[1][inner];
SkDPoint lineXY = line.ptAtT(lineT);
if (!quadXY.approximatelyEqual(lineXY)) {
quadXY.approximatelyEqual(lineXY);
SkDebugf("");
}
REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY));
}
}
}
示例6: testOneOffs
static void testOneOffs(skiatest::Reporter* reporter) {
SkIntersections intersections;
bool flipped = false;
for (size_t index = 0; index < oneOffs_count; ++index) {
const SkDQuad& quad = oneOffs[index].quad;
const SkDLine& line = oneOffs[index].line;
int result = doIntersect(intersections, quad, line, flipped);
for (int inner = 0; inner < result; ++inner) {
double quadT = intersections[0][inner];
SkDPoint quadXY = quad.xyAtT(quadT);
double lineT = intersections[1][inner];
SkDPoint lineXY = line.xyAtT(lineT);
REPORTER_ASSERT(reporter, quadXY.approximatelyEqual(lineXY));
}
}
}
示例7: uniqueAnswer
bool uniqueAnswer(double cubicT, const SkDPoint& pt) {
for (int inner = 0; inner < fIntersections->used(); ++inner) {
if (fIntersections->pt(inner) != pt) {
continue;
}
double existingCubicT = (*fIntersections)[0][inner];
if (cubicT == existingCubicT) {
return false;
}
// check if midway on cubic is also same point. If so, discard this
double cubicMidT = (existingCubicT + cubicT) / 2;
SkDPoint cubicMidPt = fCubic.ptAtT(cubicMidT);
if (cubicMidPt.approximatelyEqual(pt)) {
return false;
}
}
#if ONE_OFF_DEBUG
SkDPoint cPt = fCubic.ptAtT(cubicT);
SkDebugf("%s pt=(%1.9g,%1.9g) cPt=(%1.9g,%1.9g)\n", __FUNCTION__, pt.fX, pt.fY,
cPt.fX, cPt.fY);
#endif
return true;
}
示例8: is_linear_inner
static bool is_linear_inner(const SkDQuad& q1, double t1s, double t1e, const SkDQuad& q2,
double t2s, double t2e, SkIntersections* i, bool* subDivide) {
SkDQuad hull = q1.subDivide(t1s, t1e);
SkDLine line = {{hull[2], hull[0]}};
const SkDLine* testLines[] = { &line, (const SkDLine*) &hull[0], (const SkDLine*) &hull[1] };
const size_t kTestCount = SK_ARRAY_COUNT(testLines);
SkSTArray<kTestCount * 2, double, true> tsFound;
for (size_t index = 0; index < kTestCount; ++index) {
SkIntersections rootTs;
rootTs.allowNear(false);
int roots = rootTs.intersect(q2, *testLines[index]);
for (int idx2 = 0; idx2 < roots; ++idx2) {
double t = rootTs[0][idx2];
#ifdef SK_DEBUG
SkDPoint qPt = q2.ptAtT(t);
SkDPoint lPt = testLines[index]->ptAtT(rootTs[1][idx2]);
SkASSERT(qPt.approximatelyEqual(lPt));
#endif
if (approximately_negative(t - t2s) || approximately_positive(t - t2e)) {
continue;
}
tsFound.push_back(rootTs[0][idx2]);
}
}
int tCount = tsFound.count();
if (tCount <= 0) {
return true;
}
double tMin, tMax;
if (tCount == 1) {
tMin = tMax = tsFound[0];
} else {
SkASSERT(tCount > 1);
SkTQSort<double>(tsFound.begin(), tsFound.end() - 1);
tMin = tsFound[0];
tMax = tsFound[tsFound.count() - 1];
}
SkDPoint end = q2.ptAtT(t2s);
bool startInTriangle = hull.pointInHull(end);
if (startInTriangle) {
tMin = t2s;
}
end = q2.ptAtT(t2e);
bool endInTriangle = hull.pointInHull(end);
if (endInTriangle) {
tMax = t2e;
}
int split = 0;
SkDVector dxy1, dxy2;
if (tMin != tMax || tCount > 2) {
dxy2 = q2.dxdyAtT(tMin);
for (int index = 1; index < tCount; ++index) {
dxy1 = dxy2;
dxy2 = q2.dxdyAtT(tsFound[index]);
double dot = dxy1.dot(dxy2);
if (dot < 0) {
split = index - 1;
break;
}
}
}
if (split == 0) { // there's one point
if (add_intercept(q1, q2, tMin, tMax, i, subDivide)) {
return true;
}
i->swap();
return is_linear_inner(q2, tMin, tMax, q1, t1s, t1e, i, subDivide);
}
// At this point, we have two ranges of t values -- treat each separately at the split
bool result;
if (add_intercept(q1, q2, tMin, tsFound[split - 1], i, subDivide)) {
result = true;
} else {
i->swap();
result = is_linear_inner(q2, tMin, tsFound[split - 1], q1, t1s, t1e, i, subDivide);
}
if (add_intercept(q1, q2, tsFound[split], tMax, i, subDivide)) {
result = true;
} else {
i->swap();
result |= is_linear_inner(q2, tsFound[split], tMax, q1, t1s, t1e, i, subDivide);
}
return result;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_skia_src,代码行数:84,代码来源:SkDQuadIntersection.cpp