Changeset 11739 for code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
- Timestamp:
- Feb 12, 2018, 12:17:34 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
r11738 r11739 115 115 } 116 116 117 void AsteroidMinable::setSize( int s)117 void AsteroidMinable::setSize(float s) 118 118 { 119 119 this->size = s; … … 214 214 if (this->size <=1){return;} // Absicherung trivialer Fall 215 215 216 int massRem = this->size-1; //some mass is lost217 int num = round(rnd()*(massRem-1)) + 1; // random number of children, at least one216 float massRem = (this->size-1); //some mass is lost 217 int num = (int)roundf(rnd(massRem-1)) + 1; // random number of children, at least one 218 218 if(num > 10){num = 10;} // no max function in C? 219 std::vector< int> masses(num); // Masses of the asteroids219 std::vector<float> masses(num); // Masses of the asteroids 220 220 // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl; 221 221 massRem = massRem-num; // mass must be at least one, add later. … … 228 228 for(int twat = 0; twat<num; ++twat) 229 229 { 230 masses[twat] = 0 ;230 masses[twat] = 0.0f; 231 231 phi[twat] = 0.0f; 232 232 theta[twat] = 0.0f; … … 236 236 float d_p = 2*piG/num; 237 237 float d_t = piG/num; 238 float p = d_p/2.0 ;239 float t = d_t/2.0 ;238 float p = d_p/2.0f; 239 float t = d_t/2.0f; 240 240 // float phiOffset = rnd()*2*pi; // Added everywhere to become independent of the coordinate system? 241 241 // float thetaOffset = rnd()*pi; … … 251 251 for(int it = 0; it<num; ++it){ 252 252 253 pos = mod((int)(rnd( )*num),num);253 pos = mod((int)(rnd((float)num)),num); 254 254 while(phi[pos] != 0.0){// find empty spot in array 255 255 pos = (int)mod(++pos, num); … … 257 257 phi[pos] = p + it*d_p;// set angle there 258 258 259 pos = mod((int)(rnd( )*num),num);259 pos = mod((int)(rnd((float)num)),num); 260 260 while(theta[pos] != 0.0){ 261 261 pos = (int)mod(++pos, num); … … 271 271 // Triangular, discrete probability "density" with max at the average value massRem/num. 50% chance to be below that. 272 272 if(massRem>0){ 273 int c = massRem;273 int c = (int)massRem; 274 274 std::vector<float> probDensity(c); 275 275 276 int a = round(massRem/num);276 int a = (int)roundf(massRem/num); 277 277 int b = c-a; 278 278 279 279 int z = 0; 280 float dProbA = 1.0 /(a*a + 3.0*a + 2.0); // one 'probability unit' for discrete ramp function. Gauss stuff.280 float dProbA = 1.0f/(a*a + 3.0f*a + 2.0f); // one 'probability unit' for discrete ramp function. Gauss stuff. 281 281 for(z = 0; z<a; ++z){probDensity[z] = (z+1)*dProbA; } // rising part 282 282 283 float dProbB = 1.0 /(b*b +3.0*b + 2.0);283 float dProbB = 1.0f/(b*b +3.0f*b + 2.0f); 284 284 for(z = 0; z<b; ++z){probDensity[c-1-z] = (z+1)*dProbB;} // falling part 285 285 … … 306 306 } 307 307 308 masses[trav] = 1 +result; // Fragments have mass of at least one.308 masses[trav] = 1.0f + result; // Fragments have mass of at least one. 309 309 massRem = massRem-result; 310 310
Note: See TracChangeset
for help on using the changeset viewer.