Jpp
examples
JGeometry3D
JPolyline3D.cc
Go to the documentation of this file.
1
#include <iostream>
2
#include <fstream>
3
4
#include "
JGeometry3D/JPolyline3D.hh
"
5
using namespace
JGEOMETRY3D
;
6
using namespace
std
;
7
8
inline
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
*/
23
int
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
}
JGEOMETRY3D::JPolyline3D::rotate_back
JPolyline3D & rotate_back(const JRotation3D &R)
Rotate back all vertices.
Definition:
JPolyline3D.hh:83
JGEOMETRY3D::JPolyline3D::rotate
JPolyline3D & rotate(const JRotation3D &R)
Rotate all vertices.
Definition:
JPolyline3D.hh:72
JGEOMETRY3D::JVector3D
Data structure for vector in three dimensions.
Definition:
JVector3D.hh:33
printPolyline
void printPolyline(const JPolyline3D &pl)
Definition:
JPolyline3D.cc:8
JGEOMETRY3D::JRotation3Z
Rotation around Z-axis.
Definition:
JRotation3D.hh:85
main
int main(int argc, char **argv)
Definition:
JPolyline3D.cc:23
JPolyline3D.hh
std
Definition:
jaanetDictionary.h:36
JGEOMETRY3D
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition:
JAngle3D.hh:18
JGEOMETRY3D::JPolyline3D
Data structure for polyline in three dimensions.
Definition:
JPolyline3D.hh:25
Generated by
1.8.16