Math and caves

I need to randomly draw caves... I have written a program which does the opposite of what I need it to do but I lost it and I have no idea how I did it. Imagine a screen with the dimensions 94*62, two numbers are selected at random (rand94, rand62), something has to happen between these numbers where as these numbers get closer to the middle of the screen, the radius of the circle is larger. Code:

1
2
3
4
5
6
7
8
While (N>0)
{
N = N -1;
A = Rand94;
B = Rand62;
//Equasion to find C, the radius
Circle(A,B,C); //draws a circle
}


What it should look like:
http://s27.postimg.org/spgze38gv/Cave.png
What it should resemble:
http://thehdwall.com/wp-content/uploads/2014/08/Tunnel-Light-Painting-Fantasy-Dark-Cave-Abstract-Landscapes-Wallpaperswide-Mobile.jpg

Math answers:

if A=47 and B=31 then C==23
if A=10 and B=40 then C=~10
if A=80 and B=20 then C=~5
Last edited on
I'm thinking something parabolic where the vertex of a downward-facing parabola. Something like: y = -(x - midpoint_x)^2 + midpoint_x^2. It would give you something very regular, but it would be a start.
That's exactly what I was thinking but I don't remember writing that in the other program. Let me check that equation... It goes a little high, the equation -0.05(X -midpoint_x)^2+max_y is better suited. Just to let you know, xmin=0, ymin=0, xmax=94 and ymax=62 so -0.05(X-47)^2+62 is the fitting equation.

Thanks but I'm not sure if using parabolas will work but it's a great way of visualising what I'm trying to do.

After some experimentation, I have found a definite point using the equation, I will edit the post to reflect this:


if A=47 and B=31 then C==23

It HAS to be 23, not approximately.
Last edited on
Never mind, I don't need the solution anymore, I'll draw something else.
Topic archived. No new replies allowed.