Arc 2 · Measure it  /  Tutorial 04a  /  rebuilt section

Where the delta-v went

Your rocket burned 2500 m/s of propellant and is going 1700 m/s. Something took 800 m/s. This page finds out what, and it assumes you remember algebra and nothing else. Every tool you need is on this page before you're asked to use it.

Toolbox

Everything you need, up front

Nothing below this point requires you to remember something from school. If a step needs a fact, that fact is in this section. Read it, then use it — that's the whole method.

tool 01
A vector is a list of numbers

In 2D, (3, 4) means "3 across, 4 up". That's it. Its length comes from Pythagoras: √(3²+4²) = 5.

A unit vector is one with length 1. It carries direction and nothing else. We put a hat on it: v̂.

v:MAG // length
v:NORMALIZED // same direction, length 1
tool 02
Adding forces

Forces add component by component. (3,4) + (1,−9) = (4,−5). No trig, no angles.

Newton says the sum of forces equals mass × acceleration. That is the only physics law on this page.

Ftotal = F₁ + F₂ + F₃ = m·a
tool 03
Integrating a rate

If you know a rate and you want the total, you add it up over time. That's all an integral is here.

Losing 3 m/s every second for 10 seconds loses 30 m/s. Written formally: ∫3 dt over 10 s = 30. In code it's total = total + rate*dt.

tool 04
Splitting an integral

If a rate is a sum of parts, the total is the sum of the parts' totals:

∫(A − B − C) dt  =  ∫A dt − ∫B dt − ∫C dt

This single fact is what turns one equation into four labelled buckets. It is the whole trick of this page.

Identities this page depends on — open if you want them stated explicitly

There are three, and you will be told when each is used.

  1. Unit-circle components. A unit vector pointing at angle θ above horizontal has components (cos θ, sin θ). Used in: writing down the vectors. There's a widget for it in the next section.
  2. The dot product picks out "how much of A points along B". Used in: every single step of the derivation. Section after next.
  3. Linearity of the integral — tool 04 above. Used in: splitting the bill.

Not needed: the chain rule (that was Tutorial 02), any angle-addition formula, any co-function identity like cos(90°−θ)=sin θ, or the derivative of anything. If you find yourself reaching for one, you've taken a harder path than the one on this page — back up and use the dot product.

The vectors kOS will actually hand you

You asked how to get useful vectors out of kOS. Here is the complete list you need for this page. Every one is a real 3D vector object, not an angle.

Directions & motion
SHIP:VELOCITY:SURFACEWhich way you're actually going, and how fast, relative to the ground. This is the reference direction for the whole page.
SHIP:FACING:VECTORWhich way the nose points. A unit vector already.
SHIP:UP:VECTORStraight up — directly away from the planet's centre. A unit vector.
SHIP:NORTH:VECTORPoints north along the surface. Only needed if you want a compass heading for your log.
SHIP:BODY:POSITIONVector from your ship to the planet's centre — kOS positions are always relative to the vessel. So -SHIP:BODY:POSITION points up, which is why SHIP:UP:VECTOR exists as a shortcut.
Operations
VDOT(a, b)The dot product. Returns a number. The tool this page is built on.
VANG(a, b)Angle between two vectors, in degrees, always 0–180. Good for logging, rarely what you want for math.
VCRS(a, b)Cross product — returns a vector perpendicular to both. You need it in Arc 5 for orbital planes, not here.
VXCL(k, v)"v with all of its k removed" — flattens v into the plane perpendicular to k. Used for compass headings.
v:MAG / v:NORMALIZEDLength, and the same direction at length 1.
The one that trips everyone SHIP:BODY:POSITION is not the planet's position in space — it's the vector from your ship to the planet's centre. Every kOS position is relative to the CPU vessel. If a formula ever gives you an answer that's wrong by exactly your own position, this is why.
Toolbox

The unit circle, since you asked for it

You said you know to reach for a unit circle but would have to look it up. Don't — here it is, and here is the single sentence it's for.

A unit vector pointing at angle θ above horizontal has components ( cos θ , sin θ ). cos gives you the across-part. sin gives you the up-part. That is the entire content of the unit circle.
Unit circle—
the unit vector cos θ — across sin θ — up
Two values worth burning in. At θ = 0° (flat), cos = 1 and sin = 0 — all across, nothing up. At θ = 90° (straight up), cos = 0 and sin = 1 — all up, nothing across. Every gravity-turn argument in this series is somewhere between those two.
Toolbox

