Jump to content

Dunbaratu

Members
  • Posts

    3,857
  • Joined

  • Last visited

Community Answers

  1. Dunbaratu's post in How to determine average equatorial surface elevation on planets/moons? was marked as the answer   
    In kOS, this code would store a list of altitudes around the equator:
    local the_body is Mun. // or set to some other body to measure. local alt_list is list(). local startlong is 0. local stoplong is 360. local steplong is 0.5. // samples 0.5 longitude degreees apart. Set smaller for more fine-grain measure. for long in range(startlong, stoplong, steplong) { // latitude = 0 to hardcode equator, longitude varies through the loop: alt_list:add( the_body:geopositionlatlng(0, long):terrainheight ). } // Now alt_list is a list of terrain heights around the equator. // Do whatever statistical work on that list that you like in the lines below... // for example - to get the mean: local sum is 0. for long in alt_list set sum to sum + long. local mean is sum / alt_list:length. Warning: the above code is not tested.  I typed it in without trying to run it.  It may have errors.
  2. Dunbaratu's post in kOS - 3 simple questions was marked as the answer   
    (1) - The function call : VANG(ship:up:vector, ship:srfprograde:vector) will give you the angle between straight up and your surface-prograde vector.  (I assume you want surface and not orbital here).  So, for example, a pitch of 80 would mean there is 10 degrees angle between up and prograde.  If you do 90 - VANG(ship:up:vector, ship:srfprograde:vector) then you should get the pitch number you are looking for.
    (2) - There is no such thing in kOS.  Instead you can explicitly mention which you are interested in because prograde comes in two varieties - surface and orbital.  You can say srfprograde for surface, or just prograde for orbital.  You can say ship:velocity:surface or ship:velocity:orbit to get velocity vectors in the two frames.  For target-relative there isn't a shortcut, but you can always subtract your target's velocity vector from your velocity vector to get the same thing the navball would have shown you in target mode.
    (3) - Not really.  But if you want this kind of information, look at lib/navball in the community library.  It's possible to get this information with a few lines of kOS script code and this example shows how.
    The documentation describing the functions is here: https://github.com/KSP-KOS/KSLib/blob/master/doc/lib_navball.md
    The actual functions themselves are here: https://github.com/KSP-KOS/KSLib/blob/master/library/lib_navball.ks
×
×
  • Create New...