ripple / spherical wave
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
What you want is
z = sin(r)
r is radius, so
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]
z = sin(r)
r is radius, so
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]
cplusasterisk, thanks for the reply. I will get working on that!
any working examples with source?
any working examples with source?
Here''s part of a C++ GLUT program I made a while ago:
DrawGraph does the OpenGl drawing, and ZFunction is the wave equation. anim_frame is a global variable that incremented each frame.
c+*
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+*
The spherical wave equation is given by
You can make a change of variables, v = ru, to give
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
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
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
********
A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement