Merge in changes from CYBUTEK's Helpers, Logger
Merge in changes from CYBUTEK's Helpers, Logger

--- a/Averager.cs
+++ b/Averager.cs
@@ -18,50 +18,49 @@
 // 
 
 using System;
-using UnityEngine;
 
 namespace KerbalEngineer
 { 
     public class VectorAverager
     {
-        private Vector3 sum = Vector3.zero;
+        private Vector3d sum = Vector3d.zero;
         private uint count = 0;
 
-        public void Add(Vector3 v) {
+        public void Add(Vector3d v) {
             sum += v;
             count += 1;
         }
 
-        public Vector3 Get() {
+        public Vector3d Get() {
             if (count > 0) {
                 return sum / count;
             } else {
-                return Vector3.zero;
+                return Vector3d.zero;
             }
         }
 
         public void Reset()
         {
-            sum = Vector3.zero;
+            sum = Vector3d.zero;
             count = 0;
         }
     }
 
     public class WeightedVectorAverager
     {
-        private Vector3 sum = Vector3.zero;
+        private Vector3d sum = Vector3d.zero;
         private double totalweight = 0;
 
-        public void Add(Vector3 v, double weight) {
-            sum += v * (float)weight;
+        public void Add(Vector3d v, double weight) {
+            sum += v * weight;
             totalweight += weight;
         }
 
-        public Vector3 Get() {
+        public Vector3d Get() {
             if (totalweight > 0) {
-                return sum / (float)totalweight;
+                return sum / totalweight;
             } else {
-                return Vector3.zero;
+                return Vector3d.zero;
             }
         }
 
@@ -71,7 +70,7 @@
 
         public void Reset()
         {
-            sum = Vector3.zero;
+            sum = Vector3d.zero;
             totalweight = 0.0;
         }
     }

--- a/ForceAccumulator.cs
+++ b/ForceAccumulator.cs
@@ -20,7 +20,6 @@
 using System;
 using System.Collections.Generic;
 using KerbalEngineer.VesselSimulator;
-using UnityEngine;
 
 namespace KerbalEngineer
 {
@@ -29,8 +28,8 @@
     {
         private static readonly Pool<AppliedForce> pool = new Pool<AppliedForce>(Create, Reset);
 
-        public Vector3 vector;
-        public Vector3 applicationPoint;
+        public Vector3d vector;
+        public Vector3d applicationPoint;
 
         static private AppliedForce Create()
         {
@@ -39,7 +38,7 @@
 
         static private void Reset(AppliedForce appliedForce) { }
 
-        static public AppliedForce New(Vector3 vector, Vector3 applicationPoint)
+        static public AppliedForce New(Vector3d vector, Vector3d applicationPoint)
         {
             AppliedForce force = pool.Borrow();
             force.vector = vector;
@@ -69,22 +68,22 @@
 	public class ForceAccumulator
 	{
 	    // Total force.
-		private Vector3 totalForce = Vector3.zero;
+		private Vector3d totalForce = Vector3d.zero;
 		// Torque needed to compensate if force were applied at origin.
-		private Vector3 totalZeroOriginTorque = Vector3.zero;
+		private Vector3d totalZeroOriginTorque = Vector3d.zero;
 
 		// Weighted average of force application points.
 		private WeightedVectorAverager avgApplicationPoint = new WeightedVectorAverager();
 
 		// Feed an force to the accumulator.
-		public void AddForce(Vector3 applicationPoint, Vector3 force)
+		public void AddForce(Vector3d applicationPoint, Vector3d force)
 		{
 			totalForce += force;
-			totalZeroOriginTorque += Vector3.Cross(applicationPoint, force);
+			totalZeroOriginTorque += Vector3d.Cross(applicationPoint, force);
 			avgApplicationPoint.Add(applicationPoint, force.magnitude);
 		}
 
-        public Vector3 GetAverageForceApplicationPoint() {
+        public Vector3d GetAverageForceApplicationPoint() {
             return avgApplicationPoint.Get();
         }
 
@@ -93,38 +92,38 @@
         }
 
 		// Residual torque for given force application point.
-		public Vector3 TorqueAt(Vector3 origin)
+		public Vector3d TorqueAt(Vector3d origin)
 		{
-			return totalZeroOriginTorque - Vector3.Cross(origin, totalForce);
+			return totalZeroOriginTorque - Vector3d.Cross(origin, totalForce);
 		}
 
         // Total force vector.
-        public Vector3 GetTotalForce()
+        public Vector3d GetTotalForce()
         {
             return totalForce;
         }
 
         // Returns the minimum-residual-torque force application point that is closest to origin.
         // Note that TorqueAt(GetMinTorquePos()) is always parallel to totalForce.
-        public Vector3 GetMinTorqueForceApplicationPoint(Vector3 origin)
+        public Vector3d GetMinTorqueForceApplicationPoint(Vector3d origin)
         {
             double fmag = totalForce.sqrMagnitude;
             if (fmag <= 0) {
                 return origin;
             }
 
-            return origin + Vector3.Cross(totalForce, TorqueAt(origin)) / (float)fmag;
+            return origin + Vector3d.Cross(totalForce, TorqueAt(origin)) / fmag;
         }
 
-        public Vector3 GetMinTorqueForceApplicationPoint()
+        public Vector3d GetMinTorqueForceApplicationPoint()
         {
             return GetMinTorqueForceApplicationPoint(avgApplicationPoint.Get());
         }
 
 	    public void Reset()
 	    {
-	        totalForce = Vector3.zero;
-	        totalZeroOriginTorque = Vector3.zero;
+	        totalForce = Vector3d.zero;
+	        totalZeroOriginTorque = Vector3d.zero;
             avgApplicationPoint.Reset();
 	    }
 	}

file:a/Logger.cs -> file:b/Logger.cs
--- a/Logger.cs
+++ b/Logger.cs
@@ -1,4 +1,4 @@
-// 
+// 
 //     Kerbal Engineer Redux
 // 
 //     Copyright (C) 2014 CYBUTEK

file:a/Units.cs -> file:b/Units.cs
--- a/Units.cs
+++ b/Units.cs
@@ -1,7 +1,7 @@
 // 
 //     Kerbal Engineer Redux
 // 
-//     Copyright (C) 2014 CYBUTEK
+//     Copyright (C) 2015 CYBUTEK
 // 
 //     This program is free software: you can redistribute it and/or modify
 //     it under the terms of the GNU General Public License as published by
@@ -19,15 +19,13 @@
 
 namespace KerbalEngineer.Helpers
 {
-    #region Using Directives
     using System;
-
-    #endregion
 
     public static class Units
     {
-        #region Methods
         public const double GRAVITY = 9.80665;
+        public const double RAD_TO_DEG = 180.0 / Math.PI;
+        public const double DEG_TO_RAD = Math.PI / 180.0;
 
         public static string Concat(int value1, int value2)
         {
@@ -95,7 +93,7 @@
             int min = (int)Math.Floor(rem * 60);
             rem -= ((double)min / 60);
             int sec = (int)Math.Floor(rem * 3600);
-            return String.Format("{0:0}° {1:00}' {2:00}\"", deg, min, sec); 
+            return string.Format("{0:0}° {1:00}' {2:00}\"", deg, min, sec);
         }
 
         public static string ToDistance(double value, int decimals = 1)
@@ -127,16 +125,26 @@
             return value.ToString("N" + decimals) + "Mm";
         }
 
+        public static string ToFlux(double value)
+        {
+            return value.ToString("#,0.00") + "kW";
+        }
+
         public static string ToForce(double value)
         {
-            return value.ToString((value < 100000.0) ? (value < 10000.0) ? (value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0") + "kN";
+            return value.ToString((value < 100000.0) ? (value < 10000.0) ? (value < 100.0) ? (Math.Abs(value) < double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0") + "kN";
         }
 
         public static string ToForce(double value1, double value2)
         {
-            string format1 = (value1 < 100000.0) ? (value1 < 10000.0) ? (value1 < 100.0) ? (Math.Abs(value1) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
-            string format2 = (value2 < 100000.0) ? (value2 < 10000.0) ? (value2 < 100.0) ? (Math.Abs(value2) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
+            string format1 = (value1 < 100000.0) ? (value1 < 10000.0) ? (value1 < 100.0) ? (Math.Abs(value1) < double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
+            string format2 = (value2 < 100000.0) ? (value2 < 10000.0) ? (value2 < 100.0) ? (Math.Abs(value2) < double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
             return value1.ToString(format1) + " / " + value2.ToString(format2) + "kN";
+        }
+
+        public static string ToMach(double value)
+        {
+            return value.ToString("0.00") + "Ma";
         }
 
         public static string ToMass(double value, int decimals = 0)
@@ -182,6 +190,16 @@
             return value.ToString("N" + decimals) + "m/s";
         }
 
+        public static string ToTemperature(double value)
+        {
+            return value.ToString("#,0") + "K";
+        }
+
+        public static string ToTemperature(double value1, double value2)
+        {
+            return value1.ToString("#,0") + " / " + value2.ToString("#,0") + "K";
+        }
+
         public static string ToTime(double value)
         {
             throw new NotImplementedException("ToTime method not implemented in this build of VesselSimulator.");
@@ -189,8 +207,7 @@
 
         public static string ToTorque(double value)
         {
-            return value.ToString((value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N1" : "N0") + "kNm";
-        }
-        #endregion
+            return value.ToString((value < 100.0) ? (Math.Abs(value) < double.Epsilon) ? "N0" : "N2" : "N0") + "kNm";
+        }
     }
 }