private static List <ISpaceCraft> BuildFalconHeavyDemo(IMassiveBody planet, MissionConfig config, string craftDirectory) { var roadster = new Roadster(craftDirectory, planet.Position + new DVector2(planet.SurfaceRadius, 0) + config.PositionOffset, planet.Velocity + new DVector2(0, -400) + config.VelocityOffset, config.PayloadMass); var fairingLeft = new Fairing(craftDirectory, roadster.Position, DVector2.Zero, true, -5.0); var fairingRight = new Fairing(craftDirectory, roadster.Position, DVector2.Zero, false, -5.0); roadster.AttachFairings(fairingLeft, fairingRight); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero, 404272); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero, 8.4); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero, 396772); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero, 396772); roadster.AddChild(fhS2); fhS2.SetParent(roadster); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { roadster, fhS2, fhLeftBooster, fhS1, fhRightBooster, fairingLeft, fairingRight }); }
public static List <ISpaceCraft> BuildFalconHeavy(IMassiveBody planet, string path) { Payload payload = GetPayload(path); var demoSat = new DemoSat(planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), payload.DryMass, payload.PropellantMass); var fhS1 = new FHS1(DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(fhS2); fhS2.SetParent(demoSat); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { demoSat, fhS2, fhS1, fhLeftBooster, fhRightBooster }); }
private static List <ISpaceCraft> BuildElectron(IMassiveBody planet, MissionConfig config, string craftDirectory) { var kickStage = new ElectronKickStage(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), config.PayloadMass); var leftFairing = new ElectronFairing(craftDirectory, kickStage.Position, DVector2.Zero, true); var rightFairing = new ElectronFairing(craftDirectory, kickStage.Position, DVector2.Zero, false); kickStage.AttachFairings(leftFairing, rightFairing); var leftBattery = new ElectronBattery(craftDirectory, kickStage.Position, DVector2.Zero, true); var rightBattery = new ElectronBattery(craftDirectory, kickStage.Position, DVector2.Zero, false); kickStage.AttachBatteries(leftBattery, rightBattery); var electronS1 = new ElectronS1(craftDirectory, DVector2.Zero, DVector2.Zero); var electronS2 = new ElectronS2(craftDirectory, DVector2.Zero, DVector2.Zero); kickStage.AddChild(electronS2); electronS2.SetParent(kickStage); electronS2.AddChild(electronS1); electronS1.SetParent(electronS2); return(new List <ISpaceCraft> { kickStage, electronS2, leftBattery, rightBattery, electronS1, leftFairing, rightFairing }); }
private static List <ISpaceCraft> BuildDeltaHeavy(IMassiveBody planet, MissionConfig config, string craftDirectory) { var demoSat = new ParkerSolarProbe(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius) + config.PositionOffset, planet.Velocity + new DVector2(-400, 0) + config.VelocityOffset, config.PayloadMass); var fairingLeft = new DIVH5mFairing(craftDirectory, demoSat.Position, DVector2.Zero, true); var fairingRight = new DIVH5mFairing(craftDirectory, demoSat.Position, DVector2.Zero, false); demoSat.AttachFairings(fairingLeft, fairingRight); var dhS1 = new CommonBoosterCore(craftDirectory, DVector2.Zero, DVector2.Zero); var dhS2 = new DIVHS2(craftDirectory, DVector2.Zero, DVector2.Zero, 7.2); var dhS3 = new Star48PAM(craftDirectory, DVector2.Zero, DVector2.Zero, 3); var dhLeftBooster = new SideBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var dhRightBooster = new SideBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(dhS3); dhS3.SetParent(demoSat); dhS3.AddChild(dhS2); dhS2.SetParent(dhS3); dhS2.AddChild(dhS1); dhS1.SetParent(dhS2); dhS1.AddChild(dhLeftBooster); dhS1.AddChild(dhRightBooster); dhLeftBooster.SetParent(dhS1); dhRightBooster.SetParent(dhS1); return(new List <ISpaceCraft> { demoSat, dhS3, dhS2, dhLeftBooster, dhS1, dhRightBooster, fairingLeft, fairingRight }); }
private static List <ISpaceCraft> BuildFalconHeavy(IMassiveBody planet, Payload payload, string craftDirectory, float offset = 0) { var demoSat = new DemoSat(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), payload.DryMass, payload.PropellantMass); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(fhS2); fhS2.SetParent(demoSat); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { demoSat, fhS2, fhS1, fhLeftBooster, fhRightBooster }); }
public void Draw(Graphics graphics, Camera camera, IMassiveBody parentBody) { var poweredTrails = new List <RectangleF>(); var coastTrails = new List <RectangleF>(); for (int i = 0; i < _trailAngles.Count; i++) { double angle = _trailAngles[i] + parentBody.Pitch; double distance = _trailDistances[i]; DVector2 worldPoint = DVector2.FromAngle(angle) * distance + parentBody.Position; if (camera.Contains(worldPoint)) { PointF localPoint = RenderUtils.WorldToScreen(worldPoint, camera.Bounds); if (_trailPowered[i]) { poweredTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2)); } else { coastTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2)); } } } RenderUtils.DrawRectangles(graphics, poweredTrails, Color.Red); RenderUtils.DrawRectangles(graphics, coastTrails, Color.White); }
private static List <ISpaceCraft> BuildRedDragonFH(IMassiveBody planet, Payload payload, string craftDirectory, float offset = 0) { var redDragon = new RedDragon.RedDragon(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), payload.DryMass, payload.PropellantMass); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); redDragon.AddChild(dragonTrunk); dragonTrunk.SetParent(redDragon); dragonTrunk.AddChild(fhS2); fhS2.SetParent(dragonTrunk); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { redDragon, dragonTrunk, fhS2, fhS1, fhLeftBooster, fhRightBooster }); }
private static List <ISpaceCraft> BuildFalconHeavy(IMassiveBody planet, MissionConfig config, string craftDirectory) { var demoSat = new DemoSat(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius) + config.PositionOffset, planet.Velocity + new DVector2(-400, 0) + config.VelocityOffset, config.PayloadMass); var fairingLeft = new Fairing(craftDirectory, demoSat.Position, DVector2.Zero, true); var fairingRight = new Fairing(craftDirectory, demoSat.Position, DVector2.Zero, false); demoSat.AttachFairings(fairingLeft, fairingRight); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(fhS2); fhS2.SetParent(demoSat); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { demoSat, fhS2, fhS1, fhLeftBooster, fhRightBooster }); }
public void Draw(Graphics graphics, RectangleD cameraBounds, IMassiveBody parentBody) { var poweredTrails = new List<RectangleF>(); var coastTrails = new List<RectangleF>(); for (int i = 0; i < _trailAngles.Count; i++) { double angle = _trailAngles[i] + parentBody.Pitch; double distance = _trailDistances[i]; DVector2 worldPoint = DVector2.FromAngle(angle) * distance + parentBody.Position; if (cameraBounds.Contains(worldPoint)) { PointF localPoint = RenderUtils.WorldToScreen(worldPoint, cameraBounds); if (_trailPowered[i]) { poweredTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2)); } else { coastTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2)); } } } RenderUtils.DrawRectangles(graphics, poweredTrails, Color.Red); RenderUtils.DrawRectangles(graphics, coastTrails, Color.White); }
public static List <ISpaceCraft> BuildSpaceCraft(IMassiveBody planet, double surfaceAngle, MissionConfig config, string craftDirectory) { if (string.IsNullOrEmpty(config.VehicleType)) { throw new Exception("Must specify a vehicle type in the MissionConfig.xml!"); } if (string.IsNullOrEmpty(config.ParentPlanet)) { throw new Exception("Must specify a parent planet for the launch vehicle!"); } var planetOffset = new DVector2(Math.Cos(surfaceAngle) * planet.SurfaceRadius, Math.Sin(surfaceAngle) * planet.SurfaceRadius); List <ISpaceCraft> spaceCrafts = GenerateSpaceCraft(planet, config, craftDirectory); if (spaceCrafts.Count == 0) { throw new Exception("No spacecrafts produced!"); } ISpaceCraft primaryCraft = spaceCrafts[0]; DVector2 distanceFromSurface = primaryCraft.Position - planet.Position; // If the ship is spawned on the planet update it's position to the correct surface angle if (distanceFromSurface.Length() * 0.999 < planet.SurfaceRadius) { primaryCraft.SetSurfacePosition(planet.Position + planetOffset, surfaceAngle); } return(spaceCrafts); }
private static List <ISpaceCraft> BuildGreyDragonFH(IMassiveBody planet, MissionConfig config, string craftDirectory) { var dragon = new GreyDragon.GreyDragon(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity, config.PayloadMass, 446); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); dragonTrunk.AddChild(fhS2); fhS2.SetParent(dragonTrunk); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return(new List <ISpaceCraft> { dragon, dragonTrunk, fhS2, fhS1, fhLeftBooster, fhRightBooster }); }
private static List <ISpaceCraft> BuildSLS(IMassiveBody planet, MissionConfig config, string craftDirectory) { var demoSat = new EuropaClipper(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius) + config.PositionOffset, planet.Velocity + new DVector2(-400, 0) + config.VelocityOffset, config.PayloadMass); var fairingLeft = new SLS5mFairing(craftDirectory, demoSat.Position, DVector2.Zero, true); var fairingRight = new SLS5mFairing(craftDirectory, demoSat.Position, DVector2.Zero, false); demoSat.AttachFairings(fairingLeft, fairingRight); var slsS1 = new SLSS1(craftDirectory, DVector2.Zero, DVector2.Zero); var slsS2 = new SLSS2(craftDirectory, DVector2.Zero, DVector2.Zero, 9.9); var slsLeftBooster = new SLSBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var slsRightBooster = new SLSBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(slsS2); slsS2.SetParent(demoSat); slsS2.AddChild(slsS1); slsS1.SetParent(slsS2); slsS1.AddChild(slsLeftBooster); slsS1.AddChild(slsRightBooster); slsLeftBooster.SetParent(slsS1); slsRightBooster.SetParent(slsS1); return(new List <ISpaceCraft> { demoSat, slsS2, slsLeftBooster, slsS1, slsRightBooster, fairingLeft, fairingRight }); }
private static double GetDownrangeAngle(IMassiveBody planet, double downrangeDistance) { double circumference = 2 * Math.PI * planet.SurfaceRadius; double downrangeRatio = -downrangeDistance / circumference; return(downrangeRatio * Math.PI * 2); }
private static List <ISpaceCraft> BuildF9SSTO(IMassiveBody planet, string craftDirectory) { var f9SSTO = new F9SSTO(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity); return(new List <ISpaceCraft> { f9SSTO }); }
public void AddPoint(DVector2 point, IMassiveBody parentBody, bool isPowered) { DVector2 offset = point - parentBody.Position; _trailAngles.Add(offset.Angle() - parentBody.Pitch); _trailDistances.Add(offset.Length()); _trailPowered.Add(isPowered); }
public static List <ISpaceCraft> BuildF9SSTO(IMassiveBody planet, string path) { var f9SSTO = new F9SSTO(planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0)); return(new List <ISpaceCraft> { f9SSTO }); }
private static List <ISpaceCraft> BuildMiniBfs(IMassiveBody planet, MissionConfig config, string craftDirectory) { // inclination 28.5° var ship = new MiniBFS(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), config.PayloadMass, 75000); return(new List <ISpaceCraft> { ship }); }
private static List <ISpaceCraft> BuildF9S2EDL(IMassiveBody planet, MissionConfig config, string craftDirectory) { var s2 = new F9S2B(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius - 150000), planet.Velocity + new DVector2(-10000, 850), 0, 1000); return(new List <ISpaceCraft> { s2 }); }
private static List <ISpaceCraft> BuildScaledBfsEDL(IMassiveBody planet, MissionConfig config, string craftDirectory) { var ship = new ScaledBFS(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius - 150000), planet.Velocity + new DVector2(-10800, 1161.2), config.PayloadMass, 20000); return(new List <ISpaceCraft> { ship }); }
private static List <ISpaceCraft> BuildItsEDL(IMassiveBody planet, MissionConfig config, string craftDirectory) { var ship = new ITSShip(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius - 150000), planet.Velocity + new DVector2(-7400, 700), config.PayloadMass, 0); return(new List <ISpaceCraft> { ship }); }
private static List <ISpaceCraft> BuildScaledBfsTEI(IMassiveBody planet, MissionConfig config, string craftDirectory) { var ship = new ScaledBFS(craftDirectory, planet.Position + new DVector2(planet.SurfaceRadius, 0), planet.Velocity + new DVector2(0, 0), config.PayloadMass, 136600); return(new List <ISpaceCraft> { ship }); }
private static List <ISpaceCraft> BuildBfs300(IMassiveBody planet, MissionConfig config, string craftDirectory) { // inclination 53° var ship = new BFS300(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-277, 0), config.PayloadMass, 1100000); return(new List <ISpaceCraft> { ship }); }
private static List <ISpaceCraft> BuildBfsMarsReturnEdl(IMassiveBody planet, MissionConfig config, string craftDirectory) { var ship = new BFS300(craftDirectory, planet.Position + new DVector2(0, planet.SurfaceRadius + 166000.0), planet.Velocity + new DVector2(12500, -1640), config.PayloadMass, 30000); return(new List <ISpaceCraft> { ship }); }
public static List <ISpaceCraft> BuildAutoLandingTest(IMassiveBody planet, MissionConfig payload, string craftDirectory) { var f9 = new F9S1(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius - 7000), planet.Velocity + new DVector2(-400, 400), 3500); return(new List <ISpaceCraft> { f9, }); }
public double GetSurfaceAngle(DateTime localTime, IMassiveBody sun) { DVector2 sunDifference = sun.Position - Position; double noonAngle = sunDifference.Angle(); TimeSpan noonOffset = new TimeSpan(localTime.Hour, localTime.Minute, localTime.Second) - new TimeSpan(12, 0, 0); return(noonAngle + noonOffset.TotalSeconds * RotationRate); }
private static List <ISpaceCraft> BuildITSTanker(IMassiveBody planet, MissionConfig config, string craftDirectory) { var tanker = new ITSTanker(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), config.PayloadMass, 0); return(new List <ISpaceCraft> { tanker }); }
public static List<ISpaceCraft> BuildAutoLandingTest(IMassiveBody planet, VehicleConfig payload, string craftDirectory) { var f9 = new F9S1(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius - 7000), planet.Velocity + new DVector2(-400, 400), 3500); return new List<ISpaceCraft> { f9, }; }
public void ResolveAtmopsherics(IMassiveBody body) { DVector2 difference = body.Position - Position; double distance = difference.Length(); difference.Normalize(); double altitude = distance - body.SurfaceRadius; // The object is in the atmosphere of body B if (altitude < body.AtmosphereHeight) { var surfaceNormal = new DVector2(-difference.Y, difference.X); double altitudeFromCenter = altitude + body.SurfaceRadius; // Distance of circumference at this altitude ( c= 2r * pi ) double pathCirumference = 2 * Math.PI * altitudeFromCenter; double rotationalSpeed = pathCirumference / body.RotationPeriod; // Simple collision detection if (altitude <= 0) { var normal = new DVector2(-difference.X, -difference.Y); Position = body.Position + normal * (body.SurfaceRadius); Velocity = (body.Velocity + surfaceNormal * rotationalSpeed); Rotation = normal.Angle(); AccelerationN.X = -AccelerationG.X; AccelerationN.Y = -AccelerationG.Y; } double atmosphericDensity = body.GetAtmosphericDensity(altitude); DVector2 relativeVelocity = (body.Velocity + surfaceNormal * rotationalSpeed) - Velocity; double velocityMagnitude = relativeVelocity.LengthSquared(); if (velocityMagnitude > 0) { relativeVelocity.Normalize(); // Drag ( Fd = 0.5pv^2dA ) DVector2 dragForce = relativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * DragCoefficient * CrossSectionalArea); AccelerationD += dragForce / Mass; } } }
protected StructureBase(DVector2 relativePosition, string texturePath, IMassiveBody parent) { _parent = parent; _initialDistance = relativePosition.Length(); _rotationOffset = relativePosition.Angle(); _initialRotation = parent.Rotation; _texture = new Bitmap(texturePath); }
protected StructureBase(double surfaceAngle, double height, string texturePath, IMassiveBody parent) { _parent = parent; _initialDistance = parent.SurfaceRadius - height; _rotationOffset = surfaceAngle; _initialRotation = parent.Pitch; _texture = new Bitmap(texturePath); }
public static List <ISpaceCraft> BuildDragonV2Abort(IMassiveBody planet, string path) { var dragon = new DragonV2.DragonV2(planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity); var dragonTrunk = new DragonV2Trunk(DVector2.Zero, DVector2.Zero); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); return(new List <ISpaceCraft> { dragon, dragonTrunk }); }
private static List <ISpaceCraft> BuildDragonV2Abort(IMassiveBody planet, MissionConfig config, string craftDirectory) { var dragon = new DragonV2.DragonV2(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity, config.PayloadMass, 446); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); return(new List <ISpaceCraft> { dragon, dragonTrunk }); }
public static List<ISpaceCraft> BuildSpaceCraft(IMassiveBody planet, string craftDirectory, float offset = 0) { VehicleConfig vehicle = GetPayload(craftDirectory); if (string.IsNullOrEmpty(vehicle.VehicleType)) { throw new Exception("Please specify a craftType in the VehicleConfig.xml!"); } switch (vehicle.VehicleType) { case "GenericF9": return BuildF9(planet, vehicle, craftDirectory, offset); case "DragonF9": return BuildF9Dragon(planet, craftDirectory, vehicle, offset); case "F9SSTO": return BuildF9SSTO(planet, craftDirectory); case "DragonAbort": return BuildDragonV2Abort(planet, vehicle, craftDirectory); case "DragonEntry": return BuildDragonV2Entry(planet, vehicle, craftDirectory); case "RedDragonFH": return BuildRedDragonFH(planet, vehicle, craftDirectory, offset); case "GenericFH": return BuildFalconHeavy(planet, vehicle, craftDirectory, offset); case "AutoLandingTest": return BuildAutoLandingTest(planet, vehicle, craftDirectory); case "ITS Crew Launch": return BuildITSCrew(planet, vehicle, craftDirectory, offset); case "ITS Earth EDL": return BuildItsEarthEDL(planet, vehicle, craftDirectory, offset); case "ITS Earth Aerocapture": return BuildItsEarthAerocapture(planet, vehicle, craftDirectory, offset); case "ITS Earth Direct": return BuildItsEarthAerocapture(planet, vehicle, craftDirectory, offset); case "ITS Mars Aerocapture": return BuildItsMarsAerocapture(planet, vehicle, craftDirectory, offset); case "ITS Mars EDL": return BuildItsMarsEDL(planet, vehicle, craftDirectory, offset); case "ITS Mars Direct": return BuildItsMarsAerocapture(planet, vehicle, craftDirectory, offset); default: throw new Exception("Unknown craftType: " + vehicle.VehicleType); } }
public static List<ISpaceCraft> BuildFalconHeavy(IMassiveBody planet, string path) { var spacecraft = new List<ISpaceCraft>(); Payload payload = GetPayload(path); var demoSat = new DemoSat(planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), payload.DryMass, payload.PropellantMass); var falcon9S1 = new FH9S1(DVector2.Zero, DVector2.Zero); var falcon9S2 = new FH9S2(DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(falcon9S2); falcon9S2.SetParent(demoSat); falcon9S2.AddChild(falcon9S1); falcon9S1.SetParent(falcon9S2); falcon9S1.AddChild(fhLeftBooster); falcon9S1.AddChild(fhRightBooster); fhLeftBooster.SetParent(falcon9S1); fhRightBooster.SetParent(falcon9S1); spacecraft.Add(demoSat); spacecraft.Add(falcon9S2); spacecraft.Add(falcon9S1); spacecraft.Add(fhLeftBooster); spacecraft.Add(fhRightBooster); foreach (ISpaceCraft spaceCraft in spacecraft) { spaceCraft.InitializeController(path); } return spacecraft; }
private static List<ISpaceCraft> BuildDragonV2Entry(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory) { var dragon = new DragonV2.DragonV2(craftDirectory, planet.Position + new DVector2(planet.SurfaceRadius*0.75, planet.SurfaceRadius*-0.75), planet.Velocity + new DVector2(-6000, -5100), vehicle.PayloadMass); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); dragon.SetPitch(Math.PI * 1.24); return new List<ISpaceCraft> { dragon, dragonTrunk }; }
private static List<ISpaceCraft> BuildF9(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory, float offset = 0) { var demoSat = new DemoSat(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), vehicle.PayloadMass); var f9S1 = new F9S1(craftDirectory, DVector2.Zero, DVector2.Zero); var f9S2 = new F9S2(craftDirectory, DVector2.Zero, DVector2.Zero, 13.3); demoSat.AddChild(f9S2); f9S2.SetParent(demoSat); f9S2.AddChild(f9S1); f9S1.SetParent(f9S2); return new List<ISpaceCraft> { demoSat, f9S2, f9S1 }; }
private static List<ISpaceCraft> BuildF9Dragon(IMassiveBody planet, string craftDirectory, VehicleConfig vehicle, float offset = 0) { var dragon = new Dragon(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity, vehicle.PayloadMass); var dragonTrunk = new DragonTrunk(craftDirectory, DVector2.Zero, DVector2.Zero); var f9S1 = new F9S1(craftDirectory, DVector2.Zero, DVector2.Zero); var f9S2 = new F9S2(craftDirectory, DVector2.Zero, DVector2.Zero, 8.3); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); dragonTrunk.AddChild(f9S2); f9S2.SetParent(dragonTrunk); f9S2.AddChild(f9S1); f9S1.SetParent(f9S2); return new List<ISpaceCraft> { dragon, dragonTrunk, f9S2, f9S1 }; }
private static List<ISpaceCraft> BuildF9SSTO(IMassiveBody planet, string craftDirectory) { var f9SSTO = new F9SSTO(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0)); return new List<ISpaceCraft> { f9SSTO }; }
private static List<ISpaceCraft> BuildFalconHeavy(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory, float offset = 0) { var demoSat = new DemoSat(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), vehicle.PayloadMass); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); demoSat.AddChild(fhS2); fhS2.SetParent(demoSat); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return new List<ISpaceCraft> { demoSat, fhS2, fhS1, fhLeftBooster, fhRightBooster }; }
public void SetGravitationalParent(IMassiveBody parent) { GravitationalParent = parent; }
public void ResolveAtmopsherics(IMassiveBody body) { // Don't resolve drag for children if (Parent != null) return; DVector2 difference = body.Position - Position; double heightOffset = Children.Count > 0 ? TotalHeight - Height*0.5 : Height*0.5; double distance = difference.Length() - heightOffset; difference.Normalize(); double altitude = distance - body.SurfaceRadius; // The spacecraft is in the bodies atmopshere if (altitude < body.AtmosphereHeight) { var surfaceNormal = new DVector2(-difference.Y, difference.X); double altitudeFromCenter = altitude + body.SurfaceRadius; // Distance of circumference at this altitude ( c= 2r * pi ) double pathCirumference = 2 * Math.PI * altitudeFromCenter; double rotationalSpeed = pathCirumference / body.RotationPeriod; // Rough metric for staying on ground from frame to frame if (altitude <= 0.0001) { _onGroundIterations = Math.Min(_onGroundIterations + 1, 10); } else { _onGroundIterations = Math.Max(_onGroundIterations - 1, 0); } // Simple collision detection if (_onGroundIterations > 5) { OnGround = true; var normal = new DVector2(-difference.X, -difference.Y); Position = body.Position + normal * (body.SurfaceRadius + heightOffset); Velocity = (body.Velocity + surfaceNormal*rotationalSpeed); Pitch = normal.Angle(); AccelerationN.X = -AccelerationG.X; AccelerationN.Y = -AccelerationG.Y; } else { OnGround = false; } double atmosphericDensity = body.GetAtmosphericDensity(altitude); DVector2 relativeVelocity = (body.Velocity + surfaceNormal * rotationalSpeed) - Velocity; double velocityMagnitude = relativeVelocity.LengthSquared(); if (velocityMagnitude > 0) { double speed = relativeVelocity.Length(); // Heating HeatingRate = 1.83e-4 * Math.Pow(speed, 3) * Math.Sqrt(atmosphericDensity / (Width * 0.5)); relativeVelocity.Normalize(); double formDragCoefficient = TotalFormDragCoefficient(); double skinFrictionCoefficient = TotalSkinFrictionCoefficient(); double liftCoefficient = TotalLiftCoefficient(); double formDragTerm = formDragCoefficient * TotalFormDragArea(); double skinFrictionTerm = skinFrictionCoefficient * TotalSkinFrictionArea(); double dragTerm = formDragTerm; if (!double.IsNaN(skinFrictionTerm)) dragTerm += skinFrictionTerm; double liftTerm = liftCoefficient * TotalLiftArea() * Math.Cos(Roll); double turnTerm = liftCoefficient * TotalLiftArea() * Math.Sin(Roll); // Form Drag ( Fd = 0.5pv^2dA ) // Skin friction ( Fs = 0.5CfpV^2S ) DVector2 drag = relativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * dragTerm); DVector2 lift = relativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * liftTerm); DVector2 turn = relativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * turnTerm); AccelerationD = drag / Mass; DVector2 accelerationLift = lift / Mass; DVector2 accelerationTurn = turn / Mass; double alpha = GetAlpha(); double halfPi = Math.PI / 2; bool isRetrograde = alpha > halfPi || alpha < -halfPi; if (isRetrograde) { AccelerationL.X -= accelerationLift.Y; AccelerationL.Y += accelerationLift.X; } else { AccelerationL.X += accelerationLift.Y; AccelerationL.Y -= accelerationLift.X; } if (DateTime.Now - timestamp > TimeSpan.FromSeconds(1)) { string filename = MissionName + ".csv"; if (!File.Exists(filename)) { File.AppendAllText(filename, "Altitude, Ma, Acceleration, alpha, roll, HeatingRate, dragTerm, liftTerm, turnTerm\r\n"); } timestamp = DateTime.Now; string contents = string.Format("{0:N3}, {1:N3}, {2:N3}, {3:N3}, {4:N3}, {5:N3}, {6:N3}, {7:N3}, {8:N3}\r\n", altitude / 1000, MachNumber * 10, GetRelativeAcceleration().Length() * 10, alpha * MathHelper.RadiansToDegrees, Roll * MathHelper.RadiansToDegrees, HeatingRate / 100000, dragTerm/10, liftTerm/10, turnTerm/10); File.AppendAllText(filename, contents); } } } else { HeatingRate = 0; } }
public ASDS(double surfaceAngle, double height, IMassiveBody parent) : base(surfaceAngle, height, "Textures/asds.png", parent) { }
public void ResolveAtmopsherics(IMassiveBody body) { DVector2 difference = body.Position - Position; double distance = difference.Length() - Height * 0.5; difference.Normalize(); Altitude = distance - body.SurfaceRadius; // The object is in the atmosphere of body B if (Altitude < body.AtmosphereHeight) { var surfaceNormal = new DVector2(-difference.Y, difference.X); double altitudeFromCenter = Altitude + body.SurfaceRadius; // Distance of circumference at this altitude ( c= 2r * pi ) double pathCirumference = 2 * Math.PI * altitudeFromCenter; double rotationalSpeed = pathCirumference / body.RotationPeriod; // Simple collision detection if (Altitude <= 0) { var normal = new DVector2(-difference.X, -difference.Y); Position = body.Position + normal*(body.SurfaceRadius); Pitch = normal.Angle(); AccelerationN.X = -AccelerationG.X; AccelerationN.Y = -AccelerationG.Y; OnGround = true; } else { OnGround = false; } double atmosphericDensity = body.GetAtmosphericDensity(Altitude); RelativeVelocity = (body.Velocity + surfaceNormal * rotationalSpeed) - Velocity; double velocityMagnitude = RelativeVelocity.LengthSquared(); if (velocityMagnitude > 0) { DVector2 normalizedRelativeVelocity = RelativeVelocity.Clone(); normalizedRelativeVelocity.Normalize(); double formDragTerm = FormDragCoefficient * FrontalArea; double skinFrictionTerm = SkinFrictionCoefficient * ExposedSurfaceArea; double dragTerm = formDragTerm + skinFrictionTerm; // Drag ( Fd = 0.5pv^2dA ) DVector2 dragForce = normalizedRelativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * dragTerm); AccelerationD = dragForce / Mass; } } }
public MassiveBodyProxy(DVector2 position, DVector2 velocity, IMassiveBody massiveBody) : base(position, velocity, 0) { _proxy = massiveBody; }
private static List<ISpaceCraft> BuildItsMarsEDL(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory, float offset = 0) { var ship = new ITSShip(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius - 100000), planet.Velocity + new DVector2(-3300, 300), vehicle.PayloadMass, vehicle.PropellantMass); return new List<ISpaceCraft> { ship }; }
public Strongback(double surfaceAngle, double height, IMassiveBody parent) : base(surfaceAngle, height, "Textures/strongback.png", parent) { }
public Strongback(DVector2 relativePosition, IMassiveBody parent) : base(relativePosition, "Textures/strongback.png", parent) { }
public void ResolveAtmopsherics(IMassiveBody body) { // Don't resolve drag for children if (Parent != null) return; DVector2 difference = body.Position - Position; double distance = difference.Length(); difference.Normalize(); double altitude = distance - body.SurfaceRadius; // The spacecraft is in the bodies atmopshere if (altitude < body.AtmosphereHeight) { var surfaceNormal = new DVector2(-difference.Y, difference.X); double altitudeFromCenter = altitude + body.SurfaceRadius; // Distance of circumference at this altitude ( c= 2r * pi ) double pathCirumference = 2 * Math.PI * altitudeFromCenter; double rotationalSpeed = pathCirumference / body.RotationPeriod; // Simple collision detection if (altitude <= 0) { var normal = new DVector2(-difference.X, -difference.Y); Position = body.Position + normal * (body.SurfaceRadius); Velocity = (body.Velocity + surfaceNormal * rotationalSpeed); Rotation = normal.Angle(); AccelerationN.X = -AccelerationG.X; AccelerationN.Y = -AccelerationG.Y; } double atmosphericDensity = body.GetAtmosphericDensity(altitude); DVector2 relativeVelocity = (body.Velocity + surfaceNormal * rotationalSpeed) - Velocity; double velocityMagnitude = relativeVelocity.LengthSquared(); if (velocityMagnitude > 0) { relativeVelocity.Normalize(); double dragTerm = TotalDragCoefficient() * TotalDragArea(); // Drag ( Fd = 0.5pv^2dA ) DVector2 dragForce = relativeVelocity * (0.5 * atmosphericDensity * velocityMagnitude * dragTerm); AccelerationD += dragForce / Mass; } } }
public ITSMount(double surfaceAngle, double height, IMassiveBody parent) : base(surfaceAngle, height, "Textures/itsMount.png", parent) { }
private static List<ISpaceCraft> BuildITSCrew(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory, float offset=0) { var ship = new ITSShip(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), vehicle.PayloadMass); var booster = new ITSBooster(craftDirectory, DVector2.Zero, DVector2.Zero); ship.AddChild(booster); booster.SetParent(ship); return new List<ISpaceCraft> { ship, booster }; }
private static List<ISpaceCraft> BuildRedDragonFH(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory, float offset = 0) { var redDragon = new RedDragon.RedDragon(craftDirectory, planet.Position + new DVector2(offset, -planet.SurfaceRadius), planet.Velocity + new DVector2(-400, 0), vehicle.PayloadMass); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS1 = new FHS1(craftDirectory, DVector2.Zero, DVector2.Zero); var fhS2 = new FHS2(craftDirectory, DVector2.Zero, DVector2.Zero); var fhLeftBooster = new FHBooster(craftDirectory, 1, DVector2.Zero, DVector2.Zero); var fhRightBooster = new FHBooster(craftDirectory, 2, DVector2.Zero, DVector2.Zero); redDragon.AddChild(dragonTrunk); dragonTrunk.SetParent(redDragon); dragonTrunk.AddChild(fhS2); fhS2.SetParent(dragonTrunk); fhS2.AddChild(fhS1); fhS1.SetParent(fhS2); fhS1.AddChild(fhLeftBooster); fhS1.AddChild(fhRightBooster); fhLeftBooster.SetParent(fhS1); fhRightBooster.SetParent(fhS1); return new List<ISpaceCraft> { redDragon, dragonTrunk, fhS2, fhS1, fhLeftBooster, fhRightBooster }; }
private static List<ISpaceCraft> BuildDragonV2Abort(IMassiveBody planet, VehicleConfig vehicle, string craftDirectory) { var dragon = new DragonV2.DragonV2(craftDirectory, planet.Position + new DVector2(0, -planet.SurfaceRadius), planet.Velocity, vehicle.PayloadMass); var dragonTrunk = new DragonV2Trunk(craftDirectory, DVector2.Zero, DVector2.Zero); dragon.AddChild(dragonTrunk); dragonTrunk.SetParent(dragon); return new List<ISpaceCraft> { dragon, dragonTrunk }; }