#include //for the object cout #include //for the functions sqrt, atan2, and abs #include "point.h" using namespace std; point::point(double init_x, double init_y) : x {init_x}, y {init_y} { } point::point() //The default constructor puts the origin into the newborn point. : x {0.0}, y {0.0} { } double point::r() const //distance from origin { return sqrt(x * x + y * y); } double point::theta() const //in radians { return atan2(y, x); //two-argument arctangent function } void point::print() const { cout << "(" << x << ", " << y << ")"; } double distance(const point& A, const point& B) //distance between two points { const double dx {A.x - B.x}; const double dy {A.y - B.y}; return sqrt(dx * dx + dy * dy); } bool equals(const point& A, const point& B) //true if at same coordinates { return A.x == B.X && A.y == B.y; } double area(const point& A, const point& B, const point& C) //area of triangle { return abs(A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / 2.0; }