/***************************************************************** * File: Point2d.java * Synopsis: * Basic Point Class for 2-dimensional geometry * * $Id: Point2d.j,v 1.1 2003/02/12 17:57:36 yap Exp $ *****************************************************************/ class Point2d extends GeomObj { public: double x, y; //Constructors Point2d(); //initialized to origin(0,0) Point2d(double, double); Point2d( Point2d ); Point2d(Vector v); //create a point initialized to the point $(v[0], v[1])$ //precondition: v.dim() = 2 //destructor virtual ~Point2d() {} Point2d operator=( Point2d); double X() { return x; } double Y() { return y; } double distance( Point2d) ; // returns the Euclidean distance between p and this double distance() { return distance(Point2d(0, 0)); } // returns distance between this and origin Point2d operator+( Point2d ) ; Point2d operator-( Point2d ) ; Point2d rotate90( Point2d q); // returns the point rotated about q by angle of 90 degrees bool operator==( Point2d) ; bool operator!=( Point2d p) {return !operator==(p); } void dump(String m); // write point p to output stream, printing message m void dump(); // dump without message void read(); // reads the x and y coordinates of point p from standard input }; // OTHER: Point2d center(Point2d a, Point2d b); int orientation2d( Point2d a, Point2d b, Point2d c); double area( Point2d a, Point2d b, Point2d c); bool collinear( Point2d a, Point2d b, Point2d c);