Slashdot Mirror


Writing Code for Surface Plots?

MySchizoBuddy asks: "In what ways can you code plots of surface charts using a z(x,y) function or a cloud of points? I'm looking for a tutorial that explains this that doesn't use DirectX or OpenGL libraries (the language I'm using cannot use either framework anyway). How is the 3D mess generated and how can the 2D contour plots be generated as well? I'm assuming once I know that I can also use it to make torus plots as well. Remember, I'm asking for the explanation of the underlying math and an example code that does that. The GNUPlot gallery has some examples that I find helpful, but are there similar examples out there? (Remember, I am writing the plotting code as well)? Can anyone help or point me in the right direction?"

1 of 81 comments (clear)

  1. I just hacked something up myself by lakeland · · Score: -1, Offtopic


    Create an array 1000x1000 or whatever depending on the resolution you want your final plot to be
    Calculate the x,y point.
    Scale that point to an x',y' point in the graph (1000x1000 or whatever)
    Add one to every point near point near x',y'. If you're feeling flash, give a weighting to closer points.
    Save the resulting array to a file
    plot the resulting array using your favourite plotting tool (I used gnuplot).

    The whole thing was just a couple hundred lines of C. I imagine it would've been easy to make it shorter if there had been a need. A good chunk of that code is the curses progress 'bar'