Jump to content
  • Advertisement
Sign in to follow this  

Efficient graph plotting techniques

This topic is 2882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody,

I've got a few questions concerning techniques to plot the graphs of functions.
I've written a bunch of libraries which can simplify algebraic equations and what not, and also evaluate user defined functions. When drawing these function however, I come accross several problems:

Right now I'm calculating a new y value say, every 3 pixels. This can take quite a while with longer functions, but still works rather fast since they are in RPN (postfix). Isn't there an easier/more efficient way to draw the graph? I imagine just calculating a few points and then interpolating the curve might work, but I don't know how prone to error that is.

I also have some problems when it comes to limits of functions. If I increase the step size dx for which I always calculate new y values, I might miss a limit, and the result of this can be seen in the second picture (the first picture is a close up):



In the second pic, the curve should go all the way out of window, so I'd need to determine a value y1, which will serve as a sort of boundary, after which everything else is interpreted as +/-Infinity. Any ideas?


Share this post

Link to post
Share on other sites
One option would be to differentiate the function and use that to graph the curve (c.f. the way many line-drawing algorithms and rasterization algorithms work).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!