private void RenderMainOutputArea()
        {
            // Display error if it exists.
            if (errorText != "")
            {
                GUILayout.Label(errorText);
            }

            // Parse the caclulated orbit.
            if (currentOrbit != null)
            {
                if (currentOrbit.IsOutsideSOI)
                {
                    GUILayout.Label("Warning: Orbit is outside of the SOI.");
                }
                if (currentOrbit.Periapsis < currentOrbit.ParentBody.Radius)
                {
                    GUILayout.Label("Warning: Orbit intersects surface.");
                }

                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                GUILayout.Label("Periapsis Alt.: " + SOCUtilis.ParseOrbitElement(currentOrbit.PeriapsisAltitude, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Periapsis: " + SOCUtilis.ParseOrbitElement(currentOrbit.Periapsis, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Periapsis Speed: " + SOCUtilis.ParseOrbitElement(currentOrbit.PeriapsisSpeed, SimpleOrbit.ScalerType.Speed));
                GUILayout.Label("S.Major Axis: " + SOCUtilis.ParseOrbitElement(currentOrbit.SemiMajorAxis, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Period: " + SOCUtilis.ParseOrbitElement(currentOrbit.OrbitalPeriod, SimpleOrbit.ScalerType.Time));
                try
                {
                    string dragText = (currentOrbit.ParentBody.atmosphere) ? " + drag" : "";
                    GUILayout.Label("Launch Δv: " + SOCUtilis.ParseOrbitElement(currentOrbit.CalculateEquatorialLandingDeltaV(), SimpleOrbit.ScalerType.Speed) + dragText);
                }
                catch (OrbitalElementExecption)
                {
                    GUILayout.Label("Launch Δv: n/a");
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                GUILayout.Label("Apoapsis Alt.: " + SOCUtilis.ParseOrbitElement(currentOrbit.ApoapsisAltitude, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Apoapsis: " + SOCUtilis.ParseOrbitElement(currentOrbit.Apoapsis, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Apoapsis Speed: " + SOCUtilis.ParseOrbitElement(currentOrbit.ApoapsisSpeed, SimpleOrbit.ScalerType.Speed));
                GUILayout.Label("Eccentricity: " + SOCUtilis.ParseOrbitElement(currentOrbit.Eccentricity));
                GUILayout.Label("Mean Orbit Speed: " + SOCUtilis.ParseOrbitElement(currentOrbit.MeanOrbitalSpeed, SimpleOrbit.ScalerType.Speed));
                GUILayout.Label("Max. Darkness Length: " + SOCUtilis.ParseOrbitElement(currentOrbit.MaxDarknessTime, SimpleOrbit.ScalerType.Time));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
예제 #2
0
        public string ToString(bool userApsideAltitude)
        {
            string periapsisText, apoapsisText;

            if (userApsideAltitude)
            {
                periapsisText = SOCUtilis.ParseOrbitElement(PeriapsisAltitude, ScalerType.Distance);
                apoapsisText  = SOCUtilis.ParseOrbitElement(ApoapsisAltitude, ScalerType.Distance);
            }
            else
            {
                periapsisText = SOCUtilis.ParseOrbitElement(Periapsis, ScalerType.Distance);
                apoapsisText  = SOCUtilis.ParseOrbitElement(Apoapsis, ScalerType.Distance);
            }
            return(parentBody.name + ": " + periapsisText + " x " + apoapsisText);
        }
        /// <summary>
        /// Renders the celestial info area.
        /// </summary>
        private void RenderCelestialInfoArea()
        {
            // The current celestial.
            CelestialBody celestialBody = celestialBodies[selectedCelestialIndex];

            // Displays the current celestial.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Selected Body: " + celestialSelectValues[selectedCelestialIndex]);
            GUILayout.EndHorizontal();

            // Main info area
            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));

            // Orbital Characteristics
            if (celestialBody.orbit != null)
            {
                // Calculations
                double meanOrbitalSpeed = OrbitMath.MeanOrbitalSpeed(celestialBody.orbit.semiMajorAxis, celestialBody.orbit.eccentricity, celestialBody.referenceBody.gravParameter);

                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                GUILayout.Label("ORBITAL CHARACTERISTICS");
                GUILayout.Label("Apoapsis: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.ApR, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Periapsis: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.PeR, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Semi-major axis: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.semiMajorAxis, SimpleOrbit.ScalerType.Distance));
                GUILayout.Label("Eccentricity: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.eccentricity));
                GUILayout.Label("Orbital period: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.period, SimpleOrbit.ScalerType.Time));
                GUILayout.Label("Average orbital speed: " + SOCUtilis.ParseOrbitElement(meanOrbitalSpeed, SimpleOrbit.ScalerType.Speed));
                GUILayout.Label("Mean anomaly at epoch: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.meanAnomalyAtEpoch, SimpleOrbit.ScalerType.Radians));
                GUILayout.Label("Inclination: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.inclination, SimpleOrbit.ScalerType.Degrees));
                GUILayout.Label("Longitude of ascending node: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.LAN, SimpleOrbit.ScalerType.Degrees));
                GUILayout.Label("Argument of periapsis: " + SOCUtilis.ParseOrbitElement(celestialBody.orbit.argumentOfPeriapsis, SimpleOrbit.ScalerType.Degrees));
                GUILayout.EndVertical();
            }

            // Physical Characteristics
            GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
            GUILayout.Label("PHYSICAL CHARACTERISTICS");
            GUILayout.Label("Radius: " + SOCUtilis.ParseOrbitElement(celestialBody.Radius, SimpleOrbit.ScalerType.Distance));
            GUILayout.Label("Circumference: " + SOCUtilis.ParseOrbitElement(celestialBody.Radius * 2.0 * Math.PI, SimpleOrbit.ScalerType.Distance));
            GUILayout.Label("Surface area: " + SOCUtilis.ParseOrbitElement(celestialBody.SurfaceArea, SimpleOrbit.ScalerType.Area));
            GUILayout.Label("Volume: " + SOCUtilis.ParseOrbitElement(celestialBody.Mass / celestialBody.Density, SimpleOrbit.ScalerType.Volume));
            GUILayout.Label("Mass: " + SOCUtilis.ParseOrbitElement(celestialBody.Mass, SimpleOrbit.ScalerType.Mass));
            GUILayout.Label("Density: " + SOCUtilis.ParseOrbitElement(celestialBody.Density, SimpleOrbit.ScalerType.Density));
            GUILayout.Label("Surface gravity: " + SOCUtilis.ParseOrbitElement(celestialBody.GeeASL, "g"));
            GUILayout.Label("Escape velocity: " + SOCUtilis.ParseOrbitElement(Math.Sqrt(2.0 * celestialBody.gravParameter / celestialBody.Radius), SimpleOrbit.ScalerType.Speed));
            GUILayout.Label("Sphere of influence: " + SOCUtilis.ParseOrbitElement(celestialBody.sphereOfInfluence, SimpleOrbit.ScalerType.Distance));
            GUILayout.Label("Sidereal rotation period: " + SOCUtilis.ParseOrbitElement(celestialBody.rotationPeriod, SimpleOrbit.ScalerType.Time));

            CelestialBody planet = SOCUtilis.PlanetOfCelesital(celestialBody);

            if (planet != null)
            {
                double solarDay = Math.Abs(celestialBody.rotationPeriod / (1.0 - celestialBody.rotationPeriod / planet.orbit.period));
                GUILayout.Label("Solar day: " + SOCUtilis.ParseOrbitElement(solarDay, SimpleOrbit.ScalerType.Time));
                if (celestialBody.atmosphere)
                {
                    GUILayout.Label("Surface pressure: " + SOCUtilis.ParseOrbitElement(celestialBody.atmospherePressureSeaLevel, "kPa"));
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
        private void RenderHohmannTransferArea()
        {
            // The Orbit 1 Save button.
            GUILayout.BeginHorizontal();
            if (currentOrbit == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Save as Orbit 1", GUILayout.Width(SaveOrbitButtonWidth)))
            {
                savedOrbit1 = currentOrbit;
            }
            GUI.enabled = true;
            if (savedOrbit1 != null)
            {
                if (GUILayout.Button("C", GUILayout.Width(CharButtonWidth)))
                {
                    savedOrbit1 = null;
                }
                GUILayout.Label(savedOrbit1.ToString(useAltitideAspides));
            }
            GUILayout.EndHorizontal();

            // The Orbit 2 Save button.
            GUILayout.BeginHorizontal();
            if (currentOrbit == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Save as Orbit 2", GUILayout.Width(SaveOrbitButtonWidth)))
            {
                savedOrbit2 = currentOrbit;
            }
            GUI.enabled = true;
            if (savedOrbit2 != null)
            {
                if (GUILayout.Button("C", GUILayout.Width(CharButtonWidth)))
                {
                    savedOrbit2 = null;
                }
                GUILayout.Label(savedOrbit2.ToString(useAltitideAspides));
            }
            GUILayout.EndHorizontal();

            // Calculate the delta-V of transfer if valid.
            if (savedOrbit1 != null && savedOrbit2 != null)
            {
                if (savedOrbit1.ParentBody == savedOrbit2.ParentBody)
                {
                    try
                    {
                        double hohmannTransferDeltaV = SimpleOrbit.CalculateHohmannTransferDeltaV(savedOrbit1, savedOrbit2);
                        GUILayout.Label("Transfer Δv: " + SOCUtilis.ParseOrbitElement(hohmannTransferDeltaV, SimpleOrbit.ScalerType.Speed));
                    }
                    catch (ArgumentException e)
                    {
                        GUILayout.Label("Error: " + e.Message);
                    }
                }
                else
                {
                    GUILayout.Label("Parent bodies of saved orbits do not match.");
                }
            }
        }