/// <summary>Estimated solar flux from the first parent sun of the given body, including other neighbouring stars/suns (binary systems handling)</summary> /// <param name="body"></param> /// <param name="worstCase">if true, we use the largest distance between the body and the sun</param> /// <param name="mainSun"></param> /// <param name="mainSunDirection"></param> /// <param name="mainSunDistance"></param> /// <returns></returns> public static double SolarFluxAtBody(CelestialBody body, bool worstCase, out CelestialBody mainSun, out Vector3d mainSunDirection, out double mainSunDistance) { // get first parent sun mainSun = Lib.GetParentSun(body); // get direction and distance mainSunDirection = (mainSun.position - body.position).normalized; if (worstCase) { mainSunDistance = Sim.Apoapsis(Lib.GetParentPlanet(body)) - mainSun.Radius - body.Radius; } else { mainSunDistance = Sim.SunDistance(body.position, mainSun); } // get solar flux int mainSunIndex = mainSun.flightGlobalsIndex; Sim.SunData mainSunData = Sim.suns.Find(pr => pr.bodyIndex == mainSunIndex); double solarFlux = mainSunData.SolarFlux(mainSunDistance); // multiple suns handling (binary systems...) foreach (Sim.SunData otherSun in Sim.suns) { if (otherSun.body == mainSun) { continue; } Vector3d otherSunDir = (otherSun.body.position - body.position).normalized; double otherSunDist; if (worstCase) { otherSunDist = Sim.Apoapsis(Lib.GetParentPlanet(body)) - otherSun.body.Radius; } else { otherSunDist = Sim.SunDistance(body.position, otherSun.body); } // account only for other suns that have approximatively the same direction (+/- 30°), discard the others if (Vector3d.Angle(otherSunDir, mainSunDirection) > 30.0) { continue; } solarFlux += otherSun.SolarFlux(otherSunDist); } return(solarFlux); }
public SunInfo(Sim.SunData sunData) { this.sunData = sunData; }