The dot product, which replaces all the trig

This is the tool. If you take one thing from this page, take this one — it is why the derivation needs no identities you'd have to look up.

The dot product of two vectors multiplies them component by component and adds the results:

( a1, a2 ) · ( b1, b2 ) = a1b1 + a2b2

Pure algebra — multiply, multiply, add. But here's what it means, and this is the part that does the work:

If b̂ is a unit vector, then a · b̂ is
how much of a points along b̂. A single number. Positive means "with", negative means "against", zero means "perpendicular — no contribution at all".

That's the projection. It is the answer to "how much of this force is actually speeding me up?", and you get it without ever naming an angle.

Try it — pure arithmetic, 60 seconds

Let v̂ = (0.8, 0.6) — check it: 0.8² + 0.6² = 1, so it really is a unit vector. It's pointing up and to the right.

  1. Gravity is g = (0, −9.81). Compute g · v̂. Is it speeding you up or slowing you down?
  2. Thrust is T = (16, 12). Compute T · v̂. Now compute the length of T. Compare the two numbers — what does the gap tell you?
  3. A force P = (−0.6, 0.8). Compute P · v̂. What does that answer mean physically?
Saved
Check your arithmetic

1. (0)(0.8) + (−9.81)(0.6) = −5.886. Negative, so gravity is slowing you down at 5.886 m/s every second. Note it isn't the full 9.81 — because you're not going straight up, only part of gravity opposes your motion. That number, −5.886, is the gravity loss rate, and you just computed it with two multiplications.

2. T · v̂ = (16)(0.8) + (12)(0.6) = 12.8 + 7.2 = 20.0. The length of T is √(16² + 12²) = √400 = 20.0. They're equal, which means every bit of that thrust is pushing along your direction of travel — the thrust is perfectly aligned. Nothing wasted.

If the projection had come out to 18 instead, you'd know 2 m/s² of your thrust was being spent turning rather than accelerating. That gap is the steering loss, and you now have a way to measure it.

3. (−0.6)(0.8) + (0.8)(0.6) = −0.48 + 0.48 = 0. Zero means P is exactly perpendicular to your motion. It is bending your path without changing your speed at all — it costs you nothing in the delta-v budget. This is the single most important idea on the page: perpendicular forces are free.

Why this is the whole trick

The usual textbook derivation says "resolve along the velocity vector" and then produces F cos α and mg sin γ out of thin air, expecting you to see which angle goes where and to remember that cos(90°−γ) = sin γ.

You don't have to. Write the vectors down, dot each one with v̂, and the cosines and sines appear on their own — as the output of arithmetic you can check, not as an identity you had to recall.

Your turn

Draw the point mass

Before you look at anything below: get a piece of paper. This is the exercise you said you wanted, and it works best if you commit to an answer first.

Draw it

Draw a rocket climbing at an angle — a dot for the vehicle is fine, that's what "point mass" means. Then mark every vector you care about and every angle you'd have to name to describe the situation.

Don't worry about getting them exactly right. The point is to find out which ones you didn't think of.

Two prompts if you're stuck: what is pushing or pulling on this rocket? and what do I need to draw before I can say what "climbing at an angle" even means?

