Advertisement
ibuckshot5

maple random system generator c++

Jul 31st, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.69 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. ofstream output ("output.cfg");
  11. string name;
  12. cout << "Name:";
  13. cin >> name;
  14. output << "@Kopernicus:AFTER[Kopernicus]" << '\n';
  15. output << "{" << '\n';
  16. output << " Body" << '\n';
  17. output << "    {" << '\n';
  18. output << "        name = " << name << '\n';
  19. output << "        Template" << '\n';
  20. output << "        {" << '\n';
  21. output << "            name = Sun" << '\n';
  22. output << "            removeProgressTree = false" << '\n';
  23. output << "        }" << '\n';
  24. output << "        Properties" << '\n';
  25. output << "        {" << '\n';
  26. output << "         mass = 7.0950549e+26" << '\n';
  27. output << "         radius = 6571392" << '\n';
  28. output << "         description = A potentially habitable brown dwarf." << '\n';
  29. output << "        }" << '\n';
  30. output << "     Orbit" << '\n';
  31. output << "        {" << '\n';
  32. output << "            referenceBody = Sun" << '\n';
  33. output << "         inclination = 0" << '\n';
  34. output << "            eccentricity = 0" << '\n';
  35. output << "            semiMajorAxis = 1E+14" << '\n';
  36. output << "            longitudeOfAscendingNode = 0" << '\n';
  37. output << "            argumentOfPeriapsis = 0" << '\n';
  38. output << "            meanAnomalyAtEpoch = 0" << '\n';
  39. output << "            epoch = 0" << '\n';
  40. output << "         color = 0.3,0.0,0.0,0.5" << '\n';
  41. output << "        }" << '\n';
  42. output << "        ScaledVersion" << '\n';
  43. output << "        {" << '\n';
  44. output << "         SolarLightColor" << '\n';
  45. output << "         {" << '\n';
  46. output << "             " << '\n';
  47. output << "             sunlightColor = 1.0, 0.0, 0.0, 1.0" << '\n';
  48. output << "             sunlightIntensity = 0.45" << '\n';
  49. output << "             scaledSunlightColor = 1.0, 0.0, 0.0, 1.0" << '\n';
  50. output << "             scaledSunlightIntensity = 0.45" << '\n';
  51. output << "             IVASunColor = 1.0, 0.977, 0.896, 1.0" << '\n';
  52. output << "             IVASunIntensity = 0.34" << '\n';
  53. output << "             sunLensFlareColor = 0.2, 0.0, 0.0, 1.0" << '\n';
  54. output << "             sunAU = 13599840256" << '\n';
  55. output << "             brightnessCurve" << '\n';
  56. output << "             {" << '\n';
  57. output << "                 key = -0.01573471 0.217353 1.706627 1.706627" << '\n';
  58. output << "                 key = 5.084181 3.997075 -0.001802375 -0.001802375" << '\n';
  59. output << "                 key = 38.56295 1.82142 0.0001713 0.0001713" << '\n';
  60. output << "             }" << '\n';
  61. output << "         }" << '\n';
  62. output << "         " << '\n';
  63. output << "         Material" << '\n';
  64. output << "            {" << '\n';
  65. output << "                emitColor0 = 0.3,0.0,0.2,1.0" << '\n';
  66. output << "                emitColor1 = 0.3,0.0,0.2,1.0" << '\n';
  67. output << "                sunspotColor = 1.0,0.0,0.0,1.0" << '\n';
  68. output << "                rimColor = 0.4,0.05,0.05,1.0" << '\n';
  69. output << "             rimPower = 0" << '\n';
  70. output << "             rimBlend = 1.4" << '\n';
  71. output << "            }" << '\n';
  72. output << "" << '\n';
  73. output << "" << '\n';
  74. output << "            Coronas" << '\n';
  75. output << "            {" << '\n';
  76. output << "                Corona" << '\n';
  77. output << "                {" << '\n';
  78. output << "                    rotation = 0" << '\n';
  79. output << "                    speed = -1" << '\n';
  80. output << "                    updateInterval = 5" << '\n';
  81. output << "                    scaleLimitX = 5" << '\n';
  82. output << "                    scaleLimitY = 5" << '\n';
  83. output << "                    scaleSpeed = 0.007" << '\n';
  84. output << "" << '\n';
  85. output << "                    Material" << '\n';
  86. output << "                    {" << '\n';
  87. output << "                        texture = ProcBrownDwarves/corona.png" << '\n';
  88. output << "                        inverseFade = 2.553731" << '\n';
  89. output << "                    }" << '\n';
  90. output << "                }" << '\n';
  91. output << "" << '\n';
  92. output << "                Corona" << '\n';
  93. output << "                {" << '\n';
  94. output << "                    rotation = 0" << '\n';
  95. output << "                    speed = 1" << '\n';
  96. output << "                    updateInterval = 5" << '\n';
  97. output << "                    scaleLimitX = 5" << '\n';
  98. output << "                    scaleLimitY = 5" << '\n';
  99. output << "                    scaleSpeed = 0.009" << '\n';
  100. output << "" << '\n';
  101. output << "                    Material" << '\n';
  102. output << "                    {" << '\n';
  103. output << "                        texture = ProcBrownDwarves/corona.png" << '\n';
  104. output << "                        inverseFade = 2.553731" << '\n';
  105. output << "                    }" << '\n';
  106. output << "                }" << '\n';
  107. output << "            }" << '\n';
  108. output << "        }" << '\n';
  109. output << "        SolarPowerCurve" << '\n';
  110. output << "        {" << '\n';
  111. output << "            key = 206000000000 0 0 0" << '\n';
  112. output << "            key = 13599840256 1 0 0" << '\n';
  113. output << "            key = 68773560320 0.5 0 0" << '\n';
  114. output << "            key = 0 10 0 0" << '\n';
  115. output << "        }" << '\n';
  116. output << "    } " << '\n';
  117. int planets;
  118. int moons = 3;
  119. cout << "Number of planets to generate:";
  120. cin >> planets;
  121. int pcounter = 1;
  122. int mcounter = 1;
  123. int body;
  124. float mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  125. //store constants
  126. double period, relativeMass, relativeDensity, relativeRadius;
  127.  
  128. double mass, radius, density, factor, sma;
  129.  
  130. double inc, ecc, fcc, man;
  131.  
  132. double log10 = 2.302;
  133. double v1=-0.209594; //constants from the exoplanet mass-radius paper - Seager et al
  134. double v2=0.0799;
  135. double v3=0.413;
  136. double vm=10.55;    //mass scaling factor
  137. double vr=3.9;  // radius scaling factor   
  138. do
  139. {
  140.     body = rand() % 3;
  141.     if (body == 0)
  142.     {
  143.        mass = ((mrand*10 + 0.1)*100)/100;
  144.        mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  145.        factor = v1+1/3*log10*(mass/vm)-v2*pow((mass/vm),v3);
  146.        radius = (pow(10,factor)*vr*6371)*100;
  147.        density = mass*4.0e12/(4/3*3.1416*pow(radius,3))/0.62/5.52;
  148.     }
  149.     else
  150.     {
  151.        mass = ((mrand/40+0.0001)*10000)/10000;
  152.        mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  153.        density = ((mrand*4 + 1) *100)/100/5.52;
  154.        factor = v1+1/3*log10*(mass/vm)-v2*pow((mass/vm),v3);
  155.        radius = (pow(10,factor)*vr*1415)*100;
  156.     }
  157.     mcounter = 1;
  158.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  159.     period = (((mrand*22 + 8 )*10 )/10)*3600;
  160.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  161.     sma = (mrand * 5);
  162.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  163.     inc = (mrand * 5);
  164.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  165.     ecc = (mrand / 10);
  166.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  167.     man = (mrand * 6.28318531);
  168.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  169.     fcc = rand() % 361;
  170.     output << " Body" << '\n';
  171.     output << " {" << '\n';
  172.     output << "     name = " << name << " " << pcounter << '\n';
  173.     output << "     Template" << '\n';
  174.     output << "     {" << '\n';
  175.     output << "         name = Tylo" << '\n';
  176.     output << "     }" << '\n';
  177.     output << "     Properties" << '\n';
  178.     output << "     {" << '\n';
  179.     output << "         description = A planet" << '\n';
  180.     output << "         radius = " << radius << '\n';
  181.     output << "         mass = 5.29157926281091E+22" << '\n';
  182.     output << "         @mass *= " << mass << '\n';
  183.     output << "         rotates = True" << '\n';
  184.     output << "         rotationPeriod = " << period << '\n';
  185.     output << "         tidallyLocked = false" << '\n';
  186.     output << "         initialRotation = 0" << '\n';
  187.     output << "     }" << '\n';
  188.     output << "     Orbit" << '\n';
  189.     output << "     {" << '\n';
  190.     output << "         referenceBody = " << name << '\n';
  191.     output << "         inclination = " << inc << '\n';
  192.     output << "         eccentricity = " << ecc << '\n';
  193.     output << "         semiMajorAxis = 1359984025" << '\n';
  194.     output << "         @semiMajorAxis *= " << sma << '\n';
  195.     output << "         longitudeOfAscendingNode = " << fcc << '\n';
  196.     fcc = rand() % 361;
  197.     output << "         argumentOfPeriapsis = " << fcc << '\n';
  198.     output << "         meanAnomalyAtEpoch = " << man << '\n';
  199.     output << "         epoch = 0" << '\n';
  200.     output << "         color = 0.5,0.5,0.5,1" << '\n';
  201.     output << "     }" << '\n';
  202.     output << " }" << '\n';
  203.     do
  204.     {
  205.     mass = ((mrand/40+0.0001)*10000)/10000;
  206.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  207.     density = ((mrand*4 + 1) *100)/100/5.52;
  208.     factor = k1+1/3*log10*(mass/km)-k2*pow((mass/km),k3);
  209.     radius = (pow(10,factor)*kr*1415)*40;
  210.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  211.     sma = (mrand * 5);
  212.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  213.     inc = (mrand * 5);
  214.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  215.     ecc = (mrand / 10);
  216.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  217.     man = (mrand * 6.28318531);
  218.     mrand = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  219.     fcc = rand() % 361;
  220.     output << " Body" << '\n';
  221.     output << " {" << '\n';
  222.     output << "     name = " << name << " " << pcounter << "." << mcounter << '\n';
  223.     output << "     Template" << '\n';
  224.     output << "     {" << '\n';
  225.     output << "         name = Tylo" << '\n';
  226.     output << "     }" << '\n';
  227.     output << "     Properties" << '\n';
  228.     output << "     {" << '\n';
  229.     output << "         description = A moon" << '\n';
  230.     output << "         radius = " << radius << '\n';
  231.     output << "         mass = 5.29157926281091E+22" << '\n';
  232.     output << "         @mass *= " << mass << '\n';
  233.     output << "         rotates = True" << '\n';
  234.     output << "         rotationPeriod = " << period << '\n';
  235.     output << "         tidallyLocked = false" << '\n';
  236.     output << "         initialRotation = 0" << '\n';
  237.     output << "     }" << '\n';
  238.     output << "     Orbit" << '\n';
  239.     output << "     {" << '\n';
  240.     output << "         referenceBody = " << name << " " << pcounter << '\n';
  241.     output << "         inclination = " << inc << '\n';
  242.     output << "         eccentricity = " << ecc << '\n';
  243.     output << "         semiMajorAxis = 12000000" << '\n';
  244.     output << "         @semiMajorAxis *= " << sma << '\n';
  245.     output << "         longitudeOfAscendingNode = " << fcc << '\n';
  246.     fcc = rand() % 361;
  247.     output << "         argumentOfPeriapsis = " << fcc << '\n';
  248.     output << "         meanAnomalyAtEpoch = " << man << '\n';
  249.     output << "         epoch = 0" << '\n';
  250.     output << "         color = 0.5,0.5,0.5,1" << '\n';
  251.     output << "     }" << '\n';
  252.     output << " }" << '\n';
  253.     mcounter++;
  254.     } while (mcounter <= moons);
  255.     pcounter++;
  256. } while (pcounter != planets);
  257. output << "}" << '\n';
  258. std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
  259. system("pause");
  260. return 0;
  261. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement