I am trying to write a Mathematica script that can interpolate a discrete vector field to a continuous vector field. I then want to extract the integral curves (field lines) from the continuous vector field.
I know that Mathematica’s ListStreamPlot function can visually present integral curves; however, I need the actual points that comprise them.
I have considered writing a brute-force method to the following effect: It seems that the integral curve could be determined recursively. If a point were picked in the list, then the “next” point in the integral curve would be that with the closest slope. (Each “point” is actually a vector, and thus each has its own slope.) There are only 4 candidates for the “next” point — up, down, left, or right of the current point. The “next” point would then become the new starting point, and the process would recurse until the edge of the grid is reached.
However, I wonder if there is a simpler method using Mathematica’s higher-level functions. (I also don’t know if my method is even conceptually correct.)
I would really appreciate any thoughts or suggestions on this task.
Thanks!
FYI: http://mathematica.stackexchange.com
Make up some data:
Build a
ListStreamPlotIn Mathematica everything is an expression – so even this plot is basically visualized code of graphics primitives. You can extract those primitives – including lines you need – by various ways. For example – just picking parts of expression you cam find all points comprising this plot:
If you need to see the whole expression evaluate
plot//InputForm. Now you could also do pattern matching to see inside expression. lets find all indexes comprising all your lines:Now you have everything to analyse, draw and stylize your lines. For example – design an app that highlights a specific line in the original plot: