#### Archived

This topic is now archived and is closed to further replies.

# ripple / spherical wave

This topic is 5744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Can anyone give me an insight on how to simulate a ripple? or help me find and article about "spherical wave equation". I understand that it is the equation to follow. thanks

##### Share on other sites
What you want is

z = sin(r)

z = sin(sqrt(x^2 + y^2))

If you want it to be animated, make t equal the frame number, and

z = sin( sqrt(x^2 + y^2) - t)

You can put some constants in there to change the shape or speed. For example, to slow it down

z = sin( sqrt(x^2 + y^2) - t*0.1)

c+*

[edited by - cplusasterisk on October 1, 2002 4:20:24 PM]

##### Share on other sites
cplusasterisk, thanks for the reply. I will get working on that!
any working examples with source?

##### Share on other sites
Here''s part of a C++ GLUT program I made a while ago:

void DrawGraph(int size){	int x, y;	GLfloat z;	glBegin(GL_QUADS);	for (int i=0;i	{		for (int j=0;j		{			x = i - (size/2);			y = j - (size/2);			// Draw one square			// something like this:			// (x,y)  (x+1,y)			//    a-----b			//    |     |			//    |     |			//    d-----c			// (x,y-1)(x+1,y-1)			// a			z = ZFunction(x,y);			glColor3f(1.0f, 0.0f, 0.0f);			glVertex3f(x,   y  , z);			// b			z = ZFunction(x+1,y);			glColor3f(1.0f, 0.0f, 1.0f);			glVertex3f(x+1, y  , z);			// c			z = ZFunction(x+1, y-1);			glColor3f(0.0f, 1.0f, 1.0f);			glVertex3f(x+1, y-1, z);			// d			z = ZFunction(x, y-1);			glColor3f(0.0f, 1.0f, 0.0f);			glVertex3f(x, y-1, z);		}	}	glEnd();}GLfloat ZFunction (GLfloat x, GLfloat y){	return 2 * cos (0.5 * sqrt(x*x + y*y) - 0.1 * anim_frame)}

DrawGraph does the OpenGl drawing, and ZFunction is the wave equation. anim_frame is a global variable that incremented each frame.

c+*

##### Share on other sites
The spherical wave equation is given by
utt = c2(urr + (2/r)ur)

You can make a change of variables, v = ru, to give
vtt = c2vrr

which is the familar 1D wave equation. Given appropriate intial conditions this can be solved with a variety of methods (although D''Alembert''s equation is usually the easiest).

Cheers,

Timkin

##### Share on other sites
its a lot more fun to make a sheet of springs, move any part in a sine shape for raindrop ripples, flag flapping etc. plus they can interfere and overlap.

********

A Problem Worthy of Attack
Proves It''s Worth by Fighting Back

##### Share on other sites
quote:
Original post by walkingcarcass
its a lot more fun to make a sheet of springs, move any part in a sine shape for raindrop ripples, flag flapping etc. plus they can interfere and overlap.

That would essentially be a simulation of surface (internal) tension which would ultimately generate the same (or very similar) effect. I guess it depends on personal preference as to which way you go... each is equally valid.

Cheers,

Timkin

##### Share on other sites
Thanks everyone for every bit of advice!

I am looking at a 2D grid plane to start with....what does height mean in terms of 2D view?

[edited by - veejay on October 3, 2002 5:07:33 AM]

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631431
• Total Posts
3000040
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!