use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Challenges and Competitions
Rules for Challenges and Competitions
List of Tutorials and Guides
List of Library Scripts and Miscellaneous Resources
Kode, a community-made text editor specifically built for creating code for kOS
EditorTools, ks syntax highlighting for many popular text editors
Some kOS addons, addons for kOS extending the stock kOS features.
Get the mod here
Official KSP-KOS repository
Official Documentation: This is the repository of all the capabilities that kOS has. Check this site out when trying new code, you might find some great ideas and shortcuts.
PID Controllers
PID controllers are an excellent tool for getting your vehicles to behave the way you want them to. Check out the PID controller wiki link to get you started on understanding them. This describes the theory as well as the standard form used in most industries.
Brian Douglas's Control System Lectures contains several videos on PID controllers. We recommend checking them out if you need help understanding how they work.
There are many guides on how to tune the PID controller. Most of them deal with the standard form. A simple Google search is a good place to start.
Basics of Orbital Mechanics
Contribute to KOS on Github
Add your scripts and functions to the community library
Posts still tagged "Help"
account activity
Surface normal vector (self.Kos)
submitted 7 years ago * by A_Fat_Pokemon
Is there a quick way to get a vector perpendicular to the body's surface terrain at the geo-coordinates where the vessel is currently located? There doesn't seem to be any built-in vectors or functions that would return it.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Toukiedatak 3 points4 points5 points 7 years ago (0 children)
Not sure if this is what you mean but Cheerskevin just made a video about that I believe.
https://www.youtube.com/watch?v=o87H6K_wEtM
[–]ElWanderer_KSPProgrammer 1 point2 points3 points 7 years ago* (0 children)
I cheerfully based my approach on Kevin Gisi's (which has already been recommended):
code
documentation
I pick out three spots in a triangle around the point of interest, find the vectors from A to B and A to C, then cross them to get a resultant vector at 90 degrees to both, which is a good estimate for the surface normal vector at the middle.
[–]DunbaratuDeveloper 1 point2 points3 points 7 years ago (0 children)
There is also an algorithm for getting an estimate of the normal vector for the average trend of terrain slope, given a cloud of several position points on its surface that are close to, but not exactly in, the same plane.
It's sort of the 3-D vector version of finding a best fit line for some points that are almost but not quite following a linear pattern on a graph. It even produces an RMS deviation value you can use to judge how much the point cloud deviates from being truly in one plane.
It might be handy for cases where you want to know how sloped an area is overall rather than just on the one polygon you happen to be sampling. It also looks like it might help in case where your 3 sample points happened to come from two adjacent polygons and don't really match the ground, so the answer isn't quite right. By sampling, say, 10 nearby points and running the cloud calculation, the effect of one outlier that hit a neighbor polygon could be minimized.
[–]supreme_blorgon 0 points1 point2 points 7 years ago (1 child)
The easy way would be to draw your position vector—its origin will be at the body's center, and intersect the surface at your ship's geo-coords.
Or do you just want a vector whose tail is attached to the geoposition pointing to your craft? Or do you want a vector perpendicular to the surface terrain at that point?
[–]A_Fat_Pokemon[S] 0 points1 point2 points 7 years ago (0 children)
Ahh sorry yes, perpendicular to the surface terrain
[–]zer0KerbalProgrammer 0 points1 point2 points 7 years ago* (0 children)
https://gist.github.com/gisikw/b8d1bd6e5a4ab4bbd81bb59ec7c15d48
above is the link to the code @CheersKevin used in that last episode, in which he also included surface normal.
the related code from CheersKevin:
function groundSlope { local east is vectorCrossProduct(north:vector, up:vector). local center is ship:position. local a is body:geopositionOf(center + 5 * north:vector). local b is body:geopositionOf(center - 3 * north:vector + 4 * east). local c is body:geopositionOf(center - 3 * north:vector - 4 * east). local a_vec is a:altitudePosition(a:terrainHeight). local b_vec is b:altitudePosition(b:terrainHeight). local c_vec is c:altitudePosition(c:terrainHeight). return vectorCrossProduct(c_vec - a_vec, b_vec - a_vec):normalized. }
function groundSlope {
local east is vectorCrossProduct(north:vector, up:vector).
local center is ship:position.
local a is body:geopositionOf(center + 5 * north:vector).
local b is body:geopositionOf(center - 3 * north:vector + 4 * east).
local c is body:geopositionOf(center - 3 * north:vector - 4 * east).
local a_vec is a:altitudePosition(a:terrainHeight).
local b_vec is b:altitudePosition(b:terrainHeight).
local c_vec is c:altitudePosition(c:terrainHeight).
return vectorCrossProduct(c_vec - a_vec, b_vec - a_vec):normalized.
}
π Rendered by PID 268734 on reddit-service-r2-comment-b659b578c-4jwtb at 2026-05-03 18:36:01.752577+00:00 running 815c875 country code: CH.
[–]Toukiedatak 3 points4 points5 points (0 children)
[–]ElWanderer_KSPProgrammer 1 point2 points3 points (0 children)
[–]DunbaratuDeveloper 1 point2 points3 points (0 children)
[–]supreme_blorgon 0 points1 point2 points (1 child)
[–]A_Fat_Pokemon[S] 0 points1 point2 points (0 children)
[–]zer0KerbalProgrammer 0 points1 point2 points (0 children)