/// <summary> /// Generates Data for a star based on it's spectral type and populates it with the data. /// </summary> /// <remarks> /// This function randomly generates the Radius, Temperature, Luminosity, Mass and Age of a star and then returns a star populated with those generated values. /// What follows is a brief description of how that is done for each data point: /// <list type="Bullet"> /// <item> /// <b>Temperature:</b> The Temp. of the star is obtained by using the Randon.Next(min, max) function to get a random Temp. in the range a star of the given /// spectral type. /// </item> /// <item> /// <b>Luminosity:</b> The Luminosity of a star is calculated by using the RNG_NextDoubleRange() function to get a random Luminosity in the range a star of the /// given spectral type. /// </item> /// <item> /// <b>Age:</b> The possible ages for a star depend largely on its mass. The bigger and heaver the star the more pressure is put on its core where fusion occur /// which increases the rate that it burns Hydrogen which reduces the life of the star. The Big O class stars only last a few million years before either /// going Hyper Nova or devolving into a class B star. on the other hand a class G star (like Sol) has a life expectancy of about 10 billion years while a /// little class M star could last 100 billion years or more (hard to tell given that the Milky way is 13.2 billion years old and the universe is only /// about a billion years older then that). Given this we first use the mass of the star to produce a number between 0 and 1 that we can use to pick a /// possible age from the range (just like all the above). To get the number between 0 and 1 we use the following formula: /// <c>1 - Mass / MaxMassOfStarOfThisType</c> /// </item> /// </list> /// </remarks> /// <param name="starMVDB">The SystemBodyDB of the star.</param> /// <param name="spectralType">The Spectral Type of the star.</param> /// <param name="randomSelection">Random selection to generate consistent values.</param> /// <returns>A StarInfoDB Populated with data generated based on Spectral Type and SystemBodyDB information provided.</returns> private StarInfoDB GenerateStarInfo(MassVolumeDB starMVDB, SpectralType spectralType, double randomSelection) { double maxStarAge = _galaxyGen.Settings.StarAgeBySpectralType[spectralType].Max; StarInfoDB starData = new StarInfoDB {// for star age we will make it proportional to the inverse of the stars mass ratio (for that type of star). // while this will produce the same age for the same mass/type of star the chances of getting the same // mass/type are tiny. Tho there will still be the obvious inverse relationship here. Age = (1 - starMVDB.Mass / _galaxyGen.Settings.StarMassBySpectralType[spectralType].Max) * maxStarAge, SpectralType = spectralType, Temperature = (uint)Math.Round(GMath.SelectFromRange(_galaxyGen.Settings.StarTemperatureBySpectralType[spectralType], randomSelection)), Luminosity = (float)GMath.SelectFromRange(_galaxyGen.Settings.StarLuminosityBySpectralType[spectralType], randomSelection) }; // Generate a string specifying the full spectral class form a star. // start by getting the sub-division, which is based on temp. double sub = starData.Temperature / _galaxyGen.Settings.StarTemperatureBySpectralType[starData.SpectralType].Max; // temp range from 0 to 1. starData.SpectralSubDivision = (ushort)Math.Round((1 - sub) * 10); // invert temp range as 0 is hottest, 9 is coolest. // now get the luminosity class //< @todo For right now everthing is just main sequence. see http://en.wikipedia.org/wiki/Stellar_classification // on how this should be done. For right now tho class V is fine (its just flavor text). starData.LuminosityClass = LuminosityClass.V; // finally add them all up to get the class string: starData.Class = starData.SpectralType + starData.SpectralSubDivision.ToString() + "-" + starData.LuminosityClass; return(starData); }
public static void OrbCharsArgumentException(SpectralType spectralType) { if (!Enum.IsDefined(typeof(SpectralType), spectralType)) { throw new ArgumentOutOfRangeException ("Возможное значение спектрального класса: A, B, F, G, K, M, O"); } }
public Star(int id, string starName, SpectralType spectralType, float magnitude, float rectascension, float declinationAngle, float temperature, float distance) : this(starName, spectralType, magnitude, rectascension, declinationAngle, temperature, distance) { Id = id; NotifyPropertyChanged("Id"); }
public Star(int id, string starName, SpectralType spectralType, float magnitude, float rectascension, float declinationAngle, float temperature, float distance, ObservableDictionary <int, Planet> planets) : this(id, starName, spectralType, magnitude, rectascension, declinationAngle, temperature, distance) { _planets = planets; NotifyPropertyChanged("Planets"); }
public Star(string name, double radius, uint temp, float luminosity, SpectralType spectralType, StarSystem system) { Name = name; Position.System = system; Position.X = 0; Position.Y = 0; Temperature = temp; Luminosity = luminosity; SpectralType = spectralType; Radius = radius; Class = SpectralType.ToString(); Planets = new BindingList <SystemBody>(); SupportsPopulations = false; }
public Star(string name, double radius, uint temp, float luminosity, SpectralType spectralType, StarSystem system) { Name = name; Position.System = system; Position.X = 0; Position.Y = 0; Temperature = temp; Luminosity = luminosity; SpectralType = spectralType; Radius = radius; Class = SpectralType.ToString(); Planets = new BindingList<SystemBody>(); SupportsPopulations = false; }
public Star(string starName, SpectralType spectralType, float magnitude, float rectascension, float declinationAngle, float temperature, float distance) : this() { OrbNameArgumentException(starName, "планеты"); OrbCharsArgumentException(spectralType); OrbCharsArgumentException(rectascension, "прямого восхождения звезды"); OrbCharsArgumentException(temperature, "температуры звезды"); OrbCharsArgumentException(distance, "расстояния до звезды"); _name = starName; NotifyPropertyChanged("Name"); _spectralType = spectralType; NotifyPropertyChanged("SpectralType"); _magnitude = magnitude; NotifyPropertyChanged("Magnitude"); _rectascension = rectascension; NotifyPropertyChanged("Rectascension"); _declinationAngle = declinationAngle; NotifyPropertyChanged("DeclinationAngle"); _temperature = temperature; NotifyPropertyChanged("Temperature"); _distance = distance; NotifyPropertyChanged("Distance"); }
/// <summary> /// Creates a star entity in the system. /// Does not initialize an orbit. /// </summary> public Entity CreateStar(StarSystem system, double mass, double radius, double age, string starClass, double temperature, float luminosity, SpectralType spectralType, string starName = null) { double tempRange = temperature / _galaxyGen.Settings.StarTemperatureBySpectralType[spectralType].Max; // temp range from 0 to 1. ushort subDivision = (ushort)Math.Round((1 - tempRange) * 10); LuminosityClass luminosityClass = LuminosityClass.V; if (starName == null) { starName = system.NameDB.DefaultName; } int starIndex = system.GetAllEntitiesWithDataBlob <StarInfoDB>().Count; starName += " " + (char)('A' + starIndex) + " " + spectralType + subDivision + luminosityClass; MassVolumeDB starMassVolumeDB = MassVolumeDB.NewFromMassAndRadius(mass, radius); StarInfoDB starInfoDB = new StarInfoDB { Age = age, Class = starClass, Luminosity = luminosity, SpectralType = spectralType, Temperature = temperature, LuminosityClass = luminosityClass, SpectralSubDivision = subDivision }; PositionDB starPositionDB = new PositionDB(new Vector3(0, 0, 0), system.Guid); NameDB starNameDB = new NameDB(starName); OrbitDB starOrbitDB = new OrbitDB(); SensorProfileDB emmisionSignature = SensorProcessorTools.SetStarEmmisionSig(starInfoDB, starMassVolumeDB); return(new Entity(system, new List <BaseDataBlob> { starOrbitDB, starMassVolumeDB, starInfoDB, starNameDB, starPositionDB, emmisionSignature })); }