I would like to plot a surface defined by an implicit equation, i.e. f(x,y,z) = ax+by+cz-d

May I know how can I draw it? I would be grateful if you could tell me the algorithm.

I would like to plot a surface defined by an implicit equation, i.e. f(x,y,z) = ax+by+cz-d

May I know how can I draw it? I would be grateful if you could tell me the algorithm.

This is how I would do it:

- Solve the equation for z by assuming f(x,y,z)=0;

So in your case: z=(d-ax-by)/c; - Write 2 for loops:

```
for (double x=<x_start>; x<=<x_end>; x+=<evaluation_step>)
{
// This doesn't have to be a line strip, so you can make it
// anything that makes more sense to you - I just used line strip for simplicity.
glBegin(GL_LINE_STRIP);
for (double y=<y_start>; y<=<y_end>; y+=<evaluation_step>)
{
double z=f(x,y); // z=(d-ax-by)/c;
glVertex3f(x,y,z);
}
glEnd();
}
```

Thank you for the suggestion. However, I will need to perform trial and error on <x_start> and <x_end>.

Is there another method? I plan to generate arbitrary surfaces, which I do not know beforehand (so I can’t really have time for trial and error testing).

Let’s say you have the implicit surface f(x,y,z) = n, where n is some iso-value. The points in space where f(x,y,z) evaluates to n lie on the implicit surface. A reasonable, and popular, way of rendering such a surface is to sample the function on a grid and, thereafter, extracting triangles using the Marching Cubes algorithm. You will find lots of material available online on this topic.

The grid sampling is done by constructing a voxel grid, and evaluating the function at the corners of each voxel. It is possible to determine if the voxel contains one or more parts of the surface by checking its 8 corners. More details, as mentioned, available online.

T

Thanks for the info. Sorry, I’m a complete newbie. Can someone give me the C++ code, which does the plotting the implicit surface for me?