public double RetrieveOdds(MersenneTwister dice, string weather, int day, bool EnforceHigherOverLower = true) { double Odd = 0; List <WeatherParameters> wp = this.WeatherChances.Where(w => w.WeatherType == weather).ToList(); if (wp.Count == 0) { return(0); } Odd = wp[0].BaseValue + (wp[0].ChangeRate * day); RangePair range = new RangePair(wp[0].VariableLowerBound, wp[0].VariableHigherBound, EnforceHigherOverLower); Odd += range.RollInRange(dice); //sanity check. if (Odd < 0) { Odd = 0; } if (Odd > 1) { Odd = 1; } return(Odd); }
public double RetrieveOdds(MersenneTwister dice, string weather, int day, StringBuilder Output) { double Odd = 0; List <WeatherParameters> wp = this.WeatherChances.Where(w => w.WeatherType == weather).ToList <WeatherParameters>(); if (wp.Count == 0) { Output.Append($"{weather} weather is not found in this time span."); return(0); } Output.Append($"Retrieved data for {weather} on {day} with Base Value {wp[0].BaseValue} and Change Rate {wp[0].ChangeRate} " + $"with the variable bound of ({wp[0].VariableLowerBound} , {wp[0].VariableHigherBound}) {Environment.NewLine}"); Odd = wp[0].BaseValue + (wp[0].ChangeRate * day); RangePair range = new RangePair(wp[0].VariableLowerBound, wp[0].VariableHigherBound); Odd = Odd + range.RollInRange(dice); //sanity check. if (Odd < 0) { Odd = 0; } if (Odd > 1) { Odd = 1; } return(Odd); }
/// <summary>This function resets the weather for a new day.</summary> public void OnNewDay() { foreach (ISDVWeather weather in CurrentWeathers) weather.OnNewDay(); CurrentConditionsN = CurrentWeather.Unset; TodayTemps = TomorrowTemps; //If Tomorrow is null, should just allow it to be null. TomorrowTemps = null; if (Game1.currentSeason == "fall") { Weathers[(int)CurrentWeather.Wind] = new WeatherData(WeatherIcon.IconDebris, WeatherIcon.IconDebris, "debris", Translation.Get("weather_wind")); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Frost)] = new WeatherData(WeatherIcon.IconDebris, WeatherIcon.IconDebris, "debrisfrost", Translation.Get("weather_frost", new { condition = Translation.Get("weather_wind") })); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Heatwave)] = new WeatherData(WeatherIcon.IconDebris, WeatherIcon.IconDebris, "debrisheatwave", Translation.Get("weather_heatwaveCond", new { condition = Translation.Get("weather_wind") })); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Lightning)] = new WeatherData(WeatherIcon.IconDebris, WeatherIcon.IconDebris, "drylightningwindy", Translation.Get("weather_drylightningwindy")); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Heatwave | CurrentWeather.Lightning)] = new WeatherData(WeatherIcon.IconDebris, WeatherIcon.IconDebris, "drylightningheatwave", Translation.Get("weather_drylightningheatwavewindy")); } else { //reset back to spring. Weathers[(int)CurrentWeather.Wind] = new WeatherData(WeatherIcon.IconSpringDebris, WeatherIcon.IconSpringDebris, "debris", Translation.Get("weather_wind")); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Frost)] = new WeatherData(WeatherIcon.IconSpringDebris, WeatherIcon.IconSpringDebris, "debrisfrost", Translation.Get("weather_frost", new { condition = Translation.Get("weather_wind") })); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Heatwave)] = new WeatherData(WeatherIcon.IconSpringDebris, WeatherIcon.IconSpringDebris, "debrisheatwave", Translation.Get("weather_heatwaveCond", new { condition = Translation.Get("weather_wind") })); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Lightning)] = new WeatherData(WeatherIcon.IconSpringDebris, WeatherIcon.IconSpringDebris, "drylightningwindy", Translation.Get("weather_drylightningwindy")); Weathers[(int)(CurrentWeather.Wind | CurrentWeather.Heatwave | CurrentWeather.Lightning)] = new WeatherData(WeatherIcon.IconSpringDebris, WeatherIcon.IconSpringDebris, "drylightningheatwave", Translation.Get("weather_drylightningheatwavewindy")); } }
string RangePairToText(RangePair range) { string str = ""; if (range.Min.Exclusive) { str += "("; } else { str += "["; } str += range.Min.expression; str += ","; str += range.Max.expression; if (range.Max.Exclusive) { str += ")"; } else { str += "]"; } return(str); }
public RangePair GetTemperatures(MersenneTwister dice, int day) { var temps = new RangePair(RetrieveTemp(dice, "lowtemp", day), RetrieveTemp(dice, "hightemp", day), true); ClimatesOfFerngill.Logger.Log($"We are gathering temperatures from the climate file. Temps is {temps.LowerBound}, {temps.HigherBound}"); return(temps); }
public double MapInSource(double value) { int index = GetIndexFromTarget(value); if (index == -1) { return(double.NaN); } RangePair p = this.ranges[index]; if (p.source.Length == 0) { return(p.source.From); } if (p.target.Length == 0) { return(double.IsNaN(p.source.MappedValue) ? (p.source.From + p.source.To) / 2 : p.source.MappedValue); } double t = (value - p.target.From) / p.target.Length; return(p.source.From + (t * p.source.Length)); }
/// ****************************************************************************** /// PROCESSING /// ****************************************************************************** internal void ForceTodayTemps(double high, double low) { if (TodayTemps is null) TodayTemps = new RangePair(); TodayTemps.HigherBound = high; TodayTemps.LowerBound = low; }
/// <summary> This function resets the weather object to basic. </summary> public void Reset() { foreach (ISDVWeather weather in CurrentWeathers) weather.Reset(); TodayTemps = null; TomorrowTemps = null; CurrentConditionsN = CurrentWeather.Unset; }
public ClimateTracker() { DaysSinceRainedLast = 0; AmtOfRainInCurrentStreak = 0; AmtOfRainSinceDay1 = 0; CurrentStreak = new CurrentWeatherData("", 0); IsWeatherSystem = false; WeatherSystemType = ""; WeatherSystemDays = 0; TempsOnNextDay = new RangePair(); }
public ClimateTracker(int daysSinceLast, int amtInStreak, long TotalRain, string currentWeather, int numDays, bool weatherSystem, string wst, int weatSDays, RangePair c) { DaysSinceRainedLast = daysSinceLast; AmtOfRainInCurrentStreak = amtInStreak; AmtOfRainSinceDay1 = TotalRain; CurrentStreak = new CurrentWeatherData(currentWeather, numDays); IsWeatherSystem = weatherSystem; WeatherSystemType = wst; WeatherSystemDays = weatSDays; TempsOnNextDay = new RangePair(c); }
public ClimateTracker(ClimateTracker c) { DaysSinceRainedLast = c.DaysSinceRainedLast; AmtOfRainInCurrentStreak = c.AmtOfRainInCurrentStreak; AmtOfRainSinceDay1 = c.AmtOfRainSinceDay1; CurrentStreak = new CurrentWeatherData(c.CurrentStreak); IsWeatherSystem = c.IsWeatherSystem; WeatherSystemType = c.WeatherSystemType; WeatherSystemDays = c.WeatherSystemDays; TempsOnNextDay = new RangePair(c.TempsOnNextDay); }
/// <summary> /// Copy constructor with option to enforce higher over lower. /// </summary> /// <param name="c">The object being copied</param> public RangePair(RangePair c, bool EnforceHigherOverLower = false) { this.LowerBound = c.LowerBound; this.HigherBound = c.HigherBound; if (EnforceHigherOverLower == true && this.LowerBound > this.HigherBound) { double temp = this.LowerBound; this.LowerBound = this.HigherBound; this.HigherBound = temp; } }
public void AddRange(string variable, RangePair rangePair) { if (rangePair != null) { if (ranges.ContainsKey(variable)) { ranges[variable] = rangePair; } else { ranges.Add(variable, rangePair); } } }
public double RetrieveTemp(MersenneTwister dice, string temp, int day, bool EnforceHigherOverLower = true) { double Temp = 0; List <WeatherParameters> wp = this.WeatherChances.Where(w => w.WeatherType == temp).ToList <WeatherParameters>(); if (wp.Count == 0) { return(0); } Temp = wp[0].BaseValue + (wp[0].ChangeRate * day); RangePair range = new RangePair(wp[0].VariableLowerBound, wp[0].VariableHigherBound, EnforceHigherOverLower); Temp += range.RollInRange(dice); return(Temp); }
public RangePair getFingerChordWristRange(FingerChord fc) { RangePair rp = new RangePair(); foreach (var pair in fc) { if (pair.Value != Finger.EMPTY) { float keyPosition = Piano.KeyPositions[pair.Key]; Range range = getFingerRange(pair.Value); range = new Range { low = keyPosition + range.low, high = keyPosition + range.high }; if (pair.Value > Finger.EMPTY) { if (rp.right == null) { rp.right = range; } else { rp.right.low = Math.Max(rp.right.low, keyPosition + range.low); rp.right.high = Math.Min(rp.right.high, keyPosition + range.high); } } else { if (rp.left == null) { rp.left = range; } else { rp.left.low = Math.Max(rp.left.low, keyPosition + range.low); rp.left.high = Math.Min(rp.left.high, keyPosition + range.high); } } } } return(rp); }
public double RetrieveTemp(MersenneTwister dice, string temp, int day, StringBuilder Output) { double Temp = 0; List <WeatherParameters> wp = this.WeatherChances.Where(w => w.WeatherType == temp).ToList <WeatherParameters>(); if (wp.Count == 0) { Output.Append($"{temp} weather is not found in this time span."); return(0); } Output.Append($"Retrieved data for {temp} on {day} with Base Value {wp[0].BaseValue} and Change Rate {wp[0].ChangeRate} " + $"with the variable bound of ({wp[0].VariableLowerBound} , {wp[0].VariableHigherBound}) {Environment.NewLine}"); Temp = wp[0].BaseValue + (wp[0].ChangeRate * day); RangePair range = new RangePair(wp[0].VariableLowerBound, wp[0].VariableHigherBound); Temp = Temp + range.RollInRange(dice); return(Temp); }
protected void HandleInput(string source) { List <string> x; List <string> y; List <string> z; List <string> umin = ExpressionParser.Parse(""); List <string> umax = ExpressionParser.Parse(""); List <string> tmin = ExpressionParser.Parse(""); List <string> tmax = ExpressionParser.Parse(""); List <string> vmin = ExpressionParser.Parse(""); List <string> vmax = ExpressionParser.Parse(""); List <string> wmin = ExpressionParser.Parse(""); List <string> wmax = ExpressionParser.Parse(""); ExpressionSet expressionSet = calcManager.expressionSet; switch (source) { default: x = ExpressionParser.Parse("0.75*sin(2*pi*v)"); y = ExpressionParser.Parse("sin(pi*u)*(1.5+0.75*cos(2*pi*v))"); z = ExpressionParser.Parse("cos(pi*u)*(1.5+0.75*cos(2*pi*v))"); umin = ExpressionParser.Parse("1.5"); umax = ExpressionParser.Parse("2.5"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("1"); List <string> x2 = ExpressionParser.Parse("0.75*cos(pi*u)"); List <string> y2 = ExpressionParser.Parse("0.75*sin(pi*u)*cos(2*pi*v)+2.4"); List <string> z2 = ExpressionParser.Parse("0.75*sin(pi*u)*sin(2*pi*v)+2.6"); List <string> umin2 = ExpressionParser.Parse("0"); List <string> umax2 = ExpressionParser.Parse("1"); List <string> vmin2 = ExpressionParser.Parse("0"); List <string> vmax2 = ExpressionParser.Parse("1"); List <string> x3 = ExpressionParser.Parse("0.75*sin(2*pi*u)"); List <string> y3 = ExpressionParser.Parse("0.75*cos(2*pi*u)+1.5*cos(pi/8*v)"); List <string> z3 = ExpressionParser.Parse("-1.5*sin(pi/8*v)"); List <string> umin3 = ExpressionParser.Parse("0"); List <string> umax3 = ExpressionParser.Parse("1"); List <string> vmin3 = ExpressionParser.Parse("0"); List <string> vmax3 = ExpressionParser.Parse("1"); List <string> x4 = ExpressionParser.Parse("0.75*sin(2*pi*u)"); List <string> y4 = ExpressionParser.Parse("0.75*cos(2*pi*u)-1.5*cos(pi/8*v)"); List <string> z4 = ExpressionParser.Parse("-1.5*sin(pi/8*v)"); List <string> umin4 = ExpressionParser.Parse("0"); List <string> umax4 = ExpressionParser.Parse("1"); List <string> vmin4 = ExpressionParser.Parse("0"); List <string> vmax4 = ExpressionParser.Parse("1"); Expression X = new Expression(x); Expression Y = new Expression(y); Expression Z = new Expression(z); Expression X2 = new Expression(x2); Expression Y2 = new Expression(y2); Expression Z2 = new Expression(z2); Expression X3 = new Expression(x3); Expression Y3 = new Expression(y3); Expression Z3 = new Expression(z3); Expression X4 = new Expression(x4); Expression Y4 = new Expression(y4); Expression Z4 = new Expression(z4); Range zeroRange = new Range(ExpressionParser.Parse("0")); Range oneRange = new Range(ExpressionParser.Parse("1")); Range onePointFive = new Range(ExpressionParser.Parse("1.5")); Range twoPointFive = new Range(ExpressionParser.Parse("2.5")); RangePair zeroToZero = new RangePair(zeroRange, zeroRange); RangePair zeroToOne = new RangePair(zeroRange, oneRange); List <RangePair> rangePairs = new List <RangePair>() { zeroToZero, new RangePair(onePointFive, twoPointFive), zeroToOne, zeroToOne }; List <RangePair> rangePairs2 = new List <RangePair>() { zeroToZero, zeroToOne, zeroToOne, zeroToZero }; ExpressionSet expSet = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs, new string[] { "X", "Y", "Z" }, new List <Expression>() { X, Y, Z }); ExpressionSet expSet2 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>() { X2, Y2, Z2 }); ExpressionSet expSet3 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>() { X3, Y3, Z3 }); ExpressionSet expSet4 = new ExpressionSet(new string[] { "t", "u", "v", "w" }, rangePairs2, new string[] { "X", "Y", "Z" }, new List <Expression>() { X4, Y4, Z4 }); List <ExpressionSet> nanomeLogo = new List <ExpressionSet>() { expSet, expSet2, expSet3, expSet4 }; CalcManager.Instance.LoadSavedExpressionSets(nanomeLogo); print("unknown preset pressed"); return; //R1 -> R1 case "Cinquefoil Knot": x = ExpressionParser.Parse("cos(t)*(2-cos(2*t/5))"); y = ExpressionParser.Parse("sin(t)*(2-cos(2*t/5))"); z = ExpressionParser.Parse("-sin(2*t/5)"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("10*pi"); break; case "Circle": x = ExpressionParser.Parse("cos(t)"); y = ExpressionParser.Parse("sin(t)"); z = ExpressionParser.Parse("0"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("2pi"); break; case "Sphere Outline": x = ExpressionParser.Parse("sin(t)*cos(32*t)"); y = ExpressionParser.Parse("sin(t)*sin(32*t)"); z = ExpressionParser.Parse("cos(t)"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("pi"); break; case "Hypocloid": x = ExpressionParser.Parse("cos(t)^3"); y = ExpressionParser.Parse("sin(t)^3"); z = ExpressionParser.Parse("0"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("4pi"); break; case "Hypocloid Surface": x = ExpressionParser.Parse("10*cos(t*32)^3"); y = ExpressionParser.Parse("10*sin(t*32)^3"); z = ExpressionParser.Parse("t-2*pi"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("4pi"); break; case "Trefoil Knot": x = ExpressionParser.Parse("sin(t)+2*sin(2*t)"); y = ExpressionParser.Parse("cos(t)-2*cos(2*t)"); z = ExpressionParser.Parse("-sin(3*t)"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("2*pi"); break; case "Turnip": x = ExpressionParser.Parse("(sin(t/16)^2)*cos(8*t)*8*pi"); y = ExpressionParser.Parse("(sin(t/16))^2*sin(8*t)*8*pi"); z = ExpressionParser.Parse("8*pi-t"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("16pi"); break; case "Wavy Surface": x = ExpressionParser.Parse("(sin(t/2)^(1/2)*cos(256*t)*pi)"); y = ExpressionParser.Parse("(sin(t/2))^(1/2)*sin(64*t)*pi"); z = ExpressionParser.Parse("pi-t"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("2pi"); break; case "High-res Sphere": x = ExpressionParser.Parse("sin(t)*cos(1024*t)"); y = ExpressionParser.Parse("sin(t)*sin(1024*t)"); z = ExpressionParser.Parse("cos(t)"); tmin = ExpressionParser.Parse("0"); tmax = ExpressionParser.Parse("pi"); break; //R2->R3 case "Astroidal Ellipse": x = ExpressionParser.Parse("(2*cos(u)*cos(v))^3"); y = ExpressionParser.Parse("(2*sin(u)*cos(v))^3"); z = ExpressionParser.Parse("(2*sin(v))^3"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2*pi"); break; case "Bumpy Sphere": x = ExpressionParser.Parse("5*sin(u)*sin(v)+cos(30*v)*0.15"); y = ExpressionParser.Parse("5*cos(u)*sin(v)+cos(30*u)*0.15"); z = ExpressionParser.Parse("5*cos(v)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("2*pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("pi"); break; case "Dini's Surface": x = ExpressionParser.Parse("3*cos(u)*sin(v)"); y = ExpressionParser.Parse("3*sin(u)*sin(v)"); z = ExpressionParser.Parse("3*(cos(v)+log(tan(0.5*v)))+0.4*u"); umin = ExpressionParser.Parse("-4*pi"); umax = ExpressionParser.Parse("4*pi"); vmin = ExpressionParser.Parse("0.005"); vmax = ExpressionParser.Parse("3.135"); break; case "Figure-8": x = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*cos(u)"); y = ExpressionParser.Parse("(3+cos(u/2)*sin(v)-sin(u/2)*sin(2*v))*sin(u)"); z = ExpressionParser.Parse("sin(u/2)*sin(v)-cos(u/2)*sin(2*v)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("2*pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2*pi"); break; case "Gray's Surface": x = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*cos(u/2)"); y = ExpressionParser.Parse("(3+cos(3*u/2)*sin(v)-sin(3*u/2)*sin(2*v))*sin(u/2)"); z = ExpressionParser.Parse("sin(3*u/2)*sin(v)+cos(3*u/2)*sin(2*v)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("4*pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Knot": x = ExpressionParser.Parse("3*sin(3*u)/2+cos(v)))"); y = ExpressionParser.Parse("3*(sin(u)+2*sin(2*u))/(2+cos(v+pi*2/3))"); z = ExpressionParser.Parse("3/2*(cos(u)-2*cos(2*u))*(2+cos(v))*(2+cos(v+pi*2/3))/4"); umin = ExpressionParser.Parse("-pi"); umax = ExpressionParser.Parse("2pi"); vmin = ExpressionParser.Parse("-pi"); vmax = ExpressionParser.Parse("2pi"); break; case "Mobius": x = ExpressionParser.Parse("(5+u*cos(0.5*v))*cos(v)"); y = ExpressionParser.Parse("(5+u*cos(0.5*v))*sin(v)"); z = ExpressionParser.Parse("u*sin(0.5*v)"); umin = ExpressionParser.Parse("-1"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2*pi"); break; case "Radial Wave": x = ExpressionParser.Parse("u"); y = ExpressionParser.Parse("v"); z = ExpressionParser.Parse("cos((u^2+v^2)^0.5)"); umin = ExpressionParser.Parse("-10"); umax = ExpressionParser.Parse("10"); vmin = ExpressionParser.Parse("-10"); vmax = ExpressionParser.Parse("10"); break; case "Torus": x = ExpressionParser.Parse("(5+cos(v))*cos(u)"); y = ExpressionParser.Parse("(5+cos(v))*sin(u)"); z = ExpressionParser.Parse("sin(v)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("2pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; //R3->R3 case "Cone": x = ExpressionParser.Parse("ucos(v)w"); y = ExpressionParser.Parse("usin(v)w"); z = ExpressionParser.Parse("w"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); wmin = ExpressionParser.Parse("0"); wmax = ExpressionParser.Parse("1"); break; case "Cube": x = ExpressionParser.Parse("u"); y = ExpressionParser.Parse("v"); z = ExpressionParser.Parse("w"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("1"); wmin = ExpressionParser.Parse("0"); wmax = ExpressionParser.Parse("1"); break; case "Cylinder": x = ExpressionParser.Parse("ucos(v)"); y = ExpressionParser.Parse("usin(v)"); z = ExpressionParser.Parse("w"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); wmin = ExpressionParser.Parse("0"); wmax = ExpressionParser.Parse("1"); break; case "Sphere": x = ExpressionParser.Parse("ucos(v)sin(w)"); y = ExpressionParser.Parse("usin(v)sin(w)"); z = ExpressionParser.Parse("ucos(w)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); wmin = ExpressionParser.Parse("0"); wmax = ExpressionParser.Parse("2pi"); break; case "Tetrahedron": x = ExpressionParser.Parse("u(1-v)"); y = ExpressionParser.Parse("uv(1-w)"); z = ExpressionParser.Parse("uvw"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("1"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("1"); wmin = ExpressionParser.Parse("0"); wmax = ExpressionParser.Parse("1"); break; // Orbitals case "S": x = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(1/2*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Px": x = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*sin(v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Py": x = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(3^(1/2)/2*sin(u)*1/pi^(1/2)*cos(v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Pz": x = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(3^(1/2)/2*cos(u)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Dz\x00B2": goto case "Dz2"; case "Dz2": x = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(5^(1/2)/4*(3*((cos(u))^2)-1)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Dxz": x = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*sin(v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Dyz": x = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(15^(1/2)/2*sin(u)*cos(u)*1/pi^(1/2)*cos(v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Dxy": x = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*sin(2v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Dx\x00B2-y\x00B2": goto case "Dx2-y2"; case "Dx2-y2": x = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(15^(1/2)/4*sin(u)^2*1/pi^(1/2)*cos(2v))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fz\x00B3": goto case "Fz3"; case "Fz3": x = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(7^(1/2)/4*(5*((cos(u))^2)-3)*cos(u)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fxz\x00B2": goto case "Fxz2"; case "Fxz2": x = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*sin(v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fyz\x00B2": goto case "Fyz2"; case "Fyz2": x = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(42^(1/2)/8*(5*((cos(u))^2)-1)*sin(u)*cos(v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fxyz": x = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*cos(2v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fz\x0028x\x00B2-y\x00B2\x0029": goto case "Fzx2y2"; case "Fzx2y2": x = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(105^(1/2)/4*sin(u)^2*cos(u)*sin(2v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fx\x0028x\x00B2-3y\x00B2\x0029": goto case "Fxx23y2"; case "Fxx23y2": x = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*sin(3v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; case "Fy\x00283x\x00B2-y\x00B2\x0029": goto case "Fy3x2y2"; case "Fy3x2y2": x = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*cos(v)"); y = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*sin(u)*sin(v)"); z = ExpressionParser.Parse("(70^(1/2)/8*sin(u)^3*cos(3v)*1/pi^(1/2))^2*cos(u)"); umin = ExpressionParser.Parse("0"); umax = ExpressionParser.Parse("pi"); vmin = ExpressionParser.Parse("0"); vmax = ExpressionParser.Parse("2pi"); break; } expressionSet.AddExpression("X", x); expressionSet.AddExpression("Y", y); expressionSet.AddExpression("Z", z); expressionSet.AddRange("t", tmin, tmax); expressionSet.AddRange("u", umin, umax); expressionSet.AddRange("v", vmin, vmax); expressionSet.AddRange("w", wmin, wmax); calcManager.PresetPressed(); }
/// <summary> /// initializes a range which consists of two range pairs, one for the x and y axis /// </summary> /// <param name="minx"></param> /// <param name="miny"></param> /// <param name="maxx"></param> /// <param name="maxy"></param> public Range(double minx, double miny, double maxx, double maxy) { X = new RangePair(minx, maxx); Y = new RangePair(miny, maxy); }
public RangePair(RangePair toCopy) { Min = new Range(toCopy.Min); Max = new Range(toCopy.Max); }
/// <summary> /// Updates range for the inserted RangePair /// </summary> /// <param name="pair">RangePair with new max and min</param> public void AdjustRange(RangePair pair) { AdjustRange(pair.Min, pair.Max); }
/// <summary> This sets the temperatures from outside for tomorrow</summary> /// <param name="a">The RangePair that contains the generated temperatures</param> public void SetTomorrowTemps(RangePair a) => TomorrowTemps = new RangePair(a, EnforceHigherOverLower: true);
public SerializableRangePair(RangePair rangePair) { min = new SerializableRange(rangePair.Min); max = new SerializableRange(rangePair.Max); }
internal static void SetWeatherNonSystemForTomorrow(MersenneTwister Dice, FerngillClimate GameClimate, double rainDays, double stormDays, double windyDays, RangePair TmrwTemps) { ProbabilityDistribution <string> WeatherDist = new ProbabilityDistribution <string>("sunny"); WeatherDist.AddNewEndPoint(rainDays, "rain"); if (ClimatesOfFerngill.WeatherOpt.DisableHighRainWind) { WeatherDist.AddNewCappedEndPoint(windyDays, "debris"); } double distOdd = Dice.NextDoublePositive(); if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log(WeatherDist.ToString()); ClimatesOfFerngill.Logger.Log($"Distribution odds is {distOdd}"); } if (!(WeatherDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; ClimatesOfFerngill.Logger.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Weather result is {Result}"); } SetWeatherTomorrow(Result, Dice, GameClimate, stormDays, TmrwTemps); }
internal static void SetWeatherTomorrow(string Result, MersenneTwister Dice, FerngillClimate GameClimate, double stormOdds, RangePair TmrwTemps) { //now parse the result. if (Result == "rain") { SDVUtilities.SetWeather(Game1.weather_rain); if (Game1.currentSeason == "winter") { SDVUtilities.SetWeather(Game1.weather_snow); if (GameClimate.AllowRainInWinter && ClimatesOfFerngill.Conditions.TomorrowHigh >= -2.5) { SDVUtilities.SetWeather(Game1.weather_rain); } } //Moved from the *wrong function and logic gate* //snow applies first if (WeatherConditions.IsValidWeatherForSnow(TmrwTemps) && Game1.currentSeason != "spring") { if (ClimatesOfFerngill.WeatherOpt.Verbose) { ClimatesOfFerngill.Logger.Log($"Snow is enabled, with the High for the day being: {TmrwTemps.HigherBound}" + $" and the calculated midpoint temperature being {TmrwTemps.GetMidPoint()}"); } SDVUtilities.SetWeather(Game1.weather_snow); } //apply lightning logic. if (Dice.NextDoublePositive() >= stormOdds && Game1.weatherForTomorrow == Game1.weather_rain) { SDVUtilities.SetWeather(Game1.weather_lightning); if (SDate.Now().Year == 1 && SDate.Now().Season == "spring" && !ClimatesOfFerngill.WeatherOpt.AllowStormsSpringYear1) { SDVUtilities.SetWeather(Game1.weather_rain); } } //tracking time! - Snow fall on Fall 28, if the flag is set. if (Game1.dayOfMonth == 28 && Game1.currentSeason == "fall" && ClimatesOfFerngill.WeatherOpt.SnowOnFall28) { ClimatesOfFerngill.Conditions.ForceTodayTemps(2, -1); SDVUtilities.SetWeather(Game1.weather_snow); } } if (Result == "debris") { SDVUtilities.SetWeather(Game1.weather_debris); } if (Result == "sunny") { SDVUtilities.SetWeather(Game1.weather_sunny); } }
public void AddRange(string variable, Range rangeMin, Range rangeMax) { RangePair rangePair = new RangePair(rangeMin, rangeMax); AddRange(variable, rangePair); }