Skip to content

Commit

Permalink
Normalize all the line endings
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <[email protected]>
  • Loading branch information
lamont-granquist committed Aug 26, 2017
1 parent 824e322 commit 9bc2fb8
Show file tree
Hide file tree
Showing 47 changed files with 16,550 additions and 16,550 deletions.
124 changes: 62 additions & 62 deletions MechJeb2/CelestialBodyExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
using System;
using UnityEngine;

namespace MuMech
{
public static class CelestialBodyExtensions
{
public static double TerrainAltitude(this CelestialBody body, Vector3d worldPosition)
{
return body.TerrainAltitude(body.GetLatitude(worldPosition), body.GetLongitude(worldPosition));
}

//The KSP drag law is dv/dt = -b * v^2 where b is proportional to the air density and
//the ship's drag coefficient. In this equation b has units of inverse length. So 1/b
//is a characteristic length: a ship that travels this distance through air will lose a significant
//fraction of its initial velocity
public static double DragLength(this CelestialBody body, Vector3d pos, double dragCoeff, double mass)
{
double airDensity = FlightGlobals.getAtmDensity(FlightGlobals.getStaticPressure(pos, body), FlightGlobals.getExternalTemperature(pos, body));

if (airDensity <= 0) return Double.MaxValue;

//MechJebCore.print("DragLength " + airDensity.ToString("F5") + " " + dragCoeff.ToString("F5"));

return mass / (0.0005 * PhysicsGlobals.DragMultiplier * airDensity * dragCoeff);
}

public static double DragLength(this CelestialBody body, double altitudeASL, double dragCoeff, double mass)
{
return body.DragLength(body.GetWorldSurfacePosition(0, 0, altitudeASL), dragCoeff, mass);
}

public static double RealMaxAtmosphereAltitude(this CelestialBody body)
{
return !body.atmosphere ? 0 : body.atmosphereDepth;
}


public static double AltitudeForPressure(this CelestialBody body, double pressure)
{
if (!body.atmosphere)
return 0;
double upperAlt = body.atmosphereDepth;
double lowerAlt = 0;
while (upperAlt - lowerAlt > 10)
{
double testAlt = (upperAlt + lowerAlt) * 0.5;
double testPressure = FlightGlobals.getStaticPressure(testAlt, body);
if (testPressure < pressure)
{
upperAlt = testAlt;
}
else
{
lowerAlt = testAlt;
}
}
return (upperAlt + lowerAlt) * 0.5;
}

}
}
using System;
using UnityEngine;

namespace MuMech
{
public static class CelestialBodyExtensions
{
public static double TerrainAltitude(this CelestialBody body, Vector3d worldPosition)
{
return body.TerrainAltitude(body.GetLatitude(worldPosition), body.GetLongitude(worldPosition));
}

//The KSP drag law is dv/dt = -b * v^2 where b is proportional to the air density and
//the ship's drag coefficient. In this equation b has units of inverse length. So 1/b
//is a characteristic length: a ship that travels this distance through air will lose a significant
//fraction of its initial velocity
public static double DragLength(this CelestialBody body, Vector3d pos, double dragCoeff, double mass)
{
double airDensity = FlightGlobals.getAtmDensity(FlightGlobals.getStaticPressure(pos, body), FlightGlobals.getExternalTemperature(pos, body));

if (airDensity <= 0) return Double.MaxValue;

//MechJebCore.print("DragLength " + airDensity.ToString("F5") + " " + dragCoeff.ToString("F5"));

return mass / (0.0005 * PhysicsGlobals.DragMultiplier * airDensity * dragCoeff);
}

public static double DragLength(this CelestialBody body, double altitudeASL, double dragCoeff, double mass)
{
return body.DragLength(body.GetWorldSurfacePosition(0, 0, altitudeASL), dragCoeff, mass);
}

public static double RealMaxAtmosphereAltitude(this CelestialBody body)
{
return !body.atmosphere ? 0 : body.atmosphereDepth;
}


public static double AltitudeForPressure(this CelestialBody body, double pressure)
{
if (!body.atmosphere)
return 0;
double upperAlt = body.atmosphereDepth;
double lowerAlt = 0;
while (upperAlt - lowerAlt > 10)
{
double testAlt = (upperAlt + lowerAlt) * 0.5;
double testPressure = FlightGlobals.getStaticPressure(testAlt, body);
if (testPressure < pressure)
{
upperAlt = testAlt;
}
else
{
lowerAlt = testAlt;
}
}
return (upperAlt + lowerAlt) * 0.5;
}

}
}
Loading

0 comments on commit 9bc2fb8

Please sign in to comment.