public RgbaColor(double red, double green, double blue, double alpha = 1.0) { Red = DirectBindingMath.Clamp(red, 0, 1); Green = DirectBindingMath.Clamp(green, 0, 1); Blue = DirectBindingMath.Clamp(blue, 0, 1); Alpha = DirectBindingMath.Clamp(alpha, 0, 1); }
public void UpdateAutopilot(FlightCtrlState c) { Vector3d translate = translateProvider(); c.X = (float)DirectBindingMath.Clamp(translate.x, -1, 1); c.Y = (float)DirectBindingMath.Clamp(translate.y, -1, 1); c.Z = (float)DirectBindingMath.Clamp(translate.z, -1, 1); }
public double UTAtMeanAnomaly(double meanAnomaly, double ut) { double currentMeanAnomaly = MeanAnomalyAtUt(ut); double meanDifference = meanAnomaly - currentMeanAnomaly; if (eccentricity < 1) { meanDifference = DirectBindingMath.ClampRadians2Pi(meanDifference); } return(ut + meanDifference / MeanMotion); }
public double MeanAnomalyAtUt(double ut) { // We use ObtAtEpoch and not meanAnomalyAtEpoch because somehow meanAnomalyAtEpoch // can be wrong when using the RealSolarSystem mod. ObtAtEpoch is always correct. double ret = (orbitTimeAtEpoch + (ut - epoch)) * MeanMotion; if (eccentricity < 1) { ret = DirectBindingMath.ClampRadians2Pi(ret); } return(ret); }
public double GetMeanAnomalyAtEccentricAnomaly(double ecc) { double e = eccentricity; if (e < 1) { //elliptical orbits return(DirectBindingMath.ClampRadians2Pi(ecc - (e * Math.Sin(ecc)))); } else { //hyperbolic orbits return((e * Math.Sinh(ecc)) - ecc); } }
public void UpdateAutopilot(FlightCtrlState c) { if (!(vessel.vessel.horizontalSrfSpeed > 0.1f)) { return; } if (Math.Abs(ExtraMath.AngleDelta(vessel.Heading, vessel.VelocityHeading)) <= 90) { c.wheelSteer = (float)DirectBindingMath.Clamp(bearingProvider() / -10, -1, 1); } else { c.wheelSteer = -(float)DirectBindingMath.Clamp(bearingProvider() / -10, -1, 1); } }
public double GetEccentricAnomalyAtTrueAnomaly(double trueAnomaly) { double e = eccentricity; trueAnomaly = DirectBindingMath.ClampRadians2Pi(trueAnomaly); if (e < 1) { //elliptical orbits double cosE = (e + Math.Cos(trueAnomaly)) / (1 + e * Math.Cos(trueAnomaly)); double sinE = Math.Sqrt(1 - (cosE * cosE)); if (trueAnomaly > Math.PI) { sinE *= -1; } return(DirectBindingMath.ClampRadians2Pi(Math.Atan2(sinE, cosE))); } else { //hyperbolic orbits double coshE = (e + Math.Cos(trueAnomaly)) / (1 + e * Math.Cos(trueAnomaly)); if (coshE < 1) { throw new ArgumentException("OrbitExtensions.GetEccentricAnomalyAtTrueAnomaly: True anomaly of " + trueAnomaly + " radians is not attained by orbit with eccentricity " + eccentricity); } double ecc = DirectBindingMath.Acosh(coshE); if (trueAnomaly > Math.PI) { ecc *= -1; } return(ecc); } }
public void UpdateAutopilot(FlightCtrlState c) { c.wheelThrottle = (float)DirectBindingMath.Clamp(throttleProvider(), 0, 1); }
public double DescendingNodeTrueAnomaly(KSPOrbitModule.IOrbit b) => DirectBindingMath.ClampRadians2Pi(AscendingNodeTrueAnomaly(b) + Math.PI);