bool operator== (const Polygon& p1, const Polygon& p2) { if (p1.points.size() != p2.points.size()) return false; for (unsigned i=0; i<p1.points.size(); i++) if (!approxEqual(p1.points[i].x, p2.points[i].x) || !approxEqual(p1.points[i].y, p2.points[i].y) || !approxEqual(p1.points[i].z, p2.points[i].z)) return false; return true; }
static void checkPos( float axisPos, unsigned& left, unsigned& right, unsigned& cop, float splitPos ) { if(approxEqual(axisPos, splitPos)) ++cop; else if( axisPos < splitPos) ++left; else ++right; }
bool approxEqual(const MatrixWrapper::ColumnVector& a, const MatrixWrapper::ColumnVector& b, double epsilon) { if (a.rows() != b.rows()) return false; for (unsigned int r=0; r<a.rows(); r++) if (!approxEqual(a(r+1), b(r+1),epsilon)) return false; return true; }
CPoly LineSegment::asPoly(Color bdyColor) { if(B == noCoord) // this is a point, not actually a segment { CPoly c; c.bdy.push_back(A); c.bdyColor = GREEN; return c; } CPoly c; c.bdy.push_back(A); c.bdy.push_back(B); if(approxEqual(bdyColor, noColor)) { // to return the proper color if(approxEqual(color, noColor)) c.bdyColor = WHITE; else c.bdyColor = color; } return c; }
bool approxEqual(const MatrixWrapper::SymmetricMatrix& a, const MatrixWrapper::SymmetricMatrix& b, double epsilon) { if (a.rows() != b.rows()) return false; if (a.columns() != b.columns()) return false; for (unsigned int r=0; r<a.rows(); r++) for (unsigned int c=0; c<a.columns(); c++) if (!approxEqual(a(r+1, c+1), b(r+1,c+1),epsilon)) return false; return true; }
bool RangeData::Point::operator == (const RangeData::Point& other) const { const double priceDelta = 0.0001; const double volumeDelta = 0.01; return ((approxEqual(other.open, open, priceDelta)) && (approxEqual(other.close, close, priceDelta)) && (approxEqual(other.min, min, priceDelta)) && (approxEqual(other.max, max, priceDelta)) && (approxEqual(other.volume, volume, volumeDelta)) && (approxEqual(other.adjustedClose, adjustedClose, priceDelta)) && (other.tradeTime == tradeTime) ); }
Command SequenceAnalyzer::detectCommand(double tolerance) { std::vector<Position> seq(buffer_.begin(), buffer_.end()); int correctCount = codeCorrection(seq); int N = seq.size(); if (N < 2 || invalidCount_ > 3) { return INVALID; } double mean0 = calPositionMean(seq.begin(), seq.begin() + N / 2); double mean1 = calPositionMean(seq.begin() + N / 2, seq.begin() + N); if (approxEqual(mean1, 2, tolerance) && (approxEqual(mean0, 0, tolerance) || approxEqual(mean0, 1, tolerance))) { return RIGHT; } if (approxEqual(mean1, 0, tolerance) && (approxEqual(mean0, 1, tolerance) || approxEqual(mean0, 2, tolerance))) { return LEFT; } return INVALID; }
bool ApproxEqual(Weight const& a, Weight const& b, float epsilon) { return approxEqual(a, b, epsilon); }