Added more rendezvous readouts.
Added more rendezvous readouts.

--- a/KerbalEngineer/EngineerGlobals.cs
+++ b/KerbalEngineer/EngineerGlobals.cs
@@ -23,7 +23,7 @@
         /// <summary>

         ///     Current version of Kerbal Engineer Redux.

         /// </summary>

-        public const string PrettyVersion = "1.0";

+        public const string PrettyVersion = "1.0 alpha";

 

         #endregion

 


--- a/KerbalEngineer/Extensions/FloatExtensions.cs
+++ b/KerbalEngineer/Extensions/FloatExtensions.cs
@@ -81,14 +81,14 @@
                 {

                     value = -value;

                 }

-                return value.ToString("N0" + "Mm");

+                return value.ToString("N0") + "Mm";

             }

 

             if (negative)

             {

                 value = -value;

             }

-            return value.ToString("N0" + "km");

+            return value.ToString("N0") + "km";

         }

 

         /// <summary>


--- a/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
+++ b/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
@@ -12,6 +12,8 @@
 using KerbalEngineer.Flight.Readouts.Surface;

 using KerbalEngineer.Flight.Readouts.Vessel;

 using KerbalEngineer.Settings;

+

+using OrbitalPeriod = KerbalEngineer.Flight.Readouts.Orbital.OrbitalPeriod;

 

 #endregion

 

@@ -81,7 +83,13 @@
 

             // Rendezvous

             this.readoutModules.Add(new TargetSelector());

+            this.readoutModules.Add(new PhaseAngle());

             this.readoutModules.Add(new RelativeInclination());

+            this.readoutModules.Add(new AngleToAscendingNode());

+            this.readoutModules.Add(new AngleToDescendingNode());

+            this.readoutModules.Add(new Altitude());

+            this.readoutModules.Add(new Distance());

+            this.readoutModules.Add(new Rendezvous.OrbitalPeriod());

 

             this.LoadHelpStrings();

         }

@@ -108,7 +116,7 @@
         /// </summary>

         public ReadoutModule GetReadoutModule(string name)

         {

-            return this.readoutModules.FirstOrDefault(r => r.Name == name || r.GetType().Name == name);

+            return this.readoutModules.FirstOrDefault(r => r.Name == name || r.GetType().Name == name || r.Category + "." + r.GetType().Name == name);

         }

 

         /// <summary>

@@ -142,7 +150,7 @@
             var handler = SettingHandler.Load("HelpStrings.xml");

             foreach (var readout in this.readoutModules)

             {

-                readout.HelpString = handler.GetSet(readout.GetType().Name, readout.HelpString);

+                readout.HelpString = handler.GetSet(readout.Category + "." + readout.GetType().Name, readout.HelpString);

             }

             handler.Save("HelpStrings.xml");

         }


--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/Altitude.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class Altitude : ReadoutModule

