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 LATITUDESTEPS 30 00027 #define LONGITUDESTEPS 25 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> sphere(LATITUDESTEPS,LONGITUDESTEPS); 00039 00040 if (argc < 5) { 00041 cout << "Usage: sphere xc yc zc r \n"; 00042 exit(-1); 00043 } 00044 00045 double xc = atof(argv[1]); 00046 double yc = atof(argv[2]); 00047 double zc = atof(argv[3]); 00048 double radius = atof(argv[4]); 00049 00050 for (i = 0; i < LATITUDESTEPS; i++) { 00051 u = i*PI/(LATITUDESTEPS-1); 00052 for (j = 0; j < LONGITUDESTEPS; j++) { 00053 v = j*2.0*PI/LONGITUDESTEPS; 00054 x[0] = xc + radius*cos(v)*sin(u); 00055 x[1] = yc + radius*sin(v)*sin(u); 00056 x[2] = zc + radius*cos(u); 00057 sphere(i,j) = x; 00058 } 00059 } 00060 00061 for (i = 0; i < LATITUDESTEPS; i++) { 00062 for (j = 0; j < LONGITUDESTEPS; j++) { 00063 p1 = sphere(i,j); 00064 p2 = sphere((i+1) % LATITUDESTEPS,j); 00065 p3 = sphere(i,(j+1) % LONGITUDESTEPS); 00066 cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") "; 00067 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ") "; 00068 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")\n"; 00069 p1 = sphere(i,(j+1) % LONGITUDESTEPS); 00070 p2 = sphere((i+1) % LATITUDESTEPS,j); 00071 p3 = sphere((i+1) % LATITUDESTEPS ,(j+1) % LONGITUDESTEPS); 00072 cout << "(" << p1[0] << "," << p1[1] << "," << p1[2] << ") "; 00073 cout << "(" << p2[0] << "," << p2[1] << "," << p2[2] << ") "; 00074 cout << "(" << p3[0] << "," << p3[1] << "," << p3[2] << ")\n"; 00075 } 00076 } 00077 00078 } 00079 00080