Saved
Now compare — the full picture
local horizon up (away from centre) v — velocity (surface) T — thrust (along the nose) mg — weight (toward centre) D — drag (opposes v) γ α pitch
✓
Velocity vThe direction you're actually moving. Everything else on this page is measured against it. Most people draw the rocket's nose and forget that where you point and where you go are different things.
✓
Thrust TAlong the nose, not along the velocity. Its magnitude in kN, direction from SHIP:FACING:VECTOR.
✓
Weight mgStraight at the planet's centre. Always. It does not care which way you're pointing or moving.
✓
Drag DDirectly opposite your velocity. This is why drag can only ever slow you down, never turn you.
✓
The local horizon and "up"Not forces — but you cannot define "climbing at an angle" without them. If you didn't draw these, you couldn't have labelled γ. Half of getting this right is drawing the reference lines.
✓
γ — flight path angleBetween the horizon and your velocity. How steeply you are actually climbing.
✓
α — angle of attackBetween your velocity and your nose. The gap between where you're going and where you're pointing.
✓
pitch — commanded angleBetween the horizon and your nose. This is what pitchAt() returns. And here's the relationship worth writing on your hand: pitch = γ + α.
✗
Lift / normal aerodynamic forceReal, and perpendicular to the airflow. We're ignoring it: a symmetric rocket at small α makes very little, and what it makes acts perpendicular to v — which you proved in the last section costs zero delta-v. Honest simplification, not an oversight.
✗
"Centrifugal force"If you drew this, erase it. It isn't a force — it's an artifact of choosing a rotating frame. There is nothing pushing you outward. Adding it here would double-count.
The one most people miss. Three separate angles — γ, α, and pitch — where they expected one. Tutorial 02 had you write a pitch program, so it's natural to assume "pitch" describes the flight. It doesn't: pitch is what you command, γ is what you get, and α is the difference. Arc 3 is essentially four tutorials about driving α to zero.
Instrument

Which forces change your speed?

Drag the angles. Watch each force split into the part that changes your speed and the part that changes your direction. The dot product is doing the splitting.

Free-body split—
velocity axis thrust gravity drag
Thrust along v  T·v̂—
Gravity along v  g·v̂—
Drag along v—
Net dv/dt—
Thrust wasted turning—
Gravity loss rate—
Use it to answer these
  1. Set α = 0. Now sweep γ from 0° to 90°. At which climb angle does gravity cost you nothing? At which does it cost the full 9.81 m/s²? Does that match the unit circle?
  2. Set γ = 45°, α = 0, and note "thrust along v". Now set α = 20°. How much thrust did you lose? Now α = 40°. Did the loss double, or more than double?
  3. Find a setting where "net dv/dt" is negative while the engine is at full thrust. What is physically happening to the rocket?
  4. Set γ = 90° (straight up), α = 0. Gravity loss rate reads 9.81 — the maximum possible. Now set γ = 5°. What did the gravity loss rate become? This is the entire argument for the gravity turn, in one slider.
Saved
What you should have seen

1. Gravity costs nothing at γ = 0° — flying flat — and costs the full 9.81 at γ = 90°. That's sin 0° = 0 and sin 90° = 1, exactly the two unit-circle values from earlier. Flying horizontally, gravity is perpendicular to your motion, and perpendicular forces are free.

2. At α = 20° you keep about 94% of your thrust — you lose roughly 0.9 m/s² out of 14.7. At α = 40° you keep about 77%, losing about 3.4 m/s². The loss more than doubled — it nearly quadrupled.

That's because cos α falls off quadratically for small angles: the loss goes roughly as α². Practically: small misalignments are nearly free, large ones are brutal. Being 5° off costs 0.4% of your thrust. Being 30° off costs 13%.

3. Any setting where drag plus the gravity component exceeds the thrust along v. Easiest: γ = 90°, thrust accel below 9.81. The rocket is still climbing — still moving up — but it is slowing down while it does. A TWR below 1 pointed straight up. It's the "hover" case from the budget: burning propellant and going nowhere useful.

4. At γ = 90° the gravity loss rate is 9.81 m/s per second. At γ = 5° it's 0.86 — less than a tenth.

Turn that into propellant. Sixty seconds of vertical climb costs 589 m/s of delta-v you will never get back. Sixty seconds at 5° costs 51 m/s. Same minute, same engine, 538 m/s difference — and on a rocket with 3400 m/s of budget, that is the difference between reaching orbit and not.

That's the whole reason a gravity turn exists. Not elegance — you cannot afford to point up.

Now apply it

Build the equation

Every tool is now on the page. This derivation is four steps and each one is arithmetic you've already practised.

Are we in 2D? Yes, for the derivation. At any instant, your velocity and "up" define a plane, and every force we kept lies in it — so two components is enough. (The code you write at the end works in 3D unchanged, and never picks a coordinate system at all. More on that in the last section.)

