Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace StellarScaper
- {
- public struct Vector2
- {
- public double x;
- public double y;
- public Vector2(double x, double y)
- {
- this.x = x;
- this.y = y;
- }
- }
- public struct Vector3
- {
- public double x;
- public double y;
- public double z;
- public Vector3(double x, double y, double z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- }
- public struct Vector4
- {
- public double x;
- public double y;
- public double z;
- public double a;
- public Vector4(double x, double y, double z, double a)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- this.a = a;
- }
- }
- public static class Utilities
- {
- private static double sunMagnitude = 4.83;
- private static double PI = 3.14159265358979;
- private static double GasConstant = 8.3145;
- private static double PlanckConstant = 6.582119514 * Math.Pow(10, -16);
- private static double LightSpeed = 299792458;
- private static double AvogadroConstant = 6.022140857 * Math.Pow(10, 23);
- private static double BoltzmannConstant = GasConstant / AvogadroConstant;
- public static double StefanBoltzmannConstant = 5.670367 * Math.Pow(10, -8);
- public static double GravitationalConstant = 6.67408 * Math.Pow(10, -11);
- public static class Double
- {
- private static Random randomizer;
- public static double Lerp(double a, double b, double percent)
- {
- return (a + percent * (b - a));
- }
- public static Vector2 Lerp(Vector2 a, Vector2 b, double percent)
- {
- return new Vector2((a.x + percent * (b.x - a.x)), (a.y + percent * (b.y - a.y)));
- }
- public static Vector3 Lerp(Vector3 a, Vector3 b, double percent)
- {
- return new Vector3((a.x + percent * (b.x - a.x)), (a.y + percent * (b.y - a.y)), (a.z + percent * (b.z - a.z)));
- }
- public static Vector4 Lerp(Vector4 a, Vector4 b, double percent)
- {
- return new Vector4((a.x + percent * (b.x - a.x)), (a.y + percent * (b.y - a.y)), (a.z + percent * (b.z - a.z)), (a.a + percent * (b.a - a.a)));
- }
- public static double Random()
- {
- if (randomizer == null)
- {
- randomizer = new Random();
- }
- return 0 + randomizer.NextDouble() * (100 - 0);
- }
- public static double Random(double maximum, double minimum)
- {
- if (randomizer == null)
- {
- randomizer = new Random();
- }
- return minimum + randomizer.NextDouble() * (maximum - minimum);
- }
- public static Vector2 Random(Vector2 a, Vector2 b)
- {
- return new Vector2(Random(a.x, b.x), Random(a.y, b.y));
- }
- public static Vector3 Random(Vector3 a, Vector3 b)
- {
- return new Vector3(Random(a.x, b.x), Random(a.y, b.y), Random(a.z, b.z));
- }
- public static Vector4 Random(Vector4 a, Vector4 b)
- {
- return new Vector4(Random(a.x, b.x), Random(a.y, b.y), Random(a.z, b.z), Random(a.a, b.a));
- }
- }
- public static class Calculate
- {
- public static double SolarMassToKg(double solarMass)
- {
- return solarMass * (1.989 * Math.Pow(10, 30));
- }
- public static double KgToSolarMass(double Kg)
- {
- return Kg / (1.989 * Math.Pow(10, 30));
- }
- public static double SolarRadiusToKm(double solarRadius)
- {
- return solarRadius * (695800);
- }
- public static double KmToSolarRadius(double Km)
- {
- return Km / (695800);
- }
- public static double MeterToKm(double meter)
- {
- return meter / 1000;
- }
- public static double KmToMeter(double Km)
- {
- return Km * 1000;
- }
- public static double GetWattsFromSolarLuminosity(double watts)
- {
- return watts * (3.827 * Math.Pow(10, 26));
- }
- public static double GetSolarLuminosityFromWatts(double solarLuminosity)
- {
- return solarLuminosity / (3.827 * Math.Pow(10, 26));
- }
- public static double GetVolumeFromRadius(double radius)
- {
- return (4d / 3d) * PI * Math.Pow(radius, 2);
- }
- public static double GetRadiusFromVolume(double volume)
- {
- return Math.Pow(volume / ((4 / 3) * PI), 1d / 2d);
- }
- public static double GetDensityFromMassAndVolume(double mass, double volume)
- {
- return mass / volume;
- }
- public static double GetMassFromDensityAndVolume(double density, double volume)
- {
- return density * volume;
- }
- public static double GetVolumeFromMassAndDensity(double mass, double density)
- {
- return mass / density;
- }
- public class Star
- {
- public static double SolarLuminosityToMagnitude(double luminosity)
- {
- return sunMagnitude - (Math.Pow(100d, 1d / 5d) * Math.Log10(luminosity));
- }
- public static double MagnitudeToSolarLuminosity(double magnitude)
- {
- return Math.Pow(Math.Pow(100d, 1d / 5d), sunMagnitude - magnitude);
- }
- public static double GetSolarMassFromLuminosity(double solarLuminosity)
- {
- if (solarLuminosity <= (.23 * Math.Pow(.43, 2.3)))
- {
- return Math.Pow(solarLuminosity / .23d, 1d / 2.3d);
- }
- else if (solarLuminosity < Math.Pow(2d, 4d))
- {
- return Math.Pow(solarLuminosity, 1d / 4d);
- }
- else if (solarLuminosity < 1.5 * Math.Pow(20d, 3.5d))
- {
- return Math.Pow(solarLuminosity / 1.5d, 1d / 3.5d);
- }
- else
- {
- return solarLuminosity / 3200;
- }
- }
- public static double GetLuminosityFromSolarMass(double solarMass)
- {
- if (solarMass <= .43)
- {
- return (.23 * Math.Pow(solarMass, 2.3));
- }
- else if (solarMass <= 2)
- {
- return (Math.Pow(solarMass, 4));
- }
- else if (solarMass <= 20)
- {
- return (1.5 * (Math.Pow(solarMass, 3.5)));
- }
- else
- {
- return 3200 * solarMass;
- }
- }
- public static double GetMeterRadiusFromTempAndWatts(double temperature, double watts) //temperature is in kelvin
- {
- return Math.Pow(watts / (4d * PI * StefanBoltzmannConstant * Math.Pow(temperature, 4d)), 1d / 2d);
- }
- public static double GetWattsFromTempAndMeterRadius(double temperature, double meters)
- {
- return 4 * PI * Math.Pow(meters, 2) * StefanBoltzmannConstant * Math.Pow(temperature, 4);
- }
- public static double GetTempFromWattsAndMeterRadius(double watts, double meters)
- {
- return Math.Pow(watts / (4 * PI * StefanBoltzmannConstant * Math.Pow(meters, 2)), 1d / 4d);
- }
- public static double GetGravityFromRadiusAndMass(double radius, double mass) //radius is in meters, mass is in kilograms, gravity is in meters/second
- {
- return GravitationalConstant * mass / Math.Pow(radius, 2);
- }
- public static double GetMassFromGravityAndRadius(double gravity, double radius)
- {
- return (gravity * Math.Pow(radius, 2)) / GravitationalConstant;
- }
- public static double GetRadiusFromGravityAndMass(double gravity, double mass)
- {
- return Math.Pow((mass * GravitationalConstant) / gravity, 1d / 2d);
- }
- public static class Color
- {
- public static double GetTempFromBVColor(double bv)
- {
- return 4600 * ((1 / ((0.92 * bv) + 1.7)) + (1 / ((0.92 * bv) + 0.62)));
- }
- public static Vector2 GetXYyFromTemp(double temperature)
- {
- Vector2 vec = new Vector2();
- if (temperature >= 1667 && temperature <= 4000)
- {
- vec.x = ((-0.2661239 * Math.Pow(10, 9)) / Math.Pow(temperature, 3)) + ((-0.2343580 * Math.Pow(10, 6)) / Math.Pow(temperature, 2)) + ((0.8776956 * Math.Pow(10, 3)) / temperature) + 0.179910;
- }
- else if (temperature > 4000 && temperature <= 25000)
- {
- vec.x = ((-3.0258469 * Math.Pow(10, 9)) / Math.Pow(temperature, 3)) + ((2.1070379 * Math.Pow(10, 6)) / Math.Pow(temperature, 2)) + ((0.2226347 * Math.Pow(10, 3)) / temperature) + 0.240390;
- }
- if (temperature >= 1667 && temperature <= 2222)
- {
- vec.y = -1.1063814 * Math.Pow(vec.x, 3) - 1.34811020 * Math.Pow(vec.x, 2) + 2.18555832 * vec.x - 0.20219683;
- }
- else if (temperature > 2222 && temperature <= 4000)
- {
- vec.y = -0.9549476 * Math.Pow(vec.x, 3) - 1.37418593 * Math.Pow(vec.x, 2) + 2.09137015 * vec.x - 0.16748867;
- }
- else if (temperature > 4000 && temperature <= 25000)
- {
- vec.y = 3.0817580 * Math.Pow(vec.x, 3) - 5.87338670 * Math.Pow(vec.x, 2) + 3.75112997 * vec.x - 0.37001483;
- }
- return vec;
- }
- public static Vector3 GetXYZFromXYy(Vector2 XYy)
- {
- Vector3 vec = new Vector3();
- vec.y = (XYy.y == 0) ? 0 : 1;
- vec.x = (XYy.y == 0) ? 0 : (XYy.x * vec.y) / XYy.y;
- vec.z = (XYy.y == 0) ? 0 : ((1 - XYy.x - XYy.y) * vec.y) / XYy.y;
- return vec;
- }
- public static Vector3 GetRGBFromXYZ(Vector3 XYZ)
- {
- Vector3 rgb = new Vector3();
- rgb.x = 3.2406 * XYZ.x - 1.5372 * XYZ.y - 0.4986 * XYZ.z;
- rgb.y = -0.9689 * XYZ.x + 1.8758 * XYZ.y + 0.0415 * XYZ.z;
- rgb.z = 0.0557 * XYZ.x - 0.2040 * XYZ.y + 1.0570 * XYZ.z;
- Vector3 RGB = new Vector3();
- RGB.x = (rgb.x <= 0.0031308) ? 12.92 * rgb.x : 1.055 * Math.Pow(rgb.x, 1 / 0.5) - 0.055;
- RGB.y = (rgb.y <= 0.0031308) ? 12.92 * rgb.y : 1.055 * Math.Pow(rgb.y, 1 / 0.5) - 0.055;
- RGB.z = (rgb.y <= 0.0031308) ? 12.92 * rgb.y : 1.055 * Math.Pow(rgb.y, 1 / 0.5) - 0.055;
- return RGB;
- }
- public static Vector3 GetColorFromTemp(double temperature)
- {
- return GetRGBFromXYZ(GetXYZFromXYy(GetXYyFromTemp(temperature)));
- }
- }
- }
- }
- }
- public static class StarGeneration
- {
- public static Vector2[] GetCords(string harvard, string yerkes, int IntNumeral) //on HR diagram
- {
- Vector2[] returnArray = new Vector2[2];
- switch (harvard.ToLower())
- {
- case "o":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- }
- break;
- case "b":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- }
- break;
- case "a":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- }
- break;
- case "f":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- }
- break;
- case "g":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- case "sd":
- break;
- }
- break;
- case "k":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- case "sd":
- break;
- }
- break;
- case "m":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- case "sd":
- break;
- }
- break;
- case "c":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- case "sd":
- break;
- }
- break;
- case "s":
- switch (yerkes.ToLower())
- {
- case "v":
- break;
- case "iv":
- break;
- case "iii":
- break;
- case "ii":
- break;
- case "ib":
- break;
- case "iab":
- break;
- case "ia":
- break;
- case "ia+":
- break;
- case "sd":
- break;
- }
- break;
- case "l":
- break;
- case "t":
- break;
- case "y":
- break;
- case "wn":
- case "wn/c":
- case "wc":
- case "wo":
- break;
- case "DA":
- case "DAZ":
- case "DAO":
- case "DAB":
- case "DBZ":
- case "DB":
- case "DO":
- case "DQ":
- case "DZ":
- case "DC":
- break;
- }
- return returnArray;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement