Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JPolyline3D.cc File Reference

Example program for the JGEOMETRY::JPolyline3D class. More...

#include <iostream>
#include <fstream>
#include "JGeometry3D/JPolyline3D.hh"

Go to the source code of this file.

Functions

void printPolyline (const JPolyline3D &pl)
 
int main (int argc, char **argv)
 

Detailed Description

Example program for the JGEOMETRY::JPolyline3D class.

Author
mjongen

Definition in file JPolyline3D.cc.

Function Documentation

◆ printPolyline()

void printPolyline ( const JPolyline3D & pl)
inline

Definition at line 8 of file JPolyline3D.cc.

8 {
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}

◆ main()

int main ( int argc,
char ** argv )

Definition at line 23 of file JPolyline3D.cc.

23 {
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}
void printPolyline(const JPolyline3D &pl)
Definition JPolyline3D.cc:8
Data structure for polyline in three dimensions.
Rotation around Z-axis.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36