Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cylinder.C

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //               The Motion Strategy Library (MSL)
00003 //----------------------------------------------------------------------
00004 //
00005 // Copyright (c) 1998-2000 Iowa State University and Steve LaValle.  
00006 // All Rights Reserved.
00007 // 
00008 // Permission to use, copy, and distribute this software and its 
00009 // documentation is hereby granted free of charge, provided that 
00010 // (1) it is not a component of a commercial product, and 
00011 // (2) this notice appears in all copies of the software and
00012 //     related documentation. 
00013 // 
00014 // Iowa State University and the author make no representations
00015 // about the suitability or fitness of this software for any purpose.  
00016 // It is provided "as is" without express or implied warranty.
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 20
00028 #define PI 3.1415926535897932385
00029 
00030 
00031 main(int argc, char **argv)
00032 { 
00033   list<vector> pl;
00034   vector p1,p2,p3;
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       cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") ";
00068       cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ") ";
00069       cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")\n";
00070       p1 = cylinder(i,(j+1) % CIRCLESTEPS);
00071       p2 = cylinder((i+1) % LENGTHSTEPS,j);
00072       p3 = cylinder((i+1) % LENGTHSTEPS ,(j+1) % CIRCLESTEPS);
00073       cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") ";
00074       cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ") ";
00075       cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")\n";
00076     }
00077   }
00078 
00079 }
00080   
00081 
Motion Strategy Library


Web page maintained by Steve LaValle
Partial support provided by NSF CAREER Award IRI-970228 (LaValle), Honda Research, and Iowa State University.
Contributors: Anna Atramentov, Peng Cheng, James Kuffner, Steve LaValle, and Libo Yang.