Set up axes: x is horizontal (along the ground, in the direction you're heading) and y is up.

Step 1 — write the vectors

Using the unit-circle tool: a unit vector at angle θ above horizontal is (cos θ, sin θ). Write down, in components:

  1. v̂, the unit vector along your velocity. It sits at angle γ above the horizon.
  2. T, the thrust. Its magnitude is F and it sits at angle γ + α above the horizon (remember: pitch = γ + α).
  3. W, the weight. Magnitude mg, pointing straight down.
  4. D, the drag. Magnitude D, pointing exactly opposite v̂. Hint: "opposite" just means multiply by −1.
Saved
Check step 1
v̂ = ( cos γ , sin γ )

T = F ( cos(γ+α) , sin(γ+α) )

W = ( 0 , −mg )

D = −D ( cos γ , sin γ )

Weight has no horizontal part at all — that's what "straight down" means, and it's why its x-component is 0. Drag is just v̂ scaled by −D: same line, opposite way, length D.

Step 2 — project each one onto v̂

Dot each vector with v̂. Multiply component by component, add. You did exactly this arithmetic in the toolbox.

Two of them are easy. For T · v̂ you'll get cos(γ+α)cos γ + sin(γ+α)sin γ — which is ugly, and you are not expected to simplify it with an identity. Instead, look at the picture: T is a vector of length F sitting at angle α away from v̂. Ask what its component along v̂ must be, using the unit circle directly.

Saved
Check step 2

Weight. Straight arithmetic:

W · v̂ = (0)(cos γ) + (−mg)(sin γ) = −mg sin γ

There's the sin γ everyone expects you to pull from memory. You didn't — it fell out of multiplying by zero and adding.

Drag. Even easier, since D is a multiple of v̂ and v̂·v̂ = 1 (it's a unit vector):

D · v̂ = −D (v̂ · v̂) = −D

All of drag opposes you. None of it is wasted sideways, because drag has no sideways.

Thrust. Don't expand the trig. Use the picture: T has length F and sits α away from v̂. Rotate your head so v̂ is the horizontal axis — now T is a vector of length F at angle α above "horizontal", so by the unit circle its component along that axis is F cos α.

T · v̂ = F cos α

(If you did expand it, you'd get cos(γ+α)cos γ + sin(γ+α)sin γ, and the angle-difference identity collapses it to cos((γ+α)−γ) = cos α. Same answer. The point is you never needed to know that identity — turning your head was enough.)

And the piece that doesn't go along v̂ is F sin α — the part bending your path. It never appears in the speed equation, which is exactly why it's free from the delta-v budget's point of view. It costs you elsewhere, in Tutorial 07.

Step 3 — assemble

Newton (tool 02): the sum of the along-v̂ forces equals m times the rate of change of speed. Add your three projections, set them equal to m · dv/dt, then divide everything by m.

One substitution at the end: local gravity g = μ/r², and write the drag term as D/m. Both are numbers you can read from telemetry.

Check step 3
m dvdt = F cosα − mg sinγ − D

Divide by m to get it in accelerations — which is what you can actually measure, and what the delta-v budget is denominated in:

dvdt = Fm cosα − g sinγ − Dm

This is the whole physics of the page. Everything after it is bookkeeping.

Read it in English: your speed changes at a rate given by the thrust you're actually using, minus what gravity takes because you're climbing, minus what the air takes. That sentence is the equation.

It's also the equation the instrument above was computing the entire time — the "net dv/dt" readout is exactly this line.

Now apply it

Turn the rate into a bill

You have a rate of change of speed. You want a total, itemised by cause. Tools 03 and 04 do the rest — no new physics.

Step 4 — integrate, then split
  1. Integrate both sides of the step-3 equation from liftoff to now (tool 03). The left side becomes the total speed you've gained. Use tool 04 to break the right side into three separate integrals.
  2. The first term ∫(F/m)cos α dt is annoying — the cos α is tangled up in it. Pull it apart with a pure algebra trick: cos α = 1 − (1 − cos α). Substitute that in and split again.
  3. You should now have ∫(F/m)dt standing alone. That's the delta-v your tanks gave you — call it Δvideal. Rearrange so it's alone on the left.
  4. Name each of the three remaining terms. What physical thing does each one measure?
Saved
Check step 4

1 — Integrate and split. The left side adds up all your speed changes, which is just the speed you ended up with:

Δvgained = ∫Fmcosα dt − ∫gsinγ dt − ∫Dmdt

2 — The algebra trick. Replace cos α with 1 − (1 − cos α). It's obviously true — the brackets cancel — but it separates "all the thrust" from "the bit you're wasting":

∫Fmcosα dt = ∫Fmdt − ∫Fm(1 − cosα)dt

Check it's sane: if α = 0, cos α = 1, the second integral is zero and you keep all your thrust. If α = 90°, cos α = 0, the second integral cancels the first exactly and you get nothing. Both correct.

3 — Rearrange. Move everything except ∫(F/m)dt to the other side:

Δvideal = Δvgained + Lgrav + Ldrag + Lsteer

4 — The names.

Δvideal
∫ (F/m) dtEverything the tanks gave you. This is what Tsiolkovsky in Tutorial 03 predicted. It's the total on the bill.
Δvgained
your actual speedWhat you have to show for it. The only line item that isn't a loss.
Lgrav
∫ g sin γ dtWhat gravity took because you were climbing. Zero if you fly flat, maximum if you fly straight up. The slider proved it.
Ldrag
∫ (D/m) dtWhat the air took. Small above 20 km, and the only term you cannot measure directly.
Lsteer
∫ (F/m)(1 − cos α) dtThrust you spent pointing rather than accelerating. Never negative — you cannot gain speed by aiming away from where you're going.

Everything the tanks gave you is either speed you still have, or one of exactly three named ways you threw it away. Nothing is unaccounted for. That closure is what makes the number trustworthy — and it's what you'll check in code.

The sanity check that costs nothing

A rocket hovering at exactly TWR = 1 for 30 seconds — straight up, not moving, α = 0, no drag.

TWR = 1 means F/m = g, so Δvideal = 9.81 × 30 = 294 m/s. γ = 90° so sin γ = 1, and Lgrav = 9.81 × 30 = 294 m/s. The other three terms are all zero.

294 = 0 + 294 + 0 + 0. It balances — and it says that thirty seconds of hovering costs 294 m/s and buys you nothing at all. Run this check on your own equation before you trust it.

In code

All of it, with no trig functions

Here's the payoff for building the derivation on the dot product. The kOS version needs no SIN, no COS, no ARCSIN, and no guarding against divide-by-zero in the angle math.

Look back at what you actually need: sin γ and cos α. Both are projections, and you have a projection operator.

sin γ  =  how much of v̂ points up  =  v̂ · û

cos α  =  how much of the nose points along v̂  =  n̂ · v̂

Both are dot products of two unit vectors. kOS hands you all three vectors directly.

the whole thing
FUNCTION accumulate {
  LOCAL now IS TIME:SECONDS.
  LOCAL dt  IS now - lastTick.
  SET lastTick TO now.
  IF dt <= 0 { RETURN. }

  LOCAL vel IS SHIP:VELOCITY:SURFACE.
  LOCAL spd IS vel:MAG.

  // On the pad the velocity vector has no direction to speak of.
  // We're pointed up and going nowhere: sin(90) = 1, cos(0) = 1.
  LOCAL sinGamma IS 1.
  LOCAL cosAlpha IS 1.
  IF spd > 1 {
    LOCAL vhat IS vel:NORMALIZED.
    SET sinGamma TO VDOT(vhat, SHIP:UP:VECTOR).
    SET cosAlpha TO VDOT(SHIP:FACING:VECTOR, vhat).
  }

  // kN / t is m/s^2 exactly — no conversion factor.
  LOCAL aT IS actualThrust() / SHIP:MASS.
  LOCAL r  IS SHIP:BODY:RADIUS + SHIP:ALTITUDE.
  LOCAL g  IS SHIP:BODY:MU / (r * r).

  SET dvIdeal   TO dvIdeal   + aT * dt.
  SET lossGrav  TO lossGrav  + g * sinGamma * dt.
  SET lossSteer TO lossSteer + aT * (1 - cosAlpha) * dt.
}

Six lines of physics. Each one is a term you derived, in the same order you derived it.

Compare against the scalar version. Doing this with trig means ARCSIN(MIN(MAX(SHIP:VERTICALSPEED / spd, -1), 1)) — where the MIN/MAX exist only to stop floating-point noise pushing the ratio past 1.0 and making ARCSIN return an error. Then you'd take SIN of it to get back the number you already had. The vector form skips the round trip entirely: VDOT of two unit vectors is the cosine, already clamped by construction.
Only convert to angles for the log file Your CSV wants γ and α in degrees, because you're going to plot them. That's the one place the trig belongs: ROUND(ARCSIN(sinGamma), 2) and ROUND(VANG(SHIP:FACING:VECTOR, vel), 2). Compute in vectors, display in degrees, and never feed a displayed angle back into the math.

Getting a compass heading, since you asked

You don't need this for the budget — that's the point of the last two sections — but you will want it in Arc 5, and it's the other thing VXCL is for. VXCL(k, v) means "v with everything along k removed", which flattens a vector into the horizontal plane:

heading & pitch from any direction vector
// Pitch above the horizon, degrees. VANG is measured from
// "up", so subtract from 90 to measure from the horizon.
FUNCTION pitchOf {
  DECLARE PARAMETER dir.
  RETURN 90 - VANG(dir, SHIP:UP:VECTOR).
}

// Compass heading, 0-360. Flatten both vectors into the
// local horizontal plane, then measure against north.
FUNCTION headingOf {
  DECLARE PARAMETER dir.
  LOCAL up    IS SHIP:UP:VECTOR.
  LOCAL north IS VXCL(up, SHIP:NORTH:VECTOR):NORMALIZED.
  LOCAL flat  IS VXCL(up, dir).
  IF flat:MAG < 0.001 { RETURN 0. }   // pointing straight up: no heading
  LOCAL hdg IS VANG(north, flat:NORMALIZED).
  // VANG only returns 0-180, so decide which side of north we're on.
  IF VDOT(flat, VCRS(up, north)) < 0 { SET hdg TO 360 - hdg. }
  RETURN hdg.
}
Verify the sign on your first run kOS uses a left-handed coordinate system, which means cross products point the opposite way from the right-hand rule you may have been taught. The VCRS(up, north) line above is meant to give "east" — check it once by sitting on the pad and pointing at a known heading. If headingOf(SHIP:FACING:VECTOR) reads 270 when you're facing east, swap the arguments to VCRS. Do this once, write down which way it went, and never think about it again.
Your question

Is linear algebra worth it here?

You asked whether linear algebra helps with any of this, or whether it makes working with kOS worse. Short answer: it is the single biggest quality-of-life improvement available to you, and this page is the evidence.

It replaces the trig you don't remember

The scalar derivation needs you to know that the along-track component of gravity is −mg sin γ. Where does the sin come from? From a co-function identity most people last used in school. The vector derivation gets the same answer from (0)(cos γ) + (−mg)(sin γ) — two multiplications and an addition, and the sin γ is the output, not a prerequisite.

That pattern holds for the rest of the series. Every place a textbook produces a mystery sine or cosine, a dot product produces it mechanically.

It's dimension-free, so the 2D/3D question stops mattering

The derivation was 2D because pictures are easier in 2D. But VDOT(vhat, SHIP:UP:VECTOR) never asked how many dimensions it was working in, and never asked you to choose axes. The same line is correct for a launch due east, a polar launch, and a dogleg — all of which genuinely need 3D, and all of which would need a new scalar derivation each.

This matters concretely in Arc 5. "What's the angle between my orbital plane and the target's?" has no clean scalar form at all. As vectors it's one cross product and one VANG.

It's what kOS is built out of

LOCK STEERING TO takes a direction. SHIP:FACING, SHIP:UP, SHIP:NORTH, SHIP:VELOCITY, and every position in the API are vectors. Working in angles means converting out of the representation the API gives you, doing scalar work, and converting back — two lossy steps that are also where the divide-by-zero and domain errors live.

What you actually need to know

Not much, and you now have all of it:

That's four ideas. There is no matrix anywhere in this series, no eigenvalue, no basis change, and no determinant. "Linear algebra" here means vector arithmetic, and the ceiling is genuinely this low.

Where it would make things worse

Two places, for honesty. Reading a log — a CSV column of unit vectors is unplottable, so convert to degrees on the way out. And talking to other people — every KSP tutorial and wiki page is written in angles, so you'll need to translate to compare notes.

Both are display concerns, not math concerns. The rule that falls out: compute in vectors, display in angles, never round-trip.