// ========================================================================== // $Id: test_point.cpp,v 1.4 2018/09/10 19:37:37 jlang Exp $ // CSI2372 example Code for lecture 4 // ========================================================================== // (C)opyright: // // Jochen Lang // SITE, University of Ottawa // 800 King Edward Ave. // Ottawa, On., K1N 6N5 // Canada. // http://www.site.uottawa.ca // // Creator: jlang (Jochen Lang) // Email: jlang@site.uottawa.ca // ========================================================================== // $Log: test_point.cpp,v $ // Revision 1.4 2018/09/10 19:37:37 jlang // Simplified point2d // // Revision 1.3 2017/09/13 16:09:27 jlang // Wrapped point array in std::array. Removed use of pointers. // // Revision 1.2 2014/10/22 20:33:26 jlang // changes for lecture // // Revision 1.1 2011/09/27 17:22:21 jlang // Added bounding shape example // // Revision 1.1 2010/09/29 14:28:59 jlang // Separate files for line_segment and point2d. Added test_point and make label test // // // ========================================================================== #include #include "point2d.h" using std::cout; using std::endl; int main( ) { // Define a Point2d Point2D pt1( 0.0, 1.0 ); // Make a copy Point2D pt2(pt1); // Use brace initialization Point2D pt3{1.0,0.0}; // Call the copy constuctor again Point2D pt4 = pt3; // Default point Point2D pt5; // Test the functions if (pt1.dot( pt3 ) < 1e-9) { cout << "Dot product ok." << endl << "(Vector to Point pt1 and to pt3 are orthogonal.)" << endl; } else { cout << "Dot product failed." << endl; } Point2D res = pt1.add(pt3).subtract( pt4 ); if ( res.dot(res) < 1e-9 ) { cout << "Addition and subtraction ok." << endl; } else { cout << "Addition and/or subtraction failed." << endl; } return 0; }