I'm trying to visually illustrate forecast wind speed and direction, the programming is the easy part, the math, I'm fuzzy on.

I have a grid of points (lat/lon) , the forecast wind speed and forecast wind direction at each point. I'd like to draw a line that would "thread" through a grid of points. Think of it as if you dropped a ribbon, and watched the wind currents take it. I'd iterate through several time periods re-calculating the points for each time period, and drawing a line between them.

For example, in the following grid, the arrows represent wind direction, and the thicker red line shows the resulting "thread".

Seems like there's some linear alegbra / vector type solution, but I'm struggling with where to start. It's been years (more than I care to remember), since I studied linear algebra.

Thanks in advance for any assistance.

enter image description here

  • $\begingroup$ Hi, William, welcome to math.se, I have retagged your question to better reflect your idea, what software or specific language you are using to visualize the streamlines? There are many pkgs in CFD could do this. $\endgroup$ – Shuhao Cao Sep 16 '12 at 23:26
  • $\begingroup$ Thanks Shuhao. I plan on rendering this in HTML5, using JavaScript, and the HTML 5 canvas element. $\endgroup$ – William Walseth Sep 17 '12 at 1:27

You're looking to compute streamlines. You can compute them by computing the direction of the fluid flow at every point. At every $(x,y)$ coordinate at which you have a measurement, the vector of the fluid flow gives you the streamline.

In order to compute the streamline between grid points (assuming that the only information regarding the flow field that you have is the measurements at the discrete points), the simplest method is to linearly interpolate.

Assume you want a measurement at coordinate $(x_0+\epsilon, y_0+\delta)$, and you have measurements at $(x_0,y_0), (x_0,y_1), (x_1,y_0), (x_1,y_1)$. The most straightforward approach, which should be accurate enough for visualization, is to interpolate for values at $(x_0,y_0+\delta)$ and $(x_1,y_0+\delta)$. Then, use these results to interpolate for the final value.

Geometrically, imagine your four measurements are at the corners of a box. First, draw a line horizontally through where you want your estimate. Then, where this line intersects the vertical sides of the box, estimate the streamlines there. Then, use these estimates to estimate the value inside the box.

Linear interpolation can be performed using the relationship $$ \frac{v_2-v_1}{u_2-u_1} = \frac{v-v_1}{u-u_1}. $$ Here, the $v$'s represent your streamline measurements, and the $u$ represents each coordinate (either $x$ or $y$).

Example, to estimate the streamline at coordinate $(.4,.6)$: $$\begin{align*} f(0,0) &= (3,4) \\ f(0,1) &= (3,5) \\ f(1,0) &= (2,4) \\ f(1,1) &= (2,2) \\ \end{align*} $$

$$ f(0,.6) = \left( \frac{3-3}{1-0}(.6-0)+3, \frac{5-4}{1-0}(.6-0)+4 \right) = (3,4.6) $$ $$ f(1,.6) = \left( \frac{2-2}{1-0}(.6-0)+2, \frac{2-4}{1-0}(.6-0)+4 \right) = (2,2.8) $$

Now we've interpolated vertically (which is why we replaced $u$ in the general formula above with the $y$ coordinate). Next, we interpolate over $x$. $$ f(.4,.6) = \left( \frac{2-3}{1-0}(.4-0)+2, \frac{2.8-4.6}{1-0}(.4-0)+4.6 \right) = (2.6,3.88) $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.