<p>I did some research and found the answer I was looking for.  The three most common ways to interpolate vectors are:</p>

<ol>
<li>Slerp - short for "spherical interpolation", this is the most correct way, but is also the costliest.  In practice you likely do not need the precision.</li>
<li>lerp - short for "linear interpolation", you just do a regular linear interpolation between the vectors and use that as a result.</li>
<li>nlerp - short for "normalized linear interpolation" you just normalize the result of a lerp.  Useful if you need your interpolated vector to be a normalized vector.</li>
</ol>

<p>In practice, lerp/nlerp are pretty good at getting a pretty close interpolated direction so long as the angle they are interpolating between is sufficiently small (say, 90 degrees, or 120 like Simon mentions in his comment), and nlerp is of course good at keeping the right length, if you need a normalized vector.  If you want to preserve the length while interpolating between non normalized vectors, you could always interpolate the length and direction separately.</p>

<p>Here is an example of the three interpolations on a large angle.  Dark grey = start vector, light grey = end vector.  Green = slerp, blue = lerp, orange = nlerp.<br>
<a href="https://i.sstatic.net/LaV6S.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LaV6S.png" alt="enter image description here"></a></p>

<p>Here is an example of a medium sized angle (~90 degrees) interpolating the same time t between the angles:<br>
<a href="https://i.sstatic.net/2gjmE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2gjmE.png" alt="enter image description here"></a></p>

<p>Lastly, here's a smaller angle (~35 degrees).  You can see that the results of lerp / nlerp are more accurate as the angle between the interpolated vectors gets smaller.<br>
<a href="https://i.sstatic.net/mrUqf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mrUqf.png" alt="enter image description here"></a></p>

<p>If you do lerp or nlerp, you can definitely do both bilinear as well as bicubic interpolation.</p>

<p>Using slerp, you can do bilinear interpolation, but I'm not sure how bicubic would translate.</p>

<p>I generated these images by taking screenshots from an interactive shadertoy demo I made to demonstrate these differences.  You can see that shadertoy here:<br>
<a href="https://www.shadertoy.com/view/4sV3zt" rel="nofollow noreferrer">https://www.shadertoy.com/view/4sV3zt</a></p>

CC BY-SA 3.0
2016-02-22T14:16:06.993Z
Thanks for taking the time, on both the answer and the ShaderToy example!
Rotem
CC BY-SA 3.0
2016-03-02T20:23:53.287Z
Lerp and nlerp seem “good enough” for angles <90°, but when you start getting higher (especially around 180°), the inaccuracies of lerp/nlerp become extremely pronounced.  I modified your ShaderToy example to have the vectors be 178.2° (180° * 0.99) apart from each other and the lerp/nlerp results are garbage: https://www.shadertoy.com/view/4sGGWd  If you can guarantee that the angle delta will be <90° lerp/nlerp may be a fair optimization; if not, I think using slerp in combination with heavy memoization or a pre-computed lookup table is a safer and fast-enough way to go.
Slipp D. Thompson
CC BY-SA 3.0
2016-03-02T20:40:26.713Z
I think you missed the fact that you can click the mouse to change the vector angles! and yeah, it gets real bad at larger angles.  You can even see that in the top image in my answer!
Alan Wolfe
CC BY-SA 3.0
2016-03-02T20:40:34.917Z
@AlanWolfe: Side-note: I can write up an answer than pre-computes the `slerp` results into a texture and looks-up the values at runtime, if you're interested.  Given that the color value is the output normal, and if we can assume both lookup vectors are normal-or-nearly-normal-length, I believe the lookup table can be reduced to only plausible inputs, without covering the whole input space (4-dimensional, 2 for each input vector) and without resorting to using vector angles as inputs (2-dimensional, but still incurs the `atan2` cost).
Slipp D. Thompson
CC BY-SA 3.0
2016-03-02T20:41:45.603Z
@AlanWolfe Ha, yah, I totally did.  You're one step ahead of me!  _Deleting my shadertoy clone (link above is now dead)._
Slipp D. Thompson
CC BY-SA 3.0
2016-02-19T18:31:02.727Z
2016-02-20T20:09:48.967Z
2016-02-20T20:09:48.967Z
Alan Wolfe
<p>If you have values on a grid and you want to find the value of a point within one of the cells, you can use techniques like bilinear or bicubic interpolation to get the data at that point.</p>

<p>What technique(s) would be used if the data on the grid was a vector (a surface normal specifically)?</p>

<p>I know that quaternions are good for slerping, which I think could be good in this case to do a "bilinear slerp", but quaternions require basis vectors that represent an orientation, not just a single vector.</p>

<p>Also, I'm not sure how you'd use quaternions to apply something like bicubic interpolation.</p>

<p>What methods would be good in this case, to interpolate vectors on a grid?</p>

CC BY-SA 3.0
2016-02-19T07:08:04.263Z
Slerp is a possibility for normals. It stands for "spherical lerp"—unit vectors lie on a sphere as much as unit quaternions do.
John Calsbeek
CC BY-SA 3.0
2016-02-19T14:50:07.500Z
I've found out that nlerp is a decent method: just interpolate your components and re-normalize.  I can do a bicubic version of this by doing each component individually.  Found some decent links too: https://keithmaggio.wordpress.com/2011/02/15/math-magician-lerp-slerp-and-nlerp/  and http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ .
Alan Wolfe
CC BY-SA 3.0
2016-02-19T14:55:46.257Z
If you know your grid vectors don't vary more than, say, 120 degrees  from grid point to grid point (i.e. trying to avoid problems with "which way do you interpolate), why wouldn't bicubic interpolation with renormalisation be "good enough"?
Simon F
<vectors><interpolation>
Interpolating vectors on a grid
Alan Wolfe
# Interpolating vectors on a grid

(Asked by: username_0 on 2016-02-19)

If you have values on a grid and you want to find the value of a point within one of the cells, you can use techniques like bilinear or bicubic interpolation to get the data at that point.

What technique(s) would be used if the data on the grid was a vector (a surface normal specifically)?

I know that quaternions are good for slerping, which I think could be good in this case to do a "bilinear slerp", but quaternions require basis vectors that represent an orientation, not just a single vector.

Also, I'm not sure how you'd use quaternions to apply something like bicubic interpolation.

What methods would be good in this case, to interpolate vectors on a grid?

**Tags:** vectors, interpolation

> **Comments:**
> **username_1**: Slerp is a possibility for normals. It stands for "spherical lerp"—unit vectors lie on a sphere as much as unit quaternions do.  
> **username_0**: I've found out that nlerp is a decent method: just interpolate your components and re-normalize.  I can do a bicubic version of this by doing each component individually.  Found some decent links too: https://keithmaggio.wordpress.com/2011/02/15/math-magician-lerp-slerp-and-nlerp/  and http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ .  
> **username_2**: If you know your grid vectors don't vary more than, say, 120 degrees  from grid point to grid point (i.e. trying to avoid problems with "which way do you interpolate), why wouldn't bicubic interpolation with renormalisation be "good enough"?  

---

## 1 answers

### Answer by username_0 on 2016-02-19. Score: 5 | Accepted answer

I did some research and found the answer I was looking for. The three most common ways to interpolate vectors are:

1. Slerp - short for "spherical interpolation", this is the most correct way, but is also the costliest. In practice you likely do not need the precision.
2. lerp - short for "linear interpolation", you just do a regular linear interpolation between the vectors and use that as a result.
3. nlerp - short for "normalized linear interpolation" you just normalize the result of a lerp. Useful if you need your interpolated vector to be a normalized vector.

In practice, lerp/nlerp are pretty good at getting a pretty close interpolated direction so long as the angle they are interpolating between is sufficiently small (say, 90 degrees, or 120 like username_2 mentions in his comment), and nlerp is of course good at keeping the right length, if you need a normalized vector. If you want to preserve the length while interpolating between non normalized vectors, you could always interpolate the length and direction separately.

Here is an example of the three interpolations on a large angle. Dark grey = start vector, light grey = end vector. Green = slerp, blue = lerp, orange = nlerp.  
[![enter image description here](https://i.sstatic.net/LaV6S.png)](https://i.sstatic.net/LaV6S.png)

Here is an example of a medium sized angle (~90 degrees) interpolating the same time t between the angles:  
[![enter image description here](https://i.sstatic.net/2gjmE.png)](https://i.sstatic.net/2gjmE.png)

Lastly, here's a smaller angle (~35 degrees). You can see that the results of lerp / nlerp are more accurate as the angle between the interpolated vectors gets smaller.  
[![enter image description here](https://i.sstatic.net/mrUqf.png)](https://i.sstatic.net/mrUqf.png)

If you do lerp or nlerp, you can definitely do both bilinear as well as bicubic interpolation.

Using slerp, you can do bilinear interpolation, but I'm not sure how bicubic would translate.

I generated these images by taking screenshots from an interactive shadertoy demo I made to demonstrate these differences. You can see that shadertoy here:  
<https://www.shadertoy.com/view/4sV3zt>

> **Comments:**
> **username_3**: Thanks for taking the time, on both the answer and the ShaderToy example!  
> **username_4**: Lerp and nlerp seem “good enough” for angles <90°, but when you start getting higher (especially around 180°), the inaccuracies of lerp/nlerp become extremely pronounced.  I modified your ShaderToy example to have the vectors be 178.2° (180° * 0.99) apart from each other and the lerp/nlerp results are garbage: https://www.shadertoy.com/view/4sGGWd  If you can guarantee that the angle delta will be <90° lerp/nlerp may be a fair optimization; if not, I think using slerp in combination with heavy memoization or a pre-computed lookup table is a safer and fast-enough way to go.  
> **username_0**: I think you missed the fact that you can click the mouse to change the vector angles! and yeah, it gets real bad at larger angles.  You can even see that in the top image in my answer!  
> **username_4**: @username_0: Side-note: I can write up an answer than pre-computes the `slerp` results into a texture and looks-up the values at runtime, if you're interested.  Given that the color value is the output normal, and if we can assume both lookup vectors are normal-or-nearly-normal-length, I believe the lookup table can be reduced to only plausible inputs, without covering the whole input space (4-dimensional, 2 for each input vector) and without resorting to using vector angles as inputs (2-dimensional, but still incurs the `atan2` cost).  
> **username_4**: @username_0 Ha, yah, I totally did.  You're one step ahead of me!  _Deleting my shadertoy clone (link above is now dead)._  

---

