Plotting implicit equations

Started by
13 comments, last by luca-deltodesco 14 years ago
Quote:Original post by nullsquared
If we calculate z=f(x,y) as a heightfield, we can just intersect it with the plane z=0 and the intersections give you the exact curve(s). This actually gives incredibly nice results for practically no effort:[...]


Do you mean that you,
1 - create a triangulated heightfield from your data
and then
2 - compute triangle-plane intersections to get a collection of line segments which approximate you curve?

If so, then what you're doing is mathematically identical to the triangle equivalent to marching squares (It is sometimes called "marching triangles," but a different surface triangulation algorithm is also sometimes called by this name too).

The only difference is that explicitly creating all the data structures necessary to store a triangle mesh in memory are somewhat costly, as are the general-purpose triangle-plane intersection functions (relative to the special case computed by the algorithm I referred to).
Advertisement
No, I just did a simple sign check on the heightfield, along the lines of:
foreach x    foreach y        if sign of { z[x-1][y] or z[x][y-1] or z[x-1][y-1] } is not the same as sign of z[x][y] then            plot(x, y)
Quote:Original post by nullsquared
No, I just did a simple sign check on the heightfield, along the lines of:
foreach x    foreach y        if sign of { z[x-1][y] or z[x][y-1] or z[x-1][y-1] } is not the same as sign of z[x][y] then            plot(x, y)


Oh, ok; I see. Yeah, that's very brute force. If I wanted to do this on the CPU, I'd probably adopt a better algorithm. But I think your method could make sense if implemented as a pixel shader on the GPU.

Also, FYI, since I see your level sets have multiple connected components, the methods I described earlier based on numerical continuation methods or the Hamiltonian system are inappropriate.
Quote:Original post by Emergent
Oh, ok; I see. Yeah, that's very brute force. If I wanted to do this on the CPU, I'd probably adopt a better algorithm. But I think your method could make sense if implemented as a pixel shader on the GPU.

Indeed, but this is for the CPU :/ This method isn't actually all that bad - I've yet to try the bilinear filtering trick, which I think would work great.

Quote:
Also, FYI, since I see your level sets have multiple connected components, the methods I described earlier based on numerical continuation methods or the Hamiltonian system are inappropriate.


Well, yeah, I'm going for something very general that can display just about anything you throw at it.
Marching squares algorithm is all you need here, it's certainly going to be a heck of a lot faster than your height field method :P

This topic is closed to new replies.

Advertisement