synWater Copyright 1999-2014 (c) Synthetic Reality Co. |
|||||||||||||
|
This is another useless
demo program, and is a serious number cruncher with which
to task your high powered computer. This program is FREE, not shareware. Just enjoy it. What Is synWater? Aside from an interest in simulating wave action on the surface of water (remember those 'ripple tanks' in high school physics?), I also was experimenting with higher color resolution DIBs. This program uses 16 bit color DIBs (and as a result probably won't run under NT, just to warn you). Only after I finished it did it hit me that only meant 5 bits of 'blue' and 32 shades is not as amazing a spectrum as I was idly dreaming about while coding it. Overall, I know I will be writing a sailboat simulator (I should say ANOTHER sailboat simulator) someday and I am thinking about water off and on as a result. I had an insight that the wake behind a boat might be modelled as a large number of expanding circular wavefronts displaced in time (imagine the rear end of the boat dropping pebbles in the water at regular intervals as it moved along) Thus was born synWater. Once running, you click in the water area to start a drop going. I think I limit you to max of 10 simultaneous drops. The resulting interference patterns can be quite pretty (and I think very water-like in way) Running the Program Well, just download the executable and run it.
It is a dialog-based MFC app written in VC++ 4.2b The Controls are:
There's really not a lot to this program. The Math This is more an example of my implementing a model which I thought would be useful later in a game, rather than trying to simulate the underlying physics of particle and wave interactions. My reasoning went like this: Imagine that every disturbance in the water can be modeled as a 'drip' of a particular intensity starting at a particular moment in time. From the perspective of the drip, there would be a circular wave front pushing out from the center of the drip. Viewed from the side this would be a sine wave which would start off with a peak set by the initial drip magnitude and would then peter off slowly with some decay value. A single drip in the center of the pond would affect the elevation of every other point on the surface of the pond with an equation similar to this:
I like to think of the drip in the middle continuing to bounce up and down (initial weight of drip presses it down, then pressure of surrounding water fills in the depression but makes a little hill, which is then pulled back down by gravity which makes a valley and this repeats over and over becoming the foundation of the sinusoidal wave). And then slowly petering out, but each new ripple in the center makes a new circular wave front which propagates out from the center at a certain velocity, decaying in amplitude the further it gets from the center. So basically I wrote an equation which gives the elevation of an x,y location contributed by a single drip, then called it repeated for each possible x,y location in the computation space. Then I convert the elevation to a color and display it. Then I made an array of drips and ended up with this:
Given that the inner loop (called 100*100*10 times in the default case) contains a squareroot, a sine calculation, and several multiplies and divides, it is clear to see why this is so slow! But it's so pretty! :-) |
||||||||||||
COPYRIGHT synWater is the property of Synthetic Reality and all rights are reserved. If we can figure out a way to convince people to pay for this, you can be sure we'll give it a try. But for now it is expressly intended to provide a moment of joy for the math geeks in the audience, looking for number-crunching programs to show off their power computers! Thanks for your feedback in advance! Dan Samuel |