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?"

4 of 81 comments (clear)

  1. R-project by Anonymous Coward · · Score: 3, Insightful

    Check out the R-project at www.r-project.org. It is very good for that sort of thing.

  2. See what you can come up with by Geccie · · Score: 2, Insightful

    If its a very small part of a larger program, then look for some good examples and try to trudge through getting it to work. Otherwise, start writing code and examine the visual output of the screen. Look for algorithms and methods for producing the output you want. When you begin to understand them, you can integrate the concepts into your solution.

    Unfortunately, even if you have an API, you still have to understand what it does and how to interact with it. Many people believe that modular programming simply means using code alrealy written. This is a false premise as there is no substitute for some degree of understanding.

    In the end, you may wish to use a public library because it is highly accurate, optimized, well researched, or portable, but by that time you will have the knowledge to understand why you are selecting the particular library.

  3. Statistics and Data Analysis in Geology by Davis by Anonymous Coward · · Score: 1, Insightful

    I actually understand your question and the first place to look is a book Statistics and Data Analysis in Geology" by Davis. I used it in graduate school back in the 80's. It has understandable code for generating this output. It starts with line printer plots to get you running, first with trend fitting the data, and then actually machine contouring the data. I used their examples to program my C64 do draw contour maps on the 1526 plotter. I have tried surface plots with Excel off and on and it is frustrating because the mindset of the Excel developers is in a different universe. Google around for COGS Computer Oriented Geological Society, they may have some of the source as FORTRAN in their archives.

    If you have $$$$.00 to through at the problem use IDL from Research Systems Inc. They just got bought by someone so you will have to Google for their new digs. Expect to pay three kilo-bucks.

    Gridding is a cool problem. Basically, you start at (0,0) and calculate the distance of each point to (0,0) and then sort by that distance. Then you take the nearest every how many points and fit a trend and get the value at (0,0),. next you do (0,1) and calculate distances, sort, estimate the value, move to (0,2) ... (0,n) and then start with the next row, (1,0), (1,1),(1,2)...(1,N). Keep going down the rows.

    Next you have to decide bottom contour line value, top contour line value, and contour interval. Code as if you are a pen plotter. Look at the values of each corner of each grid cell, one at a time, and if a contour line goes through that side connect it to where it crosses the other side. This requires a lot of logic that is beyond this scope but reply to me and we can get deeper if you need.

    The Commodore 64 would grid all weekend, but did a decent job of making plots and maps. Core was cheep back then.

  4. Re:Another view by Anonymous Coward · · Score: 1, Insightful

    Totally cock-sure of the fallacy that no one has ever thought up of your superb ideas before you, eh? I used to be like that. Especially with anything as 'brilliant' as using group theory in place of floating point values. Whoopie.

    Okay, so I don't mean to be that harsh - we still need people like you with that sort of talent ... but only after you get a fresh perspective on exactly what constitutes originality. It appears you're still learning, so we shan't be too hard on your optimism. We'll be waiting when someone asks Slashdot about Bayesian networks and associative memory.

    "Brilliant!" cried I.
    "Elementary," said Holmes.
    Ah, Sir AC Doyle.

    My point - this user who asked the question wanted to re-invent the wheel, but at least he knows he's re-inventing it.

    Give the world of programming some credit, young Tiger.

    Yours truly,
    Mr Trolley of Trolls Inc.