public static Mass Generate(Distance bodyDiameter, string bodyDensity) { Distance radius = bodyDiameter / 2; double volume = (4 * Math.PI) / 3 * Math.Pow(radius.ToMeters().Value, 3); double density = 0; switch (bodyDensity) { case PlanetDensities.Low: density = PerturbHelper.Change(650, 1500); // kg/m^3 break; case PlanetDensities.Average: density = PerturbHelper.Change(1500, 3000); break; case PlanetDensities.High: density = PerturbHelper.Change(3000, 6000); break; } double kgs = volume * density; Mass mass = new Mass { Value = kgs, Units = MassUnits.Kilogram }; return(mass); }
public static Distance Generate(IStar primaryStar, IOrbitingBody companionStar, short orbitNumberToGenerate) { if (companionStar.OrbitNumber >= 99) { return(OrbitRangeGenerator.Generate(orbitNumberToGenerate)); } IOrbitingBody innerObject = primaryStar.InnerOrbitingBody(companionStar.OrbitNumber); IOrbitingBody outerObject = primaryStar.OuterOrbitingBody(companionStar.OrbitNumber); Distance min = new Distance(0.1, DistanceUnits.AstronomicalUnit); Distance max; Distance maxPrimary = companionStar.OrbitalDistance / 4; if (innerObject == null && outerObject == null) { max = maxPrimary; } else if (innerObject == null) { Distance maxOuter = (outerObject.OrbitalDistance - companionStar.OrbitalDistance) / 4; if (maxOuter > maxPrimary) { max = maxPrimary; } else { max = maxOuter; } } else if (outerObject == null) { max = (companionStar.OrbitalDistance - innerObject.OrbitalDistance) / 4; } else { Distance maxInner = (companionStar.OrbitalDistance - innerObject.OrbitalDistance) / 4; Distance maxOuter = (outerObject.OrbitalDistance - companionStar.OrbitalDistance) / 4; if (maxInner > maxOuter) { max = maxOuter; } else { max = maxInner; } } Distance orbitalStep = (max - min) / SystemConstants.MaxOrbits; Distance variation = orbitalStep * .4; //So outer can't hit inner Distance baseOrbit = orbitalStep * orbitNumberToGenerate; return(PerturbHelper.Change(baseOrbit - variation, baseOrbit + variation)); }
public static Distance Generate(short orbitNumber) { double r; switch (orbitNumber) { case 0: r = 0.1 + PerturbHelper.Change(0.1); break; /* 0.2 */ case 1: r = 0.3 + PerturbHelper.Change(0.1); break; /* 0.4 */ case 2: r = 0.6 + PerturbHelper.Change(0.1); break; /* 0.7 */ case 3: r = 0.8 + PerturbHelper.Change(0.2); break; /* 1.0 */ case 4: r = 1.2 + PerturbHelper.Change(0.4); break; /* 1.6 */ case 5: r = 2.0 + PerturbHelper.Change(0.8); break; /* 2.8 */ case 6: r = 3.6 + PerturbHelper.Change(1.6); break; /* 5.2 */ case 7: r = 6.8 + PerturbHelper.Change(3.2); break; /* 10.0 */ case 8: r = 13.2 + PerturbHelper.Change(6.4); break; /* 19.6 */ case 9: r = 26.0 + PerturbHelper.Change(12.8); break; /* 38.8 */ case 10: r = 51.6 + PerturbHelper.Change(25.6); break; /* 77.2 */ case 11: r = 102.8 + PerturbHelper.Change(51.2); break; /* 154.0 */ case 12: r = 205.2 + PerturbHelper.Change(102.4); break; /* 307.6 */ case 13: r = 410.0 + PerturbHelper.Change(204.8); break; /* 614.8 */ case 14: r = 819.6 + PerturbHelper.Change(409.6); break; /* 1229.2 */ case 15: r = 1638.8 + PerturbHelper.Change(819.2); break; /* 2548.0 */ case 16: r = 3277.2 + PerturbHelper.Change(1638.4); break; /* 4915.6 */ case 17: r = 6554.0 + PerturbHelper.Change(3276.8); break; /* 9830.8 */ case 18: r = 13107.6 + PerturbHelper.Change(6553.6); break; /* 19661.2 */ case 19: r = 26214.8 + PerturbHelper.Change(13107.2); break; /* 39322.0 */ default: throw new Exception("Unexpected orbit"); } Distance output = new Distance { Value = r, Units = DistanceUnits.AstronomicalUnit }; return(output); }
public static Distance Generate() { Distance min = new Distance() { Units = DistanceUnits.LightYear, Value = 0.5 }; Distance max = new Distance() { Units = DistanceUnits.LightYear, Value = 1.5 }; return(PerturbHelper.Change(min, max)); }
public static Distance Generate(string occupiedType, int size) { double planetDiameter = 0; if (occupiedType.Equals(OccupiedTypes.GasGiant)) { switch (size) { case -1: planetDiameter = 20000 + PerturbHelper.Change(20000); break; case -2: planetDiameter = 60000 + PerturbHelper.Change(100000); break; } } else if (occupiedType.Equals(OccupiedTypes.CapturedPlanet) || occupiedType.Equals(OccupiedTypes.World)) { switch (size) { case 0: planetDiameter = 200 + PerturbHelper.Change(300); break; case 1: planetDiameter = 800 + PerturbHelper.Change(800); break; case 2: planetDiameter = 2400 + PerturbHelper.Change(1600); break; case 3: planetDiameter = 4000 + PerturbHelper.Change(800); break; case 4: planetDiameter = 5600 + PerturbHelper.Change(800); break; case 5: planetDiameter = 7200 + PerturbHelper.Change(800); break; case 6: planetDiameter = 8800 + PerturbHelper.Change(800); break; case 7: planetDiameter = 10400 + PerturbHelper.Change(800); break; case 8: planetDiameter = 12000 + PerturbHelper.Change(800); break; case 9: planetDiameter = 13600 + PerturbHelper.Change(800); break; case 10: planetDiameter = 15200 + PerturbHelper.Change(800); break; } } Distance distance = new Distance { Value = planetDiameter, Units = DistanceUnits.Kilometer }; return(distance); }