Kobymaru

[1.5.1, 1.3.1] Trajectories v2.2.1 (2018-04-28) : atmospheric predictions

Recommended Posts

Before posting feature requests or bug reports, please read the FAQ.

FAQ

  • Works with stock aerodynamics and FAR
  • Reportedly works with
    • deadly reentry
    • real solar system
    • Rescaled Kerbin
    • Outer Planets Mod
  • Compatible with Blizzy's toolbar
  • If you see weird spirals or other crazy lines everywhere, double-check you didn't enable "body-fixed mode" by mistake
  • If the predicted trajectory seems inaccurate, check that you set the correct orientation in the Descent profile (or checked Prograde or Retrograde), and that you keep that orientation all the time
  • It's not possible to predict a trajectory for a future stage. We know this is a highly requested feature, but unless we duplicate big parts of the KSP-internal code, we are limited to simulating the current state of the vessel.
  • Parachutes are not simulated (that's usually not a problem if you open it near the ground)

Download

Description

The mod displays trajectory predictions, accounting for atmospheric drag and lift. Works with the stock aerodynamic model, and with Ferram Aerospace Research (FAR).

With this mod, you can

  1. choose precisely the location where you'll crash. The typical precision is about 6km.
  2. Plan Aerobraking maneuvers that can, for example, put you on intersection trajectory with another body (see point 1 about what you can do from there)

Keep in mind that this software comes without warranty of any kind, and in particular that it may or may not help you survive, reach a specific target, or anything at all. But it usually helps :wink:

 

User manual

See your predicted trajectory

  • Open the map view
  • This is it ; trajectory display is enabled by default, you have nothing else to do
  • White is the trajectory in space, red is the trajectory in atmosphere, the red cross is your impact point (that takes the body rotation into account to show the impact point on the terrain, this is useful both for bodies with and without atmosphere)

Disable the trajectory display

  • Click on the Trajectories icon in the stock KSP toolbar (or Blizzy's toolbar if it's installed) to display the main UI
  • Click "Display trajectory" to toggle it on/off
  • Click "complete" to toggle display of the complete trajectory (including parts where it is superimposed with the stock KSP trajectory)

Set a target point (nav ball guidance)

  • Adjust your velocity so that the red cross is located where you want to go
  • Click "Set current impact as target" to enable the green cross
  • Alternatively, there is a button to set the target on the KSC (works on Kerbin only obviously), or you can enter longitude/latitude
  • Go back in flight view, and notice the two new indicators on the nav ball
  • The square indicator shows where you need to point your craft at if you were exactly following the predicted trajectory
  • The circle indicator is a hint about the direction you should go to adjust your actual trajectory to reach the target (this is not necessarily where you need to point, what's important is the direction between the square and the circle, and the distance between them indicates how far you are from the perfect trajectory)

Body-fixed mode

Use this toggle to switch between the regular mode (similar to stock KSP orbits), or body-fixed mode. In body-fixed mode, the trajectory is displayed relatively to the body frame, following the body rotation. This mode makes sense for atmospheric or low terrain fly-by, and also to adjust a geostationary orbit. However, for most high orbits, it will just look funny. This can help you keep occupied for those 2-year-long planetary transfers, but try not to burn up all the fuel to see how it can make funny curved lines.

Manoeuver nodes

You can plan aerobraking or re-entry after manoeuvers, just place your nodes as usual and see the predicted trajectory. Keep in mind that you always place nodes on the stock trajectory, that might be very different from the predicted one, so you may have to place nodes at a point that have an effect somewhere else on the predicted trajectory (especially when planning landing on a body without atmosphere with body-fixed mode). Also, atmospheric prediction can happen only for the body you are currently orbiting, so you can't plan a Kerbin re-entry while you're still arround the Mun.

Support and Bugs

If you have questions and feedback regarding a current release, feel free to post in this thread.

Please post bug reports on the GitHub bug tracker. If you don't know how, don't want to learn or are unsure it's a bug, you can ask in this thread.

Contributions

This mod is a community project! It was originally written by @Youen and is currently maintained by @PiezPiedPy
The following people have already contributed to this project (in approximative order of commits):

  • Youen (Github neuoy)
  • PiezPiedPy
  • Kobymaru (Github fat-lobyte)
  • atomicfury (Github sawyerap)
  • And many others.

You want to be part of this list? Contributions are very welcome! Read our Introduction for Contributors, fork the Repository on Github and have a go at the code!
When you feel that your changes are mature enough to be included, send me a pull request! Also, please let us know what you are working on in the development thread.

It's always best if you work on your "pet problem" - a bug that needs to be fixed or that you personally want to see implemented. Or you could just grab an issue from our Issue Tracker!

For discussions about Mod internals and Development, please head over to the development thread.

Change log

The changelog started with release v1.6.7. For the changes in versions older than that, please visit the GitHub releases page.

Spoiler

# v2.2.1 for KSP 1.4.3 and KSP 1.3.1
 - 2018-04-28

### Changes since the last release

 * GUI window would reset to screen center on a game restart if it was hidden in the previous game, now fixed.
 * In-Flight trajectory ground target marker would sometimes appear on screen when behind the camera view, now fixed.

 

# v2.2.0 for KSP 1.4.2
 - 2018-04-02

### Changes since the last release
 * Japanese translation updated. Many thanks to UresiiZo for correcting the mistakes.
 * Italian translation updated. All thanks go to Brusura for the translation fix.
 * German translation updated. Lots of thanks to nistei for updating the mistakes.
 * French translation updated. Huge thanks to d-faure for correcting the syntax.
 * GUI settings are now persistent again.
 * Black toolbar icons when Texture Settings not set to Full-Res bug fixed.
 * In-Flight trajectory ground target marker covering entire screen when camera is close bug fixed.

### For Developers
 * New API functions added `GetTimeTillImpact`, two for the Descent Profile `ProgradeEntry RetrogradeEntry`
   and some for the Trajectories version. `GetVersion GetVersionMajor GetVersionMinor GetVersionPatch`
  ## v2.1.0 for KSP 1.4.1
 - 2018-03-21

### Changes since the last release

 * Trajectories license has been changed from MIT to GPL-3.0-or-later. Please see the LICENSE.md file for more details.
 * Russian translation updated. Many thanks to Fat-Zer for correcting the mistakes.
 * Chinese translation updated. Many thanks to studentmain for rewriting the translation.
 * Added Japanese, German, French, Italian and Portuguese languages. If you know any of these languages,
   please consider helping out with translations.
 * A big cheers and a beer to Jebs_SY for his help in fixing a rendering issue on the MapView and the Target Waypoint bug.
 * ModuleManager updated to v3.0.6
 
### Known Issues

 * Sometimes In-Flight trajectory ground target marker can cover entire screen when camera is close.

## v2.0.0 for KSP 1.3.1
 - 2018-02-15
 
### Changes since the last release
 * Completely new and overhauled user interface, based on the DialogGUI system.
   Includes (automated) localizations for Russian, Spanish and Chinese (traditional). If you know any of these languages, please consider helping out with translations. Send all Thanks and Kudos to PiezPiedPy for this amazing contribution!
 * In-Flight trajectory vector line and ground marker persistence bug fixed.
 * ModuleManager updated to v3.0.3
 * When combined with FAR, aerodynamic forces calculated on a packed vessel would lead to NRE's.
   Vessels are now no longer calculated when a vessel is in a packed state. Thanks go to Alex Wang for this bug fix.
 * Higher precision and better performance through more advanced numeric techniques using an RK4 integration method.
   Try disabling the Cache for more precise predictions, predictions that should not kill your FPS anymore.
   Courtesy of fat-lobyte aka Kobymaru.
 
### For Developers
 * API changes to help catch NRE's from improper calling of the API methods.
 * New API method `HasTarget()` checks if a target has been set.
 * Flickering entries bug in the Profiler is fixed :)
 * Added Reset averages & Show zero calls buttons, a Framerate limiter, avg calls and frame counter to the Profiler.
 
### Known Issues
 * Sometimes In-Flight trajectory ground target marker can cover entire screen when camera is close.

 

## v1.7.1 for KSP 1.3.1
 - 2017-10-13

### Changes since the last release

 * In-Flight trajectory overlay now uses GLUtils from MechJeb2 for rendering.
 * Fixed In-Flight trajectory for non-atmospheric bodies

### For Developers

 * Added a Jupyter notebook for descent force analysis.
 * Added the Bug Reporting section to CONTRIBUTING.md file.

## v1.7.0 for KSP 1.3.0
 - 2017-07-08

### Changes since the last release

 * Improved precision by accounting for reynolds number in drag. Fixes Issue #84.
 * Fix crash when turning on In-Flight trajectory display while in Map view. Fixes Issue #102. Thanks to PiezPiedPy!
 * Prevent click-through in certain situations. Thanks to PiezPiedPy!
 * Numbers in the user interface don't change as quickly anymore, allowing for better readability
 * Deviation readout now switches from E to W and from N to S instead of just showing negative numbers

### For Developers

 * Added a bridge to the newly created [Telemetry](https://github.com/fat-lobyte/KSPTelemetry) module,
   allowing for nice [graphs](https://user-images.githubusercontent.com/173609/27686194-febdbca6-5cd1-11e7-877d-1ab6e5069fb6.png)
   and better debugging of prediction precision.
 * Updated Profiler UI to new Canvas system. Thanks to PiezPiedPy!
 * Added documentation for contributers in CONTRIBUTING.md file with style guidelines,
   help for building, debugging and much more.

### Known Issues

  * In-Flight trajectory for non-atmospheric trajectories is incorrect and jumpy


## v1.6.8 for KSP 1.3.0

- 2017-06-13

### Changes since the last release
  * Fixed in-flight targeting cross remaining in scence even after trajectory display was disabled.
  * Added toggle for in-flight trajectory display. Fixes Issue #96.

### Known Issues
  * Trajectory prediction is still fundamentally incorrect. See Issue #84.
  * In-Flight trajectory for non-atmospheric trajectories is jerky and jumpy.


## v1.6.7 for KSP 1.3.0

- 2017-06-09

### Changes since the last release
  * This release is brought to you by fat-lobyte (aka Kobymaru on the Forums)
  * Update ToolbarWrapper for blizzy78's Toolbar. Fixes Issue #78.
  * Enable Trajectories window in flight scence.
  * Implement in-flight trajectory line display. Please test and give feedback!
  * Fix Parenthesis silliness in .version file to make it valid JSON again. Thanks, ggpeters!
  * Update Module Manager to v2.8.0. Thanks to PiezPiedPy!
  * Disable Click-through. Thanks to PiezPiedPy!

### Known Issues
  * Trajectory prediction is still fundamentally incorrect. See Issue #84.
  * In-Flight trajectory for non-atmospheric trajectories is jerky and jumpy.
  * In-Flight trajectory leaves targeting cross in the scene, even when disabled.

### For Developers
  * KSP directory path is not hardcoded anymore. You can set up an environment variable in your Operating System named KSPDIR that points to the KSP installation directory.
  * Revamped build scripts for Visual Studio. Thanks to PiezPiedPy!
  * Added simple profiler class. Thanks to PiezPiedPy!
 

License

This mod is under GPLv3 license, feel free to look at the source code: https://github.com/neuoy/KSPTrajectories

 

Edited by Kobymaru

Share this post


Link to post
Share on other sites

Thanks for taking over @Kobymaru, and thanks and good luck to all contributors currently working on the mod.

Share this post


Link to post
Share on other sites

@Kobymaru @Youen Hey, I'm having this issue with Trajectories in 1.2.2. I'm running the latest Trajectories version (updated through CKAN). The problem is that the trajectory prediction line is invisible unless time warp is turned on. There's just nothing, but if I turn on time warp (doesn't matter what magnitude), the lines re-appear. If this is not a known bug, let me know what information is needed to determine the cause, and I'll gladly provide it. For now, here's the log.

Share this post


Link to post
Share on other sites
10 hours ago, aluc24 said:

@Kobymaru @Youen Hey, I'm having this issue with Trajectories in 1.2.2. I'm running the latest Trajectories version (updated through CKAN). The problem is that the trajectory prediction line is invisible unless time warp is turned on. There's just nothing, but if I turn on time warp (doesn't matter what magnitude), the lines re-appear. If this is not a known bug, let me know what information is needed to determine the cause, and I'll gladly provide it. For now, here's the log.

I have to admit that I haven't seen this kind of issue yet. However, you are running Trajecotires 1.6.6 with KSP 1.2.2, when the most recent versions are Trajectories 1.6.8 and KSP 1.3.0.

It doesn't make much sense to debug old versions, I'm afraid, so please try to reproduce this when you update and then report the issue again.

Share this post


Link to post
Share on other sites
2 hours ago, Kobymaru said:

I have to admit that I haven't seen this kind of issue yet. However, you are running Trajecotires 1.6.6 with KSP 1.2.2, when the most recent versions are Trajectories 1.6.8 and KSP 1.3.0.

It doesn't make much sense to debug old versions, I'm afraid, so please try to reproduce this when you update and then report the issue again.

Okay, I will... But it might be a long time before that happens. Most of mods I'm using aren't updated to 1.3 yet.

Share this post


Link to post
Share on other sites

I'm about 75% sure this crash is caused by Trajectories.  It happened twice while landing at the Mun in Body Fixed mode.  I used the in-game UI to disable trajectories outright and landed just fine.  Time warping did occur during at least one of the crashes.  I suppose it could just be a big coincidence as well, I'm uncertain.  I am seeing a lot of null references from CC as well.

https://www.dropbox.com/s/7riphki2eqozgu6/output_log.txt?dl=0

Edited by Alshain

Share this post


Link to post
Share on other sites
17 minutes ago, Alshain said:

I'm about 75% sure this crash is caused by Trajectories.  It happened twice while landing at the Mun in Body Fixed mode.  I used the in-game UI to disable trajectories outright and landed just fine.  Time warping did occur during at least one of the crashes.  I suppose it could just be a big coincidence as well, I'm uncertain.  I am seeing a lot of null references from CC as well.

Can you make a quicksave and remove as many mods as possible, with the crash still occuring? Because you have got quite a mod list there and I wouldn't even know how to cause a game crash on purpose in C#.

Out of curiosity, how can you be "75% sure this crash is caused by Trajectories" when your mod list looks like this:

Mod DLLs found:
Stock assembly: Assembly-CSharp v0.0.0.0
ModuleManager.2.8.0 v2.8.0.0
000_AT_Utils v1.4.2.0
MiniAVC v1.0.3.2
USITools v1.0.0.0
ActionGroupManager v2.1.0.0
MiniAVC v1.0.3.2
AdvancedTweakablesButton v1.0.3.0
BULB v1.3.4.0
Astrogator v0.7.4.0
CITUtil v1.4.0.0 / v1.0.0.0
BAM v1.3.0.0 / v1.1.0.0
CollisionFX v4.0.0.0
CCK v2.0.1.0 / v2.0.1.0 for KSP 1.3
ContractConfigurator v1.0.0.0 / v1.23.1
RemoteTech v1.8.0.0 / v1.8.7
CC_RemoteTech v1.0.0.0 / v1.23.1
CustomBarnKit v1.1.12.0
DistantObject v1.9.0.10326
Atmosphere v1.2.2.1
CelestialShadows v1.2.2.1
CityLights v1.2.2.1
EVEManager v1.2.2.1
PartFX v1.2.2.1
PQSManager v1.2.2.1
ShaderLoader v1.2.2.1
Terrain v1.2.2.1
TextureConfig v1.2.2.1
Utils v1.2.2.1
_BuildManager v1.2.2.1
Launchpad v5.8.0.0 / v5.8.0
Firespitter v7.3.6354.39102
MiniAVC v1.0.3.2
Fusebox v0.1.11.0
GroundConstruction v1.1.2.1
OneTimeResourceConverter v1.0.0.0
KAS v0.6.3.0 / v0.6.3 for KSP 1.3
MiniAVC v1.0.3.1
KerbalEngineer v1.1.3.0
KerbalEngineer.Unity v1.0.0.0
MiniAVC v1.0.3.2
KIS v1.5.0.0 / v1.5.0 for KSP 1.3
KSPDev_Utils.0.23.0 v0.23.0.0 / v0.23.0 for KSP v1.2
MiniAVC v1.0.3.0
KSP-AVC v1.1.6.2
KSPWheel v0.0.0.0
BetterManeuvering v1.0.3.0 / v3.0
BetterManeuvering.Unity v1.0.3.0
MiniAVC v1.0.3.2
NavBallDockingAlignmentIndicatorCE v1.0.2.0 / v1.0.0.0
NavBallTextureChanger v1.0.0.0
DockingPortAlignmentIndicator v1.0.0.0
DPAI_RPM v1.0.0.0
MiniAVC v1.0.3.2
ModuleDockingNodeNamed v1.0.0.0
PlanetShine v1.0.6121.34655
ProceduralFairings v0.0.4.0
RCSBuildAid v0.9.1.34418
ReentryParticleEffect v1.2.0.0
SCANsat v1.7.8.0 / vv17.8
SCANsat.Unity v1.7.8.0
SmokeScreen v2.7.2.0
Stock assembly: KSPSteamCtrlr v0.0.1.35
Stock assembly: Steamworks.NET v9.0.0.0 / v9.0.0
MiniAVC v1.0.3.2
Strategia v1.0.0.0 / v1.6.0
TextureReplacer v2.6.0.0
Trajectories v1.6.8.0
KerbalAlarmClock v3.8.5.0
TransferWindowPlanner v1.6.2.0
Konstruction v0.0.0.0
USILifeSupport v1.0.0.0
KolonyTools v1.0.0.0
WaypointManager v1.0.0.0 / v2.6.2
MiniAVC v1.0.3.0
[x] Science! v5.7.6355.41035

 

Edited by Kobymaru

Share this post


Link to post
Share on other sites
2 minutes ago, Kobymaru said:

Can you make a quicksave and remove as many mods as possible, with the crash still occuring? Because you have got quite a mod list there and I wouldn't even know how to cause a game crash in C#.

Well, I can't remove all of RemoteTech because the probe has an antenna on it.  I could probably remove the DLL, I'll have to copy the whole save game to do it.  Fortunately I had 3 of those probes in orbit ready to land.

Share this post


Link to post
Share on other sites
Just now, Alshain said:

Well, I can't remove all of RemoteTech because the probe has an antenna on it.  I could probably remove the DLL, I'll have to copy the whole save game to do it. 

Of course, don't do it in your main save! Back up your main save and do a quicksave.

Yes, you can remove all Mods except for RemoteTech, but you can remove the DLL there. There's also KSPPartRemover, but first focus finding the conditions where the crash occurs.

Share this post


Link to post
Share on other sites
30 minutes ago, Kobymaru said:

Of course, don't do it in your main save! Back up your main save and do a quicksave.

Yes, you can remove all Mods except for RemoteTech, but you can remove the DLL there. There's also KSPPartRemover, but first focus finding the conditions where the crash occurs.

Well, I tried with Trajectories by itself and no crash.  I went back to the other games with trajectories turned on in the same way and landed my other two probes without a crash.  It's strange, it crashed twice in a row but when I want it to, nothing.

So... tests are inconclusive.  I guess we will have to see what Nightingale says about the nullrefs but I don't know what else to do here for right now.

Share this post


Link to post
Share on other sites

Checking "in-flight" button in map view causes immediate crash (even though vessel is in orbit, so nothing much to calculate). Any ideas where to dig?

Edited by Mystique

Share this post


Link to post
Share on other sites
12 hours ago, Mystique said:

Checking "in-flight" button in map view causes immediate crash (even though vessel is in orbit, so nothing much to calculate). Any ideas where to dig?

Which version of Trajectories, which version of KSP and which mods are involved?

Can you reproduce it consistently or does it occur sporadically?

Share this post


Link to post
Share on other sites
1 hour ago, Kobymaru said:

Which version of Trajectories, which version of KSP and which mods are involved?

Can you reproduce it consistently or does it occur sporadically?

Trajectories v1.6.8

KSP: 1.3 (Win64) 

Other mods:

Spoiler

1.3 TextureReplacer x.x.x/beta
RasterPropMonitor.0.29.0.beta2
DroptankWrapper
000_AT_Utils - 1.4.4
Toolbar - 1.7.14
USI Tools - 0.9.2
AutoAsparagus - 2.2.6
B9 Part Switch - 1.8.1
Chatterer - 0.9.93.1804
Community Category Kit - 2.0.1
Community Resource Pack - 0.7.1
DMagic Orbital Science - 1.3.0.10
EditorExtensionsRedux - 3.3.13.1
Firespitter - 7.6
RasterPropMonitor - 0.29
Kerbal Attachment System - 0.6.3
Kerbal Engineer Redux - 1.1.3
Kerbal Inventory System - 1.5
Kopernicus - 1.3.0.4
KSP-AVC Plugin - 1.1.6.2
ModularFlightIntegrator - 1.2.4
Docking Port Alignment Indicator - 6.7
NearFutureConstruction - 0.8.2
NearFutureElectrical - 0.9.1
NearFuturePropulsion - 0.9.1
NearFutureSolar - 0.8.3
Procedural Parts - 1.2.12
RealChute - 1.4.4
ReentryParticleEffect - 1.2.0.1
ShipManifest - 5.1.4.3
StageRecovery - 1.7.2
ThrottleControlledAvionics - 3.4.2
Kerbal Alarm Clock - 3.8.5
TweakScale - 2.3.6
USI Alcubierre Drive - 0.6.1
Universal Storage - 1.3.0.1

Reproduction: create any new game, launch anything, go to map, check show trajectory, then check in-flight, crash.

Logs, if it helps:

on Dropbox

Edited by Mystique

Share this post


Link to post
Share on other sites

 

40 minutes ago, Mystique said:

Reproduction: create any new game, launch anything, go to map, check show trajectory, then check in-flight, crash.

Thank you for bringing this to my attention, I will take a look at it.

Share this post


Link to post
Share on other sites

Edit:

I just see that on the FAR dev repo it says:

Quote

FerramAerospaceResearch   -   Tryfix Trajectories creating phantom aerodynamic force arrows   -   3 days ago

I use this version, but the arrow is still there.

Is this from Trajectories?
BZMTNq5.png

The blueish arrow. It disappears shortly after launch but comes back later for short periods of time then and when...

Later:
OdsfuBh.png

dLSgN9n.png

Edited by Gordon Dry

Share this post


Link to post
Share on other sites

@Gordon Dry Try disabling In-flight trajectories. I've just noticed flames coming off the end of line that gets drawn. :D

Edited by PiezPiedPy

Share this post


Link to post
Share on other sites

I don't have in-flight trajectories enabled.

I never had, because of

It also crashes for me when I enable it.

Share this post


Link to post
Share on other sites
16 hours ago, Gordon Dry said:

I use this version, but the arrow is still there.

Is this from Trajectories?

I have not ever seen this in my life, but it looks kinda cool! Where can I get one of these? :wink:

 

10 hours ago, Gordon Dry said:

It also crashes for me when I enable it.

This will be fixed in the next release.

Share this post


Link to post
Share on other sites

First off, I want to thank for an awesome mod, which accompanies me in all my KSP games since the moment I found it.

Now, I am myself really interested in simulating and predicting trajectories, but unfortunately I have no idea of C#, so I cannot really understand what the code does. Could you ((I mean the contributors, but anyone who can help is welcome to do so) maybe either explain or even just give me the sources of the maths and algorithms you use in this mod? I am currently working on an ascent trajectory tool and on a low TWR vacuum trajectory tool, both in JavaScript. They could play well with your mod if someone ported them to a KSP mod when I am done. It's the ascent one that needs the aerodynamics maths, but I am also interested in simply your approach to calculating the trajectory, which could be useful to both of them.

Share this post


Link to post
Share on other sites
4 hours ago, APlayer said:

First off, I want to thank for an awesome mod, which accompanies me in all my KSP games since the moment I found it.

Don't forget to give Kudos to @Youen who created this awesome mod, I'm just the maintainer :wink:

 

4 hours ago, APlayer said:

Now, I am myself really interested in simulating and predicting trajectories, but unfortunately I have no idea of C#, so I cannot really understand what the code does.

Good point, I could probably write down what the code does.

 

4 hours ago, APlayer said:

Could you ((I mean the contributors, but anyone who can help is welcome to do so) maybe either explain or even just give me the sources of the maths and algorithms you use in this mod?

At its core, the math and the algorithms are actually kind of simple (it's just packed in a confusing way that's necessary for efficiency)

We use a mix of calls to original and duplicated KSP functions to figure out parameters for atmospheric density, temperature, reynolds number, mach, .... from altitude and velocity. We feed these values into the original KSP DragCube functions to calculate the forces on the ship for a given point in the future.

Then we simply aggregate these forces and calculate velocity and position. The "aggregation" part is important, because if you do it wrong (like simply adding up the velocity/position changes over time), you will end up with big errors. Currently this is done by "verlet integration", but I was hoping to implement Runge-Kutta 4 in the medium future.

If you want, I can look up the places of these calculations in the C# code.

4 hours ago, APlayer said:

I am currently working on an ascent trajectory tool and on a low TWR vacuum trajectory tool, both in JavaScript. They could play well with your mod if someone ported them to a KSP mod when I am done. It's the ascent one that needs the aerodynamics maths, but I am also interested in simply your approach to calculating the trajectory, which could be useful to both of them.

Sounds interesting, but the most difficult case here is to calculate the drag from aerodynamic parameters. KSP does all kinds of funny things with the "DragCube" system like occlusion and bonuses for pointiness and maluses for open stack nodes. Trajectories can get away by simply calling the functions inside KSP with the right parameters and interpreting the results.

I think it might be very hard to replicate all these systems in JavaScript, especially since you would have to dig in KSP code (which technically isn't even allowed).

If you have more questions, don't hesitate to ask!

Share this post


Link to post
Share on other sites
16 hours ago, Kobymaru said:

We use a mix of calls to original and duplicated KSP functions to figure out parameters for atmospheric density, temperature, reynolds number, mach, .... from altitude and velocity. We feed these values into the original KSP DragCube functions to calculate the forces on the ship for a given point in the future.

I see - so you actually don't do any real aerodynamics maths, but rather use built in KSP functionality. This of course makes sense, but at the same time means I cannot reuse the maths. In this case, I will probably just approximate the drag force with a guess for the drag coefficient with the standard drag equation, which could be based off a basic description of the ship and later refined by the user, who may try the trajectory and check the results. And since my programs will largely simulate prograde burns, I will not really need to account for lift or other aerodynamic forces.

As for the implementation itself, I was helped a lot on the #kspacademia channel, and they indeed recommend using RK4. I may try to help you implement that, but only on the maths and "translating it to a machine" parts, because, as I said, I know no C#, and have only marginal knowledge of OOP. You are also welcome to view my low TWR tool's JS code on GitHub which tries to implement RK4, but do note that it currently fails to calculate anything and finishes with all variables set to NaN.

Thanks for the offered help! :-)

Share this post


Link to post
Share on other sites
2 minutes ago, APlayer said:

so you actually don't do any real aerodynamics maths, but rather use built in KSP functionality.

That is mostly correct. We try to re-use the KSP functions as much as possible.

 

2 minutes ago, APlayer said:

And since my programs will largely simulate prograde burns, I will not really need to account for lift or other aerodynamic forces.

Just so you know, the distinction between "drag" and "lift" is a bit silly, because as @Boris-Barboris likes to point out, drag and lift are just components of the same vector. That means you'll run into situations where ignoring "lift" will produce inaccurate results even when you're not classically "flying".

 

2 minutes ago, APlayer said:

As for the implementation itself, I was helped a lot on the #kspacademia channel, and they indeed recommend using RK4. I may try to help you implement that, but only on the maths and "translating it to a machine" parts, because, as I said, I know no C#, and have only marginal knowledge of OOP. 

Thanks for the tips! I think implementing RK4 is not that hard (I believe I did that in C++ once for a class), but integrating it (no pun intended :wink: ) into the mod is the difficult part.

Share this post


Link to post
Share on other sites
20 hours ago, Kobymaru said:

Just so you know, the distinction between "drag" and "lift" is a bit silly, because as @Boris-Barboris likes to point out, drag and lift are just components of the same vector. That means you'll run into situations where ignoring "lift" will produce inaccurate results even when you're not classically "flying".

 

The problem here is, the lift calculation requires much more precise knowledge of the vessel shape while being a comparably small effect, and I don't think implementing that outside of KSP itself would be feasible and worth the trouble. What I could possibly do is create this tool in kOS rather than JavaScript, which could account for lift and be precise with drag, though. On second thought, this seems to be the only feasible way to do it, actually.

20 hours ago, Kobymaru said:

Thanks for the tips! I think implementing RK4 is not that hard (I believe I did that in C++ once for a class), but integrating it (no pun intended :wink: ) into the mod is the difficult part.

I am sorry, but I don't think I can help with that. I will be glad to help if there is anything I can do, though! :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now