+    {

+        public Altitude()

+        {

+            this.Name = "Altitude";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.Altitude.ToDistance());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToAscendingNode.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class AngleToAscendingNode : ReadoutModule

+    {

+        public AngleToAscendingNode()

+        {

+            this.Name = "Angle to AN";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.AngleToAscendingNode.ToAngle());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToDescendingNode.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class AngleToDescendingNode : ReadoutModule

+    {

+        public AngleToDescendingNode()

+        {

+            this.Name = "Angle to DN";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.AngleToDescendingNode.ToAngle());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/Distance.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class Distance : ReadoutModule

+    {

+        public Distance()

+        {

+            this.Name = "Distance";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.Distance.ToDistance());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/OrbitalPeriod.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class OrbitalPeriod : ReadoutModule

+    {

+        public OrbitalPeriod()

+        {

+            this.Name = "Orbital Period";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.OrbitalPeriod.ToTime());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- /dev/null
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/PhaseAngle.cs
@@ -1,1 +1,42 @@
-
+// Project:	KerbalEngineer

+// Author:	CYBUTEK

+// License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using KerbalEngineer.Extensions;

+

+#endregion

+

+namespace KerbalEngineer.Flight.Readouts.Rendezvous

+{

+    public class PhaseAngle : ReadoutModule

+    {

+        public PhaseAngle()

+        {

+            this.Name = "Phase Angle";

+            this.Category = ReadoutCategory.Rendezvous;

+            //this.HelpString = "";

+        }

+

+        public override void Update()

+        {

+            RendezvousProcessor.RequestUpdate();

+        }

+

+        public override void Draw()

+        {

+            if (!RendezvousProcessor.ShowDetails)

+            {

+                return;

+            }

+

+            this.DrawLine(RendezvousProcessor.PhaseAngle.ToAngle());

+        }

+

+        public override void Reset()

+        {

+            FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance);

+        }

+    }

+}

--- a/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs
@@ -1,6 +1,14 @@
 // Project:	KerbalEngineer

 // Author:	CYBUTEK

 // License:	Attribution-NonCommercial-ShareAlike 3.0 Unported

+

+#region Using Directives

+

+using System;

+

+using UnityEngine;

+

+#endregion

 

 namespace KerbalEngineer.Flight.Readouts.Rendezvous

 {

@@ -22,8 +30,10 @@
 

         #region Fields

 

-        private Orbit sourceOrbit;

+        private Orbit originOrbit;

+        private Vector3d originPosition;

         private Orbit targetOrbit;

+        private Vector3d targetPosition;

 

         #endregion

 

@@ -35,9 +45,44 @@
         public static bool ShowDetails { get; private set; }

 

         /// <summary>

-        ///     Gets the angular difference between the source and target orbits.

+        ///     Gets the difference in angle from the origin position to the target position based on a common reference.

+        /// </summary>

+        public static double PhaseAngle { get; private set; }

+

+        /// <summary>

+        ///     Gets the difference in angle from the origin position to where it is most efficient to burn for an encounter.

+        /// </summary>

+        public static double InterceptAngle { get; private set; }

+

+        /// <summary>

+        ///     Gets the angular difference between the origin and target orbits.

         /// </summary>

         public static double RelativeInclination { get; private set; }

+

+        /// <summary>

+        ///     Gets the angle from the origin position to the ascending node.

+        /// </summary>

+        public static double AngleToAscendingNode { get; private set; }

+

+        /// <summary>

+        ///     Gets the angle from the origin position to the descending node.

+        /// </summary>

+        public static double AngleToDescendingNode { get; private set; }

+

+        /// <summary>

+        ///     Gets the target's altitude above its reference body.

+        /// </summary>

+        public static double Altitude { get; private set; }

+

+        /// <summary>

+        ///     Gets the distance from the origin position to the target position.

+        /// </summary>

+        public static double Distance { get; private set; }

+

+        /// <summary>

+        ///     Gets the orbital period of the target orbit.

+        /// </summary>

+        public static double OrbitalPeriod { get; private set; }

 

         #endregion

 

@@ -57,11 +102,21 @@
             ShowDetails = true;

 

             this.targetOrbit = FlightGlobals.fetch.VesselTarget.GetOrbit();

-            this.sourceOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun || FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody)

+            this.originOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun || FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody)

                 ? FlightGlobals.ship_orbit

                 : FlightGlobals.ship_orbit.referenceBody.orbit;

 

-            RelativeInclination = Vector3d.Angle(this.sourceOrbit.GetOrbitNormal(), this.targetOrbit.GetOrbitNormal());

+            this.targetPosition = this.targetOrbit.getRelativePositionAtUT(Planetarium.GetUniversalTime());

+            this.originPosition = this.originOrbit.getRelativePositionAtUT(Planetarium.GetUniversalTime());

+

+            PhaseAngle = this.CalcCurrentPhaseAngle();

+            InterceptAngle = this.CalcInterceptAngle();

+            RelativeInclination = Vector3d.Angle(this.originOrbit.GetOrbitNormal(), this.targetOrbit.GetOrbitNormal());

+            AngleToAscendingNode = this.CalcAngleToAscendingNode();

+            AngleToDescendingNode = this.CalcAngleToDescendingNode();

+            Altitude = this.targetOrbit.altitude;

+            Distance = Vector3d.Distance(this.targetPosition, this.originPosition);

+            OrbitalPeriod = this.targetOrbit.period;

         }

 

         #endregion

@@ -82,5 +137,81 @@
         {

             instance.UpdateRequested = true;

         }

+

+        #region Calculations

+

+        private double CalcCurrentPhaseAngle()

+        {

+            return this.CalcPhaseAngle(this.originPosition, this.targetPosition);

+        }

+

+        private double CalcPhaseAngle(Vector3d originPos, Vector3d targetPos)

+        {

+            var phaseAngle = Vector3d.Angle(targetPos, originPos);

+            if (Vector3d.Angle(Quaternion.AngleAxis(90.0f, Vector3d.forward) * originPos, targetPos) > 90.0)

+            {

+                phaseAngle = 360 - phaseAngle;

+            }

+            return (phaseAngle + 360) % 360;

+        }

+

+        private double CalcInterceptAngle()

+        {

+            var angle = 180.0 * (1.0 - Math.Pow((this.originOrbit.radius + this.targetOrbit.radius) / (2.0 * this.targetOrbit.radius), 1.5));

+            if (angle < 0)

+            {

+                PhaseAngle -= 360;

+                angle = (PhaseAngle - angle) + 360;

+            }

+            else

+            {

+                angle = PhaseAngle - angle;

+            }

+            if (angle < 0)

+            {

+                angle += 360;

+            }

+            return angle;

+        }

+

+        private double CalcAngleToAscendingNode()

+        {

+            var angleToNode = 0.0;

+            if (this.originOrbit.inclination < 90.0)

+            {

+                angleToNode = this.CalcPhaseAngle(this.originPosition, this.GetAscendingNode());

+            }

+            else

+            {

+                angleToNode = 360 - this.CalcPhaseAngle(this.originPosition, this.GetAscendingNode());

+            }

+            return angleToNode;

+        }

+

+        private double CalcAngleToDescendingNode()

+        {

+            var angleToNode = 0.0;

+            if (this.originOrbit.inclination < 90.0)

+            {

+                angleToNode = this.CalcPhaseAngle(this.originPosition, this.GetDescendingNode());

+            }

+            else

+            {

+                angleToNode = 360 - this.CalcPhaseAngle(this.originPosition, this.GetDescendingNode());

+            }

+            return angleToNode;

+        }

+

+        private Vector3d GetAscendingNode()

+        {

+            return Vector3d.Cross(this.targetOrbit.GetOrbitNormal(), this.originOrbit.GetOrbitNormal());

+        }

+

+        private Vector3d GetDescendingNode()

+        {

+            return Vector3d.Cross(this.originOrbit.GetOrbitNormal(), this.targetOrbit.GetOrbitNormal());

+        }

+

+        #endregion

     }

 }

