00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdlib.h>
00020 #include <stream.h>
00021
00022 #include <LEDA/list.h>
00023 #include <LEDA/vector.h>
00024 #include <LEDA/array2.h>
00025
00026 #define LENGTHSTEPS 50
00027 #define CIRCLESTEPS 30
00028 #define PI 3.1415926535897932385
00029
00030
00031 main(int argc, char **argv)
00032 {
00033 list<vector> pl;
00034 vector p1,p2,p3,p4;
00035 int i,j;
00036 double u,v;
00037 vector x(3);
00038 array2<vector> cylinder(LENGTHSTEPS,CIRCLESTEPS);
00039
00040 if (argc < 6) {
00041 cout << "Usage: cylinder xp yp zp rad len\n";
00042 exit(-1);
00043 }
00044
00045 double xp = atof(argv[1]);
00046 double yp = atof(argv[2]);
00047 double zp = atof(argv[3]);
00048 double radius = atof(argv[4]);
00049 double length = atof(argv[5]);
00050
00051 for (i = 0; i < LENGTHSTEPS; i++) {
00052 u = i*length/LENGTHSTEPS;
00053 for (j = 0; j < CIRCLESTEPS; j++) {
00054 v = j*2.0*PI/CIRCLESTEPS;
00055 x[0] = xp + radius*cos(v);
00056 x[1] = yp + u;
00057 x[2] = zp + radius*sin(v);
00058 cylinder(i,j) = x;
00059 }
00060 }
00061
00062 for (i = 0; i < LENGTHSTEPS; i++) {
00063 for (j = 0; j < CIRCLESTEPS; j++) {
00064 p1 = cylinder(i,j);
00065 p2 = cylinder((i+1) % LENGTHSTEPS,j);
00066 p3 = cylinder(i,(j+1) % CIRCLESTEPS);
00067 p4 = cylinder((i+1) % LENGTHSTEPS, (j+1) % CIRCLESTEPS);
00068 cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") ";
00069 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")";
00070 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ")\n";
00071
00072 cout << "(" << p4[0] << "," << p4[1] << "," << p4[2] << ")";
00073 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ")";
00074 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")\n ";
00075 }
00076 }
00077
00078 }
00079
00080
00081
00082
00083
00084