Esempio n. 1
0
        private void CalculateFuelUsage()
        {
            NearAngleToTargetAngle();
            if (!_engineRunning)
            {
                return;
            }

            var burnedFuelPerSec = _rocketInf.FuelWeight / _rocketInf.BurnTime;
            var span             = TimeKeeper.Now() - lastCheck;
            var ms         = span.TotalMilliseconds;
            var burnedFuel = (ms / 1000) * burnedFuelPerSec * _thrustPercentage;

            lastCheck = TimeKeeper.Now();

            _restFuelWeight -= (_restFuelWeight - burnedFuel <= 0) ? _restFuelWeight : (float)burnedFuel;

            if (_restFuelWeight <= 0)
            {
                _engineRunning = false;
            }

            OwnForce = _engineRunning ? new Force(_angle, _rocketInf.Thrust * _thrustPercentage) : new Force(Angle.Zero, 0);

            Mass = new Mass(_restFuelWeight + _rocketInf.Weight - _rocketInf.FuelWeight);
        }
Esempio n. 2
0
        public TimeTravel()
        {
            InitializeComponent();
            FormClosing += TimeTravelHider;

            cbxNumber.SelectedIndex = 2;
            cbxTime.SelectedIndex   = 1;

            dtpCurrentTime.Value = TimeKeeper.Now();

            TimeKeeper.OnTimespanChanged += UpdateTime;
            TimeKeeper.OnRealTimeSet     += ProhibitInput;
            TimeKeeper.OnVirtualTimeSet  += AllowInput;

            dtpCurrentTime.ValueChanged += UpdateTimeKeeper;
            rdbRealtime.Click           += OnRdbRealtimeClick;
            rdbSimulation.Click         += OnRdbSimulationClick;

            rdbRealtime.Checked = true;

            SetInputStatus(false);

            var updateTimer = new Timer();

            updateTimer.Tick    += UpdateTime;
            updateTimer.Interval = 500;
            updateTimer.Start();
        }
Esempio n. 3
0
        private List <Sgp4Data> CalculatePositionList(int start, int end)
        {
            var startTime = new EpochTime(TimeKeeper.Now().AddMinutes(start));
            var endTime   = new EpochTime(TimeKeeper.Now().AddMinutes(end));

            var sgp4Propagator = new Sgp4(Tle, Sgp4.wgsConstant.WGS_84);

            sgp4Propagator.runSgp4Cal(startTime, endTime, 0.01);
            return(sgp4Propagator.getResults());
        }
Esempio n. 4
0
        public void DisplayInformation(Rocket rocket)
        {
            var liftoffTime = rocket.LiftOffTime;
            var time        = TimeKeeper.Now();
            var diff        = time - liftoffTime;

            lblClock.Text              = "T+ " + diff.ToString(@"dd\.hh\:mm\:ss");
            lblRocketName.Text         = rocket._name;
            lblInfModelVal.Text        = rocket._rocketInf.Model + " " + rocket._rocketInf.Variant;
            lblInfManufacturerVal.Text = rocket._rocketInf.Manufacturer;
            lblInfHeightVal.Text       = DecimalPoints.Add(rocket._rocketInf.Height) + "m";
        }
Esempio n. 5
0
        public void DrawLocation(Graphics g, CoordinateCalculator cCalc)
        {
            Sgp4Data position    = SatFunctions.getSatPositionAtTime(Tle, new EpochTime(TimeKeeper.Now()), Sgp4.wgsConstant.WGS_84);
            var      point       = SatFunctions.calcSatSubPoint(new EpochTime(TimeKeeper.Now()), position, Sgp4.wgsConstant.WGS_84);
            var      mappedPoint = cCalc.MapPoint(new PointF((float)point.getLongitude(), (float)point.getLatitude()));

            mappedPoint = new PointF((float)Math.Round(mappedPoint.X), (float)Math.Round(mappedPoint.Y));

            g.DrawImage(Properties.Resources.satellite, mappedPoint.X - 25, mappedPoint.Y - 25, 50, 50);
            var font = new Font("Times New Roman", 18, FontStyle.Bold, GraphicsUnit.Pixel);

            g.DrawString(Name, font, new SolidBrush(Color.OrangeRed), mappedPoint.X, mappedPoint.Y + 15);
        }
Esempio n. 6
0
        public PhysicsObject(PointF location, Mass mass, Force ownForce, Acceleration acceleration, Speed speed, DragProperties drag)
        {
            Location       = location;
            Mass           = mass;
            OwnForce       = ownForce;
            ResutlingForce = ownForce;
            Acceleration   = acceleration;
            Speed          = speed;
            GravityForces  = new List <Force>();
            DragForces     = new List <Force>();
            Drag           = drag;
            Diameter       = 0;

            _lastRecalculation = TimeKeeper.Now();
        }
Esempio n. 7
0
        public Rocket(PointF location, Force force, Acceleration acceleration, Speed speed,
                      Angle angle, float thrustPercentage, RocketInformation rocketInf) : base(location, new Mass(rocketInf.Weight), force, acceleration, speed, rocketInf.DragProperties)
        {
            _angle            = angle;
            targetAngle       = angle;
            _rocketInf        = rocketInf;
            _thrustPercentage = thrustPercentage;
            _restFuelWeight   = rocketInf.FuelWeight;
            _sprite           = rocketInf.GetRocketSprite();
            _engineRunning    = true;

            lastCheck = TimeKeeper.Now();

            var rnd = new Random();
            var r   = rnd.Next(rocketInf.Names.Count);

            _name = rocketInf.Names[r];
        }
Esempio n. 8
0
        public void Recalculate()
        {
            // Calculate resulting force
            var force = OwnForce;

            foreach (var exForce in ExternalForces)
            {
                force += exForce;
            }
            ResutlingForce = force;

            // Calculate Acceleration -> Speed -> Distance
            Acceleration = force.GetAcceleration(Mass);
            var timeSpan = TimeKeeper.Now() - _lastRecalculation;

            _lastRecalculation = TimeKeeper.Now();
            Speed += Acceleration.GetSpeed(timeSpan);
            var distance = Speed.GetDistance(timeSpan).CalculateXAndY();

            // Move it
            Location.X += (float)distance.X;
            Location.Y += (float)distance.Y;
        }
Esempio n. 9
0
 public void DrawLine(Graphics g, CoordinateCalculator cCalc)
 {
     DrawLineSet(new EpochTime(TimeKeeper.Now().AddMinutes(-30)), CalculatePositionList(-30, 0), Color.Red, cCalc, g);
     DrawLineSet(new EpochTime(TimeKeeper.Now()), CalculatePositionList(0, 90), Color.Yellow, cCalc, g);
 }
Esempio n. 10
0
 public void UpdateTime(object s, EventArgs e) => dtpCurrentTime.Value = TimeKeeper.Now();