--- a/KerbalEngineer/Flight/Sections/SectionModule.cs
+++ b/KerbalEngineer/Flight/Sections/SectionModule.cs
@@ -130,7 +130,7 @@
         /// </summary>

         public string[] ReadoutModuleNames

         {

-            get { return this.ReadoutModules.Select(r => r.GetType().Name).ToArray(); }

+            get { return this.ReadoutModules.Select(r => r.Category + "." + r.GetType().Name).ToArray(); }

             set { this.ReadoutModules = value.Select(n => ReadoutLibrary.Instance.GetReadoutModule(n)).ToList(); }

         }

 


--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -83,6 +83,12 @@
     <Compile Include="Flight\Readouts\ReadoutCategory.cs" />

     <Compile Include="Flight\Readouts\ReadoutLibrary.cs" />

     <Compile Include="Flight\Readouts\ReadoutModule.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\OrbitalPeriod.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\Distance.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\Altitude.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\AngleToDescendingNode.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\AngleToAscendingNode.cs" />

+    <Compile Include="Flight\Readouts\Rendezvous\PhaseAngle.cs" />

     <Compile Include="Flight\Readouts\Rendezvous\RelativeInclination.cs" />

     <Compile Include="Flight\Readouts\Rendezvous\RendezvousProcessor.cs" />

     <Compile Include="Flight\Readouts\Rendezvous\TargetSelector.cs" />


 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