This project was a follow up to my post about the predator-prey model derived by Alfred Lotka and Vito Volterra. I chose to do this for two reasons. First its always easier to understand concepts when you have their meanings visualized and applied to real life. Second, when I took ODE’s phase planes where just lines and numbers on the board. After this project, I wholesomely understood the significance of phase planes, and they’re truly enlightening. I want to share that with everyone!

It’s a very straight forward program. I chose arbitrary values for the constants, my only concern was that the center point was at (2,2). The constants are .

All of the code and documentation is at my github repository.

Program Layout

I use OpenGL to plot solutions on the phase plane. The solutions are lines of particles that flow under the forces of the vector field from the Lotka-Volterra equations. I used a graph generated from gnuplot as the background. The graph is the vector field from (5,5) with center point at .

Then I use OpenCV to plot both populations against time. The sinusoidal graphs are just a sequence of lines drawn from pixel to pixel along the graph. Each pixel’s succeeding location is updated by the Lotka-Volterra equations as well. They’re plotted on top of the graph below, it as well was generated from gnuplot.

See it in Action

If you’re curious about what it looks like in action, I made a video about it in my math math modeling section.

To Do List

I learned OpenGL for this program, so it’s a little buggy and certainly not very clean.

There are a bunch of constants I had to experimentally derive to scale the mouse clicks to the appropriate dimensions for both windows. I’m sure there is a better way to go about doing it.

This could have eaily been written only in OpenCV, but then I wouldn’t have had the excuse to learn OpenGL! =]

Special Thanks

Thanks to my friend Ian Johnson for all of his help.

Also thanks to David Kopriva for teaching me about math models!