public string ListCalculateData(int index) { string[] list = new string[8]; list[0] = AdversaryX.ToString(); list[1] = AdversaryY.ToString(); list[2] = InitialSpeed.ToString(); list[3] = AltilleryX.ToString(); list[4] = AltilleryY.ToString(); list[5] = ProjectileAngle.ToString(); list[6] = FlightDuration.ToString(); list[7] = MaxSize.ToString(); return(list[index]); }
public void AddFlightDuration(object o) { if (!ValidateAddFlightDuration()) { return; } FlightDuration flightDuration = new FlightDuration { Aircraft = SelectedAircraft, DurationHours = DurationHours.Value, DurationMinutes = DurationMinutes.Value }; FlightDurations.Add(flightDuration); SelectedAircraft = null; DurationHours = null; DurationMinutes = null; }
public JsonResult calculateSecondDate(string firstDate, string direction) { bool returning = direction == "1" ? true : false; DateTime fstDate = Convert.ToDateTime(firstDate); // # patikrinti, ar jau skaiciuota FlightDuration flightDur = FlightDuration.findOrFail(fstDate, returning); if (flightDur != null) { return(Json(flightDur, JsonRequestBehavior.AllowGet)); // return flightDur; } // earth 149500000, mars 227900000 double startAvgDistance = returning ? 227900000 : 149500000; // km double endAvgDistance = returning ? 149500000 : 227900000; // km // earth 365.25, mars 686.97 double startOrbitPeriod = returning ? 686.97 : 365.25; // days double endOrbitPeriod = returning ? 365.25 : 686.97; // days // assuming average speed of 16 km/s double spaceShipSpeed = 1382400; // km/d double startStopFuelConsumption = 100000; // litres double dailyFuelConsumption = 150; // litres double fuelLitreCost = 1.5; // euros // # apskaiciuot pozicijas pradines datos metu double startRadialPos = calculatePlanetPosition(fstDate, startOrbitPeriod); double endRadialPos = calculatePlanetPosition(fstDate, endOrbitPeriod); // # while ( not at end position) DateTime sndDate = new DateTime(fstDate.Ticks); int limit = 0; // infinite loops are never fun while (limit < 1500) { // # apskaiciuot galine planeta po vienos dienos sndDate = sndDate.AddDays(1); double endPos = calculatePlanetPosition(sndDate, endOrbitPeriod); double spaceShipDistance = (sndDate - fstDate).Days * spaceShipSpeed; // straight line distance double currentAngle = Math.Abs(startRadialPos - endPos); double distanceToPlanet = Math.Sqrt(Math.Pow(startAvgDistance, 2) + Math.Pow(endAvgDistance, 2) - 2 * startAvgDistance * endAvgDistance * Math.Cos(currentAngle * 2 * Math.PI)); // # patikrint ar trajektorija nekerta saules if (0.4 < currentAngle && currentAngle < 0.6) { distanceToPlanet *= 1.3; // modify distance to account for parabolic trajectory } // # patikrinti, ar pasieke planeta if (spaceShipDistance >= distanceToPlanet) { break; } limit++; } // # paskaiciuot kiek dienu truks // # paskaiciuot kura pagal dienas double fuelCost = (2 * startStopFuelConsumption + (sndDate - fstDate).Days * dailyFuelConsumption) * fuelLitreCost; // # issaugot duombazej flightDur = new FlightDuration(-1, returning ? fstDate : sndDate, returning ? sndDate : fstDate, returning, fuelCost); FlightDuration.insertSecondDate(flightDur); // # return return(Json(flightDur, JsonRequestBehavior.AllowGet)); }
public void RemoveFlightDuration(FlightDuration flightDuration) { FlightDurations.Remove(flightDuration); }