#include #include #include "JGeometry3D/JPolyline3D.hh" using namespace JGEOMETRY3D ; using namespace std ; inline void printPolyline(const JPolyline3D& pl) { for (int i=0; i<(int)pl.size()-1; ++i) { cout << "(" << pl[i] << ")-" ; } if (pl.size() > 0) { cout << "(" << pl.back() << ")"; } } /** * \file * * Example program for the JGEOMETRY::JPolyline3D class. * \author mjongen */ int main( int argc, char** argv ) { // create a polyline with three vertices JPolyline3D pl(3) ; // set vertex positions pl[0] = JGEOMETRY3D::JVector3D(1,0,0) ; pl[1] = JGEOMETRY3D::JVector3D(0,1,0) ; pl[2] = JGEOMETRY3D::JVector3D(0,0,1) ; // print vertex positions cout << "Initial polyline: " << endl ; printPolyline(pl) ; cout << endl ; // create rotation around the z-axis JRotation3Z R( 0.5*M_PI ) ; // rotate pl.rotate(R) ; cout << "After a 90 degree rotation around the z-axis:" << endl ; printPolyline(pl) ; cout << endl ; // rotate back pl.rotate_back(R) ; cout << "After rotating back:" << endl ; printPolyline(pl) ; cout << endl ; cout << endl ; cout << "Done!" << endl ; return 0 ; }