Your Equation

Library / Guidance and trajectory following / GUI-02

Guidance and trajectory following

Cross-track error from a straight path

Sideways distance from a straight path of known course through a given point.

Ref
GUI-02
Rev
v1
Field
Guidance and trajectory following
Result
e⊥ [m]

For a straight path through (N₀, E₀) with course χp (clockwise from north), the cross-track error is the component of the position offset at right angles to the path: e⊥ = −sin χp (N − N₀) + cos χp (E − E₀). Positive means the vehicle is to the right of the direction of travel along the path, negative to the left.

Sideways distance from a straight path of known course through a given point. Positive is to the right of the direction of travel along the path. The path course is χp and the point is (N₀, E₀).

Calculator

Solve for
m
°
0360
m
−500500
m
−500500
  • Along-track distance, cos χp (N − N₀) + sin χp (E − E₀)212.1 m
  • Distance from the path point223.6 m
  • Size of the cross-track error70.71 m

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Cross-track error (right positive) (m) current value 70.71 m
E - E₀East offset from the path pointKey driver
−424283
N - N₀North offset from the path point
−212495
χpPath course (clockwise from north)
−223223
  • The vehicle is 70.71 m to the right of the path and 212.1 m along it. The straight-line distance from the path point is 223.6 m, and the three numbers satisfy Pythagoras' theorem.
  • The sign is the safe check: for a path heading east (χp = 90°), a vehicle 100 m to the north is to the left of it, and the formula gives −100 m.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (m)Local stepChange in result
E - E₀ East offset from the path point−500 to 500 m−424.3282.8707.1+20 m+20 %
N - N₀ North offset from the path point−500 to 500 m−212.1495707.1+20 m−20 %
χp Path course (clockwise from north)0 to 360 °−223.4223.4446.8+10%−23.8 %

Sweep of East offset from the path point

East offset from the path point (m)Cross-track error (right positive) (m)
−500−424.3
−375−335.9
−250−247.5
−125−159.1
0−70.71
12517.68
250106.1
375194.5
500282.8

Sweep one variable

Cross-track error (right positive) (m)Hover, touch, or use the arrow keys on the chart
−400−2000200 −400−2000200400 East offset from the path point (m) now 70.71

Variables and how each one contributes

e⊥

Cross-track error (right positive)

Result · m

What the equation gives you. Everything else feeds it.

χp

Path course (clockwise from north)

° · typical 0 to 360

The course of the path in degrees, clockwise from north. Rotating the path changes which part of the offset is sideways to it and which is along it. Raising it by 10° (to 55°) moves the result by −53.6 %, from 70.71 to 32.8 m.

N - N₀

North offset from the path point

m · typical −500 to 500

The north offset of the vehicle from the path point, N − N₀, in m. Contributes −sin χp times itself: for a path heading east, being further north puts the vehicle further to the left. Raising it by 10 % (to 110) moves the result by −10 %, from 70.71 to 63.64 m.

E - E₀

East offset from the path point

m · typical −500 to 500

The east offset of the vehicle from the path point, E − E₀, in m. Contributes cos χp times itself: for a path heading north, being further east puts the vehicle further to the right. Raising it by 10 % (to 220) moves the result by +20 %, from 70.71 to 84.85 m.

Worked example with the values above

  1. Rotation terms for χp = 45°: sin = 0.7071, cos = 0.7071.
  2. Sideways component: −0.7071 × 100 + 0.7071 × 200.
  3. e⊥ = 70.71 m, to the right of the path.

Assumptions and limits

  • A straight path and local flat north–east coordinates, over a limited area.
  • The path point and the vehicle position given in the same frame, and the course measured clockwise from north.

Common mistakes

  • Using the wrong sign convention. Check it against a simple case, such as a path heading east, before using it in a controller.
  • Applying it over long legs on a curved Earth, where local coordinates stop being accurate.

Statistics and uncertainty

The formula is a rotation of the position offset, which keeps the size of independent, equal position noise. If N and E each have a noise of σ, the cross-track error has a noise of σ whatever the path direction. A 5 m position error is therefore a 5 m cross-track error, which should be compared with the width of the path tolerated.

Where it is used

  • Line following for aircraft, ships and ground vehicles: it is the quantity a guidance law drives to zero.
  • Checking how far a recorded track strays from a planned leg.

Maths you need

  • Rotation of coordinates: resolving a vector along and across a direction
  • Compass courses: angles clockwise from north

Related formulas

Practise this formula