Skip to Content
Apex Pathing is currently not released! Join the  Discord Server  to help or keep up with development.
DocumentationB Spline Theory

BSpline Theory


Cubic Functions

  • At its core, B-Splines are cubic functions, a function with a degree of 3. For example, a simple linear equation: \(f(x)=\ mx+b\) has a degree of 1, because the highest power in the equation, is 1.
  • A quadratic: \(f(x)=\ Ax^2+Bx+C\) has a degree of 2. When increasing the degree,the base equation just gets a new coefficient and degree. For example, a quintic equation would be \(f(x) =\ Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F\)
  • Let’s substitute \(x\) as \(t\), the time it takes between the beginning and end of a curve, usually expressed as \(t \in [0,1]\) which basically means that all curves happen on a range from 0 to 1.
  • This means that any t value that is plugged into the equation, for example \(t = 0.6\), will give you the vector, or coordinate that is exactly \((t*100)\)% along the line.
  • With this in mind, let’s write the cubic function equation: \(f(t) = At^3 + Bt^2 + Ct +D\)

2D curves

  • For a given function \(f(t)\), it is important to note that this function cannot have multiple outputs for the same input. If it weren’t for this, it wouldn’t be considered a function.
  • However, we can get around this by essentially assigning \(t\) values. We must keep in mind that although \(t\) is a substitution of \(x\), it does directly correspond to the X-Axis.
  • Therefore, a vector/coordinate at \((x:5,y:5)\) could have a \(t\) value of \(0.2\).
  • Then, if you were to create another vector at \((x:5,y:10)\), and assign it at a \(t\) value of \(0.4\), you could create a curve between the two.
  • Unfortunately, simply creating a function passing through both vectors runs into the same issue.
  • This is where 2D curves come in. Imagine that each \(x\) and \(y\) value of a function relates to another function. This allows you to model 2 functions, one for \(x\) and one for \(y\).
  • As a result, the functino doesn’t pass through 2 points on the same \(x\) value, but passes through one point on the \(x\) function and 2 on the \(y\) function.
  • This can be modeled as \((x:f(t),y:g(t))\) where \(f(t)\) is the x function, and \(g(t)\) is the y function.
  • Imagine a coordinate plane where the \(x\) axis is represented as \(t\) and the \(y\) axis is represented by \(x\). This is the \(x\) function’s ‘space’
  • In the ‘space’, the coordinates from earlier could be written as \((0.2,5)\) and \((0.4,5)\), following the scheme of \((t,x)\).
  • Similarly, the coordinates on the \(y\) function’s ‘space’ would be \((0.2,5)\) and \((0.4,10)\). Each function can be solved by interpolation (more on that later), because now, there is only one output for each input. Then, just plug the functions back into \((f(t),g(t))\).
  • To gain a more in-depth understanding of this concept, we recommend watching this YouTube video .

B-Spline Features

B-Splines possess multiple advantageous properties making them a perfect fit for FTC pathing!

  • B-Splines are \(C_2\) continuous: Their curves are connected, their first derivatives are connected, and the second derivatives, or the derivatives of the derivatives are connected.
  • This translates to exceptionally smooth pathing without any sudden jerks, and enables efficient computing.
  • B-Splines are \(G_1\) continuous, meaning that the curvature is continuous. This essentially means that the robot won’t experience any acceleration jumps while traveling the path.
  • Similar to Bezier Curves, B-Splines do not interpolate ANY control points. As a result, B-Splines do not pass through any of the specified control points, as only the endpoints are interpolated. However, we devised a way to get around this using a clever mathematical concept.
Last updated on