Planet SolarSystemCreator::createPlanet( double currentDistance, bool isSatellite, Planet& planetTop, double *prevDistance) { Planet planet; if (isSatellite) planet.setParent(&planetTop); Orbit orbit; makeOrbit(orbit); makeDiameterAndDensity(isSatellite, planet, currentDistance, planetTop); double dTemp = 255 / sqrt(( currentDistance / sqrt (_star->luminosity()))); planet.setTemperature(dTemp); double dmmwr = (0.02783 * dTemp) / ( pow(planet.gravEarth(),2) ); planet.setMmwr(dmmwr); if (dmmwr < 120) planet.setAtmosphere(atVeryThin); if (dmmwr < 80) planet.setAtmosphere(atThin); if (dmmwr < 40) planet.setAtmosphere(atStandard); if (dmmwr < 20) planet.setAtmosphere(atDense); if (dmmwr < 5) { if (planet.diameter() > 20000 ) planet.setAtmosphere(atMassive); else planet.setAtmosphere(atDense); } this->setPlanetType(planet,currentDistance); if (!isSatellite) { this->setPlanetModifiers(planet); planet.setPlanetFlag(); } else { planet.setSatelliteFlag(); //qDebug() << "Satellite flag set: " << planet.isSatellite(); } if (!isSatellite) { orbit.setDistance(currentDistance); orbit.setYear(_star->mass()); } else { double sSatDist = *prevDistance; if (sSatDist <= 0) if (planetTop.planetType() != ptGasGiant) sSatDist = 105000+(double)((SSGX::dn(20)+10) * planetTop.diameter()); else sSatDist = 105000+(double)((SSGX::floatRand()*1.8+2.0) * planetTop.diameter()); else sSatDist += 80000.0+(double)((SSGX::dn(50)+25) * planet.diameter()); *prevDistance = sSatDist; orbit.setDistance(sSatDist); //in km double d1 = orbit.distance() / 40000.0; d1 = (pow(d1,3) * 793.64) / (planetTop.massEarth() + planet.massEarth()); double dYear = sqrt(d1); orbit.setFixedYear(dYear); } planet.setOrbit(orbit); int w = rand() % 10; switch (w) { case 1: planet.setName(_onomastikon->fakeNomen()); break; case 2: planet.setName(_onomastikon->fakeNomen()); break; case 3: planet.setName(_onomastikon->nomen()); break; case 4: planet.setName(_onomastikon->nomen()); break; case 5: planet.setName(_onomastikon->sigla()); break; default: planet.setName(_onomastikon->pseudoNomen()); break; } return planet; }
Planet SolarSystemCreator::createPlanet( double currentDistance, bool isSatellite, Planet& planetTop, double *prevDistance) { Planet planet; Orbit orbit; int d = SSGX::d6(); if (d == 3) orbit.setEccentricity( (double)SSGX::dn(1000) / 10000.0); else orbit.setEccentricity( (double)SSGX::dn(300) / 10000.0); if (d == 4) orbit.setInclination( (double)(SSGX::d100() -50)/30); else orbit.setInclination( (double)(SSGX::d100() -50)/5); if (d == 4) orbit.setObliquity( (double)(SSGX::d100() -50)/2); else orbit.setInclination( (double)(SSGX::d100() -50)); d = SSGX::d6(); if (currentDistance > _star->outerLifeZone()) { if (d < 5) { planet.setCoreType(NSPlanet::ctIcy); planet.setDensity( ((double)(SSGX::dn(400)))/1000*5520.0); if (!isSatellite) planet.setDiameter(SSGX::icyDiameter()); else planet.setDiameter(SSGX::satDiameter()); } else { if (!isSatellite) planet.setDiameter(SSGX::rockyDiameter()); else planet.setDiameter(SSGX::satDiameter()); planet.setDensity( ((double)(400+SSGX::dn(600)))/1000*5520.0); } } else { if (!isSatellite) planet.setDiameter(SSGX::rockyDiameter()); else planet.setDiameter(SSGX::satDiameter()); planet.setDensity( ((double)(400+SSGX::dn(900)))/1000*5520.0); } while (isSatellite && planet.diameter() > planetTop.diameter() / 3) planet.setDiameter(planet.diameter()/2); double dTemp = 255 / sqrt(( currentDistance / sqrt (_star->luminosity()))); planet.setTemperature(dTemp); double dmmwr = (0.02783 * dTemp) / ( pow(planet.gravEarth(),2) ); planet.setMmwr(dmmwr); if (dmmwr < 120) planet.setAtmosphere(atVeryThin); if (dmmwr < 80) planet.setAtmosphere(atThin); if (dmmwr < 40) planet.setAtmosphere(atStandard); if (dmmwr < 20) planet.setAtmosphere(atDense); if (dmmwr < 5) { if (planet.diameter() > 20000 ) planet.setAtmosphere(atMassive); else planet.setAtmosphere(atDense); } this->setPlanetType(planet,currentDistance); if (!isSatellite) { this->setPlanetModifiers(planet); planet.setPlanetFlag(); } else { planet.setSatelliteFlag(); //qDebug() << "Satellite flag set: " << planet.isSatellite(); } if (!isSatellite) { orbit.setDistance(currentDistance); orbit.setYear(_star->mass()); } else { double sSatDist = *prevDistance; if (sSatDist <= 0) sSatDist = 35000+(double)((SSGX::dn(90)+30) * planet.diameter()); else sSatDist += (double)((SSGX::dn(70)+10) * planet.diameter()); *prevDistance = sSatDist; orbit.setDistance(sSatDist); //in km double d1 = orbit.distance() / 40000.0; d1 = (pow(d1,3) * 793.64) / (planetTop.massEarth() + planet.massEarth()); double dYear = sqrt(d1); orbit.setFixedYear(dYear); } planet.setOrbit(orbit); int w = rand() % 10; switch (w) { case 1: planet.setName(_onomastikon->fakeNomen()); break; case 2: planet.setName(_onomastikon->fakeNomen()); break; case 3: planet.setName(_onomastikon->nomen()); break; case 4: planet.setName(_onomastikon->nomen()); break; case 5: planet.setName(_onomastikon->sigla()); break; default: planet.setName(_onomastikon->pseudoNomen()); break; } return planet; }