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 OUTERSTEPS 40 00027 #define INNERSTEPS 20 00028 #define XTRANS 0.0 00029 #define YTRANS 15.0 00030 #define ZTRANS 0.0 00031 #define INNERRADIUS 4.0 00032 #define OUTERRADIUS 15.0 00033 #define PI 3.1415926535897932385 00034 00035 00036 main(int argc, char **argv) 00037 { 00038 list<vector> pl; 00039 vector p1,p2,p3; 00040 int i,j; 00041 double u,v; 00042 vector x(3); 00043 array2<vector> torus(OUTERSTEPS,INNERSTEPS); 00044 00045 for (i = 0; i < OUTERSTEPS; i++) { 00046 u = i*2.0*PI/OUTERSTEPS; 00047 for (j = 0; j < INNERSTEPS; j++) { 00048 v = j*2.0*PI/INNERSTEPS; 00049 x[0] = XTRANS + (OUTERRADIUS + INNERRADIUS * cos(v))*cos(u); 00050 x[1] = YTRANS + INNERRADIUS * sin(v); 00051 x[2] = ZTRANS + (OUTERRADIUS + INNERRADIUS * cos(v))*sin(u); 00052 torus(i,j) = x; 00053 } 00054 } 00055 00056 for (i = 0; i < OUTERSTEPS; i++) { 00057 for (j = 0; j < INNERSTEPS; j++) { 00058 p1 = torus(i,j); 00059 p2 = torus((i+1) % OUTERSTEPS,j); 00060 p3 = torus(i,(j+1) % INNERSTEPS); 00061 cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") "; 00062 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ") "; 00063 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ")\n"; 00064 p1 = torus(i,(j+1) % INNERSTEPS); 00065 p2 = torus((i+1) % OUTERSTEPS,j); 00066 p3 = torus((i+1) % OUTERSTEPS ,(j+1) % INNERSTEPS); 00067 cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") "; 00068 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ") "; 00069 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ")\n"; 00070 } 00071 } 00072 00073 } 00074 00075