#ifndef POINTH #define POINTH #include #include //for abs using namespace std; const double point_error = .0001; //floating point roundoff error //class point; //point midpoint(const point& A, const point& B); class point { double x, y; public: point(double initial_x = 0.0, double initial_y = 0.0) { x = initial_x; y = initial_y; } void print() const {cout << "(" << x << ", " << y << ")";} void assign(const point& another) {x = another.x; y = another.y;} double dist() const; friend double dist(const point& A, const point& B); friend point midpoint(const point& A, const point& B) { return point((A.x + B.x) / 2, (A.y + B.y) / 2); } friend double area(const point& A, const point& B, const point& C); }; point midpoint(const point& A, const point& B); //Return true if all three points lie along the same line. inline bool collinear(const point& A, const point& B, const point& C) { return abs(area(A, B, C)) < point_error; } bool contains(const point& A, const point& B, const point& C, const point& D); #endif