Programming
Plot3d is coded in C++, using the OpenGL rendering library for 3d graphing.
The surfaces are plotted by creating an equally spaced grid on a rectangular domain in R2, and applying the user supplied function to the points in the grid to determine points in R3. The grid size specifies the mesh of points over which the function to be graphed is evaluated. The x and y axes are divided uniformly with a default initial grid size of 25 by 25.
It is this grid surface that Plot3D depicts in graphing.
In many instances it's best to use triangles to render the surface;
- Since 3 points define a plane, we can be sure that the vertices are always coplanar.
- Triangles are always convex. OpenGL polygons always have to be convex.
- Triangles don't cross over themselves
The grid is rendered by using OpenGL's triangle strips . Using triangle strips can be faster by reducing the required vertex calls to the OpenGL library.
Plot3d uses the same scaling in each of the 3 dimensions ("isotropic scaling"). One drawback of "isotropic" scaling is that if there are large variations of scale in any one dimension some features of the plot may not be as easily viewable without adjusting the viewing window and possibly the grid size.
However this type of proportional look seems somewhat more faithful to the "real" look of the graph since proper scaling is always maintained by the program, still a computer generated image has problems being a totally true reprensentation of any one mathematical function.
Light effects were created by supplying the surface normal of each point in the grid to OpenGL after using a simple averaging method to calculate the normals for lighting.
Occasionally I'll receive an email asking about how the program needs this or that feature, actually it could use alot of features; however I'd like to keep the program small preferably < 500k.
It's not really meant to be a comprehensive graphing utility, but more a small quick to learn high fidelity surface grapher.
Also the bigger the program gets the longer it takes to download so for now I don't want to load it up with too much stuff.
But some of the most important changes I hope to make in the future are better axis labels and user choices of colour in the 3-d graphs, also the discontinuity code needs to be completely re-written it's a very confusing mess.
Plotting more than one function at the same time would be very nice also.
Home page
News
Projects
Links
Contact
About
