features as the ability to plot
also has adorable cows, clouds, dusk, dawn, and other such fine accoutrements
which all fashionable graphing calculators in this modern age aspire toward.
Try it now
A brief account of the creation of Graph Land
A flight simulator I've been working on needed some interesting terrain for the player to fly over. I saw two solutions: use a level editor to create some interesting terrain (the manual route), or make an algorithm that generates interesting terrain (the procedural route). Making levels by hand is tedious and time-consuming, so I chose procedural terrain generation, which is also time-consuming but more entertaining.
Later, I found myself coming back to this app to visualize other things. I used it to tune the length of daytime/nighttime (a modified sine wave) in a different game. Then I needed to smoothly switch colors in another app and I knew the shape of the curve I wanted, but I didn't know what the actual formula was until I messed around in the graphing app for a few minutes and found it.
Much later, cows wandered in. Shortly after that clouds formed in the sky. Eventually the sun, showing no respect for the traditional order of creation by its tardiness, started making a daily appearance.
I've found Graph Land useful. I'm publishing it so others can use it too. The whole thing is licensed under the Apache 2 license, so feel free to reuse it in other projects.
A collection of examples, most of which may be useful to game programmers:
% operator (A) behaves like C not like Python,
which always frustrates me when
x is negative. I usually end up
using (B) instead. Rounding down (C) gives a formula that converts any value of
x to a valid index into an array of length 3.
Smooth transitions can be down with a modified logistic function (D), which
is very easy to tweak ((A) gives a slow transition, (E) is much more abrupt). A
much faster but less flexible approach is
Sometimes you want abrupt transitions, not smooth transitions. (G) and (H) will give you those.
Convincing random terrain is largely a matter of mixing several frequencies together.
If you use your imagination, you can pretend this is a hill even though it is
y = Math.sin(x/4)
Adding in another higher-frequency, lower-amplitude sine wave makes a
y = Math.sin(x/4) + Math.sin(x/2+17)/2
(The "+17" bit offsets the second sine wave so both waves don't cross (0, 0) together.)
If you keep adding in higher-frequency, lower-amplitude waves you can see the hill gets more and more detail:
The terrain in my flight simulator works the same way except that I use random noise instead of sine waves for the basic input, so instead of combining many layers of sine waves, it is combining many layers of random noise.