# Understanding normal and binormal of a vector or of a spline

I found a paper where it computes the 3D trajectory of a quadrotor and defines an error position as the difference between 2 vectors (here the source, under 3D trajectory control):

$$e_{p} = ((\mathbf{r_{T}} - \mathbf{r})\cdot \mathbf{\hat{n}})\mathbf{\hat{n}}+((\mathbf{r_{T}} - \mathbf{r})\cdot \mathbf{\hat{b}})\mathbf{\hat{b}}$$

I have two problems with this definition:

1. Given that I have calculated the difference between $\mathbf{r_{T}}$ and $\mathbf{r}$ which turns out to be a vector in the space (3D) why is projected to times thru 2 scalar multiplication with the vector $\mathbf{\hat{n}}$ ? I tried to draw such a situation, where you have the resulting vector (figure a) and than a horizontal situation seen from above (figure b). I still cannot see how the vector $\mathbf{a}$ is going to be projected along this vector. And why twice?

2. I've found lot of good documentation about calculating such vectors link#1 and link#2 but I was wondering if is possible to apply the same to a spline (as in my application). In my program I ve defined a spline through more points, so is not difficult to get a tangential vector. But I since I don't have a continuous function, (the spline is defined through many interpolation points) I cannot simply derive a function (as in the link#3 above). How should I proceed when my spline is discretized? (I mean how to get normal and binormal point by point) ?

For your first question, the $r_T -r$ is not projected two times with vector $\hat{n}$. $(r_T -r)\cdot\hat{n}$ means inner product between vector $r_T-r$ and the unit vector $\hat{n}$ and the result of inner product is always a scalar. $((r_T -r)\cdot\hat{n})\hat{n}$ (still a vector) represents the component of $r_T -r$ in the direction of $\hat{n}$. So. that equation simply says the error $e_p$ is defined as the sum of the components of $r_T -r$ in the direction of unit vectors $\hat{n}$ and $\hat{b}$.
For the 2nd question, even if the spline is derived from interpolating discrete data points, the spline is still a continuous (or piecewise continuous) function and you can evaluate the first derivative and 2nd derivative at any parameter value. Once you have the first and second derivative, you can compute $\hat{t}$, $\hat{b}$ and $\hat{n}$ following the links you had found. You do need to be aware that when the spline is piecewise continuous, the spline could be only $C^1$ continuous (i.e., first derivative continuous) for the entire spline and have $C^2$ discontinuities at some discrete points. If this is the case, the normal and binormal vector will not be continuous for the entire spline either.