#include #include #include "point.h" #include "vector_fancyT.h" using namespace std; bool operator == (point & a, point & b) { return (a.x() == b.x() && a.y() == b.y()); } bool operator != (point & a, point & b) { return (a.x() != b.x() || a.y() != b.y()); } bool operator == (vector & u, vector & v) { return (u.x() == v.x() && u.y() == v.y()); } bool operator != (vector & u, vector & v) { return (u.x() != v.x() || u.y() != v.y()); } void print_triangle(fancy_triangle & t) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "(" << t.p1().x() << ", " << t.p1().y() << "), "; cout << "(" << t.p2().x() << ", " << t.p2().y() << "), "; cout << "(" << t.p3().x() << ", " << t.p3().y() << "),"; } void main() { int i; vector va, vb(3,4), vc(3,0); cout << "The lengthes of the three vectors are: "; va.print_vector(); cout << ":" << va.length() << ", "; vb.print_vector(); cout << ":" << vb.length() << ", " ; vc.print_vector(); cout << ":" << vc.length() << ".\n\n"; point polygon[7]= { point(0,0), point(15,42), point(35,46), point(40,30), point(20,-30), point(12,-25), point(0,0) }; point a, b(10,10), c(10,0); if (a == b || a == c || b == c) { cout << "The three points can't form a triangle!!\n"; return; } fancy_triangle t(a,b,c); cout << "The center of triangle "; print_triangle(t); cout << " is (" << t.center().x() << "," << t.center().y() << ").\n"; cout << "The area of the triangle is " << t.area() << endl << endl; vector s(1,1); t.shift(s); cout << "After shift "; s.print_vector(); cout << ": "; print_triangle(t); cout << endl; cout << "The center of triangle is (" << t.center().x() << "," << t.center().y() << ").\n"; cout << "The area of the triangle is " << t.area() << endl << endl; t = fancy_triangle(point(), point(cos(60.0/180*3.1415926), sin(60.0/180*3.1415926)),point(1,0)); print_triangle(t); double d = 0; do { cout << "\nRotate " << d << " degrees :"; t = t.rotate(d/180.0*3.1415926); print_triangle(t); cout << "\nHow many degrees: "; cin >> d; } while (d != 0); }