本文整理汇总了C++中SkDPoint::roughlyEqual方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDPoint::roughlyEqual方法的具体用法?C++ SkDPoint::roughlyEqual怎么用?C++ SkDPoint::roughlyEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDPoint
的用法示例。
在下文中一共展示了SkDPoint::roughlyEqual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: insert
int SkIntersections::insert(double one, double two, const SkDPoint& pt) {
if (fIsCoincident[0] == 3 && between(fT[0][0], one, fT[0][1])) {
// For now, don't allow a mix of coincident and non-coincident intersections
return -1;
}
SkASSERT(fUsed <= 1 || fT[0][0] <= fT[0][1]);
int index;
for (index = 0; index < fUsed; ++index) {
double oldOne = fT[0][index];
double oldTwo = fT[1][index];
if (one == oldOne && two == oldTwo) {
return -1;
}
if (more_roughly_equal(oldOne, one) && more_roughly_equal(oldTwo, two)) {
if ((precisely_zero(one) && !precisely_zero(oldOne))
|| (precisely_equal(one, 1) && !precisely_equal(oldOne, 1))
|| (precisely_zero(two) && !precisely_zero(oldTwo))
|| (precisely_equal(two, 1) && !precisely_equal(oldTwo, 1))) {
SkASSERT(one >= 0 && one <= 1);
SkASSERT(two >= 0 && two <= 1);
fT[0][index] = one;
fT[1][index] = two;
fPt[index] = pt;
}
return -1;
}
#if ONE_OFF_DEBUG
if (pt.roughlyEqual(fPt[index])) {
SkDebugf("%s t=%1.9g pts roughly equal\n", __FUNCTION__, one);
}
#endif
if (fT[0][index] > one) {
break;
}
}
if (fUsed >= fMax) {
SkASSERT(0); // FIXME : this error, if it is to be handled at runtime in release, must
// be propagated all the way back down to the caller, and return failure.
fUsed = 0;
return 0;
}
int remaining = fUsed - index;
if (remaining > 0) {
memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining);
memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining);
memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining);
int clearMask = ~((1 << index) - 1);
fIsCoincident[0] += fIsCoincident[0] & clearMask;
fIsCoincident[1] += fIsCoincident[1] & clearMask;
}
fPt[index] = pt;
SkASSERT(one >= 0 && one <= 1);
SkASSERT(two >= 0 && two <= 1);
fT[0][index] = one;
fT[1][index] = two;
++fUsed;
return index;
}