Bilinear interpolation of angles

2.3k Views Asked by At

Is their a solution to do a bilinear interpolation in x,y of angles in [0°-360°[ ? The elementary formula of bilinear interpolation don't work on angles due to the discontinuity at 360°-0°. http://en.wikipedia.org/wiki/Bilinear_interpolation

I have found a formula the mean of angles but it doesn't seems usefull for bilinear interpolation of angles.

http://en.wikipedia.org/wiki/Mean_of_circular_quantities#Mean_of_angles

2

There are 2 best solutions below

10
On

Standard bilinear interpolation goes like this: Given the values $a=f(0,0)$, $b=f(1,0)$, $c=f(0,1)$, and $d=f(1,1)$, the value of $f(x,y)$ can be found as: $$j=(1-x)a+xb$$ $$k=(1-x)c+xd$$ $$f(x,y)=(1-y)j+yk$$ Now, when working in a circular realm, we wish to take the short way around; sometimes, this is not the way that interpolates between $a$ and $b$ as numbers! This happens when $|a-b|>$ half a circle.

To fix this, in places where we need to interpolate around a circle, we can simply add a whole circle ($360°$ or $2\pi$) to the smaller of the two values when they're too far apart as described above. There are three such places, and three such pairs of values: $(a, b)$, $(c,d)$ and $(j,k)$.

Now the bad news: this will give crazy answers when $j$ and $k$ end up passing directly opposite each other. To see this, try $a=45°$, $b=135°$, $c=315°$, and $d=225°$.

8
On

I think I finally have enough information from OP to know what he or she is talking about.

Imagine that the world is an flat sheet of paper. The wind blows through this world, defining a vector field. We can model this as a function $f:\mathbb{R}^2 \to \mathbb{R}^2$. In other words, we have $f(x,y) = (U(x,y),V(x,y))$.

Assume we only know the value of $f$ at four points the fours points $$(x_0,y_0), (x_0,y_1),(x_1,y_0),(x_1,y_1)$$

We want to approximate the value of $f$ at all points interior to the rectangle by "bilinear interpolation": in other words, we can interpolate linearly along the top and bottom edge, and then interpolate linearly again through these values.

There is no problem here: just use the standard formula for bilinear interpolation on $U(x,y)$ and $V(x,y)$ separately.

The problem comes when you try to approach this problem in polar coordinates: if you want to bilinearly interpolate angles, you run into the topological problems I mention in the answer on MO (essentially you run into the fact that the mobius strip cannot retract onto its boundary circle).

So my solution is to simply avoid the angles, and work directly with the actual vector field.

If for some reason you did not have the magnitude information, but only the angle information, you would be kind of sunk. One thing you could do in this case is to imagine that the magnitudes are all $1$, convert to rectangular coordinates, and implement my method above. This circumvents the topological obstruction because we can allow $f(a,b) = (0,0)$, which does not correspond to an angle.

Moral of the story: when modeling wind, it is possible that you will need the wind to be stationary sometimes. In other words $f(x,y)=(0,0)$ for some $(x,y)$. This does not have a well defined angle measurement, so it kind of sucks to try and model this in polar coordinates. Much better to stick to rectangular coordinates, which do not have this pathological behavior.