3D math function

Does anyone help me with making a 3D function z=sin(x+t)+cos(y+t), where ‘t’ is changing time, and where you can change a density of the triangle mesh? I’m very beginner and don’t know how to solve this problem. :* to all

some pseudo code to outline the idea :

// example spacing of the grid
delta = 1.0
t = time

for x starting at 0 ending at XMAX, delta spacing {
 glBegin(GL_QUAD_STRIP)
  for y starting at 0 ending at YMAX, delta spacing {
   glVertex3d(x+t,y+t,sin(x+t)+cos(y+t));
   glVertex3d(x+t+delta,y+t,sin(x+t+delta)+cos(y+t));
  }
 glEnd();
}

And next time, just do your homework. There is plenty of doc everywhere for such a basic setup.

I guess what you mean is to make an application that visualizes such function, right?

If you’re new to OpenGL, start with nehe tutorials:
http://nehe.gamedev.net

If you need specific suggestions for your application you would have to provide a bit more detail. Is it an application where user can rotate view or change density of triangle grid in realtime? How large grids do you need? Is performance important?

And next time, just do your homework. There is plenty of doc everywhere for such a basic setup. [/QB][/QUOTE]

"And next time, just do your homework. There is plenty of doc everywhere for such a basic setup. "

This is really my homework:) and no time to learn about it ;(
Thanks for the code, I will try to do something with this clue.

Originally posted by k_szczech:
[b] I guess what you mean is to make an application that visualizes such function, right?

If you’re new to OpenGL, start with nehe tutorials:
http://nehe.gamedev.net

If you need specific suggestions for your application you would have to provide a bit more detail. Is it an application where user can rotate view or change density of triangle grid in realtime? How large grids do you need? Is performance important? [/b]
Yes, I have to do something that will visualizes this function, the most important is to change density of triangle grid in realtime using keyborad.

Czy ktoś wykonałby taki projekt? Najlepiej z Warszawy.

Originally posted by zuleja:
[b] "And next time, just do your homework. There is plenty of doc everywhere for such a basic setup. "

This is really my homework:) and no time to learn about it ;(
Thanks for the code, I will try to do something with this clue. [/b]
Well then, I suppose the next suggestion is Next time, do your homework sooner. :wink:

OK, This is what I would do:

#define DENSITY 50
#define DENSITY_STEP 1.0/DENSITY
#define LATTICE_WIDTH 10.0

for(i = 0; i < 1.0/(float)DENSITY; i++){
    glBegin(GL_TRIANGLE_STRIP);
    glVertex3f(LATTICE_WIDTH*i, LATTICE_WIDTH*(j+DENSITY_STEP), sin(LATTICE_WIDTH*i + t) + cos(LATTICE_WIDTH*(j+DENSITY_STEP) + t));
    glVertex3f(LATTICE_WIDTH*i, LATTICE_WIDTH*j, sin(LATTICE_WIDTH*i + t) + cos(LATTICE_WIDTH*j + t));    
    for(j = 0; j < 1.0/(float)DENSITY; j++){
        glVertex3f(LATTICE_WIDTH*(i+DENSITY_STEP), LATTICE_WIDTH*(j+DENSITY_STEP), sin(LATTICE_WIDTH*(i+DENSITY_STEP) + t) + cos(LATTICE_WIDTH*(j+DENSITY_STEP) + t));
        glVertex3f(LATTICE_WIDTH*(i+DENSITY_STEP), LATTICE_WIDTH*j, sin((i+DENSITY_STEP) + t) + cos(j + t));        
    }
    glEnd();
}

hope it helps(and that I wrote this correct…)! And…Do your homework next time!

Ow, define i and j as floats!OK, I wrote this in a hurry but I hope you get the idea