-
If the new wilds use the water level idea to designate boundaries between the surface and underwater... I propose a surface feature: Tides.
Tides, as you know, are caused by the gravitational force of celestial bodies pulling on the world's surface water, ie. the oceans. Well, in a simplisitic model I've developed, tides can be computed by using the sine and cosine functions. The cosine function is used to get the actual tide level. Sine is used to compute the change (to be able to indicate if the tide is rising or falling) at the same location.
Well, how is it computed? First you identify all bodies that "orbit" the world: moons, suns, other planets(?) that you wish to have affect the tides. Next, create a formula that gives the ANGLE of each body with respect to the world at any time of the year. Then, you need to have a similar function that gives the current angle of the desired longitude, using the time of day. Next, the pulling power of all objects needs to be determined, as that influences how HIGH that body can make the tide.
The formulae already! OK! FINE!
[code]
for(i=0,t=0.0,dt=0.0;i<nbodies;i++) {
t += bodies[i].maxtide * cos(bodies[i].angle - angle);
dt += bodies[i].maxtide * sin(bodies[i].angle - angle);
}
[/code]
[b]EDIT: I had the wrong assignment operators. They should be += not = .[/b]
The angle is the longitude that you wish to get the tide level for. This longitude would need to be time shifted around the world to get the "correct" one for this function. Example: If you are at 120W, at 5pm, your angle should be 135E due to the rotation of the world.
But what is computed? The final result "t" is the vertical offset from normal sea level the oceans at THAT angle of longitude (offset by the time of day). The value in "dt" is the change in the tides at that time, using the derivative of the cosine (which is -sine) in the summation. Since trig functions are cyclic, you can get the change in "dt" just by negating the value of "t". These can be used to determine if the tide is rising or ebbing. Whether it is slack or not.
Note on the formulae: I'm aware that this is likely a simplified form of the tidal level. I used the idea that a single gravitational body will pull the water on the surface toward it as well as the world itself, creating a bulge on both sides of the world and thinning out the water on the perpendicular points. The more I looked at it, the more it looked like a cosine wave wrapped around the world with the peaks inline with the body and the valleys on the perpendicular axis. It followed rather quickly that the overall tidal form is just the summation of ALL gravitational bodies pulling on the water. There are other things that can affect the tides, such as weather and the shape of the surface. But we're not trying to be 100% realistic and most people will not have the knowledge to discern any difference. That's both pointless and unfeasible.
Now, with the tides, what could this do for us? Well, the ocean water level could rise and fall obviously as you sail around during the day. However, by using a water level block for the oceans, we can have tides REVEAL stuff that would normally be underwater (thus requiring that you DIVE), such as an underwater cave entrance, or sunken debris. Sailing around the coast line would be risky for deeper draft ships, especially when the tide is ebbing. There is a chance the ship may become stranded. Swimming underwater near the shore could result in the water level dropping enough that you are no longer underwater, but touching bottom. Or the reverse, you are on the shore and the tidal waters rush in and envelop you.
Comments!!
-
Having dabbled in physics some I am definitely interested in tackling the vector math of this. Mmm, math 8). Of course, before we can implement any tide code, we would have to determine what exactly our astronomy is. Currently "time" implies that we have one moon, which I think is a little boring. Two moons would be nicer, three probably a bit too many, unless we wanted to make one of them a huge asteroid.
It could possibly be coded into the wilderness as the ocean creeping up a few rooms or so up on the land… could also be a potential mob script trigger for NPCs on the beach to come in because the tide is up.
-
Having dabbled in physics some, I have definitely had my fill of vector math. Ewww, math. I'll leave the trig to the people that find it…fun?
-
:P Be glad my minor was math! :P
But yeah, I'm sure there is more to it than what I've derived….
-
Hi guys,
Sorry I didn't respond to this earlier - I've been a bit preoccupied as you know.
I wouldn't recommend using the code above, as simple and sensible as it looks. I've had a bit of experience with this sort of thing in the past and can tell you that the sine/cosine routines are very slow, and provide much more accuracy than we need for our purposes. (For the benefit of the uninitiated, by "accuracy" I mean results to an extended number of significant digits that we'd never use). What you're looking for really is an integer math-based transformation routine, or perhaps even pre-calculated sine/cosine lookup-table(s), which would be significantly faster and efficient. There are any number of these posted all over the internet, and I'd invite you to have a look at some of them and maybe try a few out.
The idea is sound, however. Putting it into practice will be a really interesting coding exercise.
Scott.
-
:P never said the built-in sin/cos functions would have to be used. substituting for speed reasons is a must for that. It's the end result that's needed.
-
Yup, we could get around this with tables generated at startup.
I did a similar thing with the logarithm function in determining mob skills. I don't know how processor-intensive the log function is, but decided to stay on the safe side.