captncraig Posted May 27, 2015 Share Posted May 27, 2015 I am wanting to make a more advanced navball that I can run in a browser for my physical console project.I am hoping to modify the navball code from https://github.com/creshal/telemachus-glass-cockpit which is built on data from telemachus.It is able to draw the navball by reading rawPitch, rawHeading and rawRoll from telemachus (calculated with this code: https://github.com/richardbunt/Telemachus/blob/master/Telemachus/src/DataLinkHandlers.cs#L1123)In order to render prograde, retrograde, maneuver, etc.., I need to modify telemachus to give me raw pitch and heading data for those vectors.If I take [COLOR=#333333]Vector3 prograde = this.vessel.GetObtVelocity();[/COLOR] I get a vector in x,y,z space. That is about as far as I have gotten. I need to transform this into pitch and heading values relative to the current body in order to render them on the navball. Can anyone point me in the right direction? Link to comment Share on other sites More sharing options...
Crzyrndm Posted May 27, 2015 Share Posted May 27, 2015 (edited) Calculate prograde pitch by the angle between prograde and surface normal like this (substituting vessel.up (forward in KSP) for the prograde vector). Heading is a bit more complex, but you can also find the calculations required at that link Edited May 27, 2015 by Crzyrndm Link to comment Share on other sites More sharing options...
captncraig Posted May 27, 2015 Author Share Posted May 27, 2015 I think the prograde heading is the same as the surface heading in your linked code, so thanks for that. The pitch is not working for me. I'll keep trying a few things and post my code in a bit. Link to comment Share on other sites More sharing options...
Crzyrndm Posted May 27, 2015 Share Posted May 27, 2015 I think the prograde heading is the same as the surface heading in your linked codeThey are very slightly different (surfVelForward and surfVesForward as the reference vector) Link to comment Share on other sites More sharing options...
captncraig Posted May 28, 2015 Author Share Posted May 28, 2015 Yeah, I'm having a bit of trouble with the pitch:[FONT=Menlo][COLOR=#009695]var [/COLOR][COLOR=#333333]planetUp[/COLOR][COLOR=#333333]=[/COLOR][COLOR=#333333]([/COLOR][COLOR=#333333]thisVessel[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]rootPart[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]transform[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]position[/COLOR][COLOR=#333333]-[/COLOR][COLOR=#333333]thisVessel[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]mainBody[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]position[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]normalized[/COLOR][COLOR=#333333];[/COLOR][COLOR=#009695]var [/COLOR][COLOR=#333333]pitch[/COLOR][COLOR=#333333]=[/COLOR][COLOR=#3364a4]Vector3d[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]Angle[/COLOR][COLOR=#333333]([/COLOR][COLOR=#333333]planetUp[/COLOR][COLOR=#333333],[/COLOR][COLOR=#333333]thisVessel[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]obt_velocity[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]normalized[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333];[/COLOR][COLOR=#009695]return [/COLOR][COLOR=#333333]pitch[/COLOR][COLOR=#333333];[/COLOR][/FONT]I would expect this to stay at or near 0 as I ascend pointing straight up. It starts at around 90 and shrinks gradually to around 11 or so degrees as I climb. This is obviously not correct. Thanks for your help. I got the heading working perfectly. Link to comment Share on other sites More sharing options...
Crzyrndm Posted May 28, 2015 Share Posted May 28, 2015 pitch at launch would be zero relative to surface velocity, not orbital velocity (navball starts in surface mode). It starts at 90 degrees because the rotational velocity of the planet is perpendicular to the up vector, then shrinks as your vertical velocity increases. Link to comment Share on other sites More sharing options...
captncraig Posted May 28, 2015 Author Share Posted May 28, 2015 Ok, that actually makes a lot of sense. I got it pretty good using surface velocity under 36000 and orbit velocity above that. Is there a table somewhere of altitudes for switching surface -> orbit mode for all bodies? Or even better a useful formula?Thanks for all your help! Link to comment Share on other sites More sharing options...
Crzyrndm Posted May 28, 2015 Share Posted May 28, 2015 Go by the display modeFlightUIController.speedDisplayMode Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now