Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPolyline3D.cc
Go to the documentation of this file.
1#include <iostream>
2#include <fstream>
3
5using namespace JGEOMETRY3D ;
6using namespace std ;
7
8inline void printPolyline(const JPolyline3D& pl) {
9 for (int i=0; i<(int)pl.size()-1; ++i) {
10 cout << "(" << pl[i] << ")-" ;
11 }
12 if (pl.size() > 0) {
13 cout << "(" << pl.back() << ")";
14 }
15}
16
17/**
18 * \file
19 *
20 * Example program for the JGEOMETRY::JPolyline3D class.
21 * \author mjongen
22 */
23int main( int argc, char** argv ) {
24 // create a polyline with three vertices
25 JPolyline3D pl(3) ;
26
27 // set vertex positions
28 pl[0] = JGEOMETRY3D::JVector3D(1,0,0) ;
29 pl[1] = JGEOMETRY3D::JVector3D(0,1,0) ;
30 pl[2] = JGEOMETRY3D::JVector3D(0,0,1) ;
31
32 // print vertex positions
33 cout << "Initial polyline: " << endl ;
34 printPolyline(pl) ;
35 cout << endl ;
36
37 // create rotation around the z-axis
38 JRotation3Z R( 0.5*M_PI ) ;
39
40 // rotate
41 pl.rotate(R) ;
42 cout << "After a 90 degree rotation around the z-axis:" << endl ;
43 printPolyline(pl) ;
44 cout << endl ;
45
46 // rotate back
47 pl.rotate_back(R) ;
48 cout << "After rotating back:" << endl ;
49 printPolyline(pl) ;
50 cout << endl ;
51
52 cout << endl ;
53 cout << "Done!" << endl ;
54
55 return 0 ;
56}
int main(int argc, char **argv)
void printPolyline(const JPolyline3D &pl)
Definition JPolyline3D.cc:8
Data structure for polyline in three dimensions.
JPolyline3D & rotate(const JRotation3D &R)
Rotate all vertices.
JPolyline3D & rotate_back(const JRotation3D &R)
Rotate back all vertices.
Rotation around Z-axis.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19