SpherePackingScenarioGenerator
|
00001 /* 00002 * StaggeredCircles.h 00003 * 00004 * Created on: Jun 25, 2012 00005 * Author: liebm 00006 */ 00007 00008 #include "algorithms/AbstractSpherePacking.h" 00009 #include "tarch/la/Vector.h" 00010 #include <iostream> 00011 00012 #ifndef STAGGEREDCIRCLES_H_ 00013 #define STAGGEREDCIRCLES_H_ 00014 00015 namespace algorithms { 00016 namespace staggeredcircles { 00017 class StaggeredCircles; 00018 }} 00019 00020 class algorithms::staggeredcircles::StaggeredCircles: public algorithms::AbstractSpherePacking { 00021 public: 00025 StaggeredCircles( 00026 const double nSpheres, 00027 const double distance 00028 ); 00029 00033 virtual 00034 ~StaggeredCircles(); 00035 00036 00037 virtual void generate() { 00038 std::cout <<"number of spheres: " <<_numberOfSpheres <<std::endl; 00039 _radius = 0.5* (1.0 - _distance*(_numberOfSpheres+1))/_numberOfSpheres;//0.5 * (1.0 - _distance*(_nSpheres+1)) / _nSpheres; // radius of the spheres 00040 const double spatialDelta = 1.0/(_numberOfSpheres+1); 00041 for(unsigned int i=1; i <= _numberOfSpheres/2; i++) { 00042 for(unsigned int j = 1; j <= _numberOfSpheres; j++) { 00043 _spheres.push_back(algorithms::geometries::SphereGeometry( 00044 j*spatialDelta, 00045 i*spatialDelta, 00046 0.0, 00047 _radius 00048 )); 00049 } 00050 } 00051 } 00052 00053 private: 00054 const double _distance; 00055 }; 00056 00057 #endif /* STAGGEREDCIRCLES_H_ */