Pages

Friday, 8 March 2013

3D Graph Plotter

3D Graph Plotter


It's been quite a long time since my last blog I agree. I did have to complete my high school after all. However, my non-blog time wasn't wasted. I had been involved during this time developing a few programs for my annual school project. The one that I wish to show here is a 3d Graph Plotter called Visual3D (as I named it). It's purely written in Java and the source is JDK v6 compatible.

3D Graph Plotter in Visualization

Graph Plotters are typically used to create a visual representation of a mathematical equation. In doing so, the relationship between the given variables is better understood.
A 3d Graph Plotter is generally concerned with 3 variables – x, y, and z. Where, z is a function of x & y. In formal terms z = f(x, y). The 3 variables are plotted along the 3 axes in space. The result of such functions is always a 3d surface varying in height, in the z axis.

The given program can be used to plot any mathematical function in 3d. The complete set of the functions supported are:

  • Trigonometric
    • sin()
    • cos()
    • tan()
    • asin()
    • acos()
    • atan()
  • Arithmetic
    • sqrt()
    • cbrt()
    • log()
    • ln()
  • Miscellanious
    • floor()
    • ceil()
    • abs()
    • sign()

Supported constants
  • PI
  • E
Supported variables
  • x
  • y
Supported operators
  • +
  • -
  • *
  • /
  • ^
  • %

Program Structure Overview

The program contains a total of 19 classes which are packaged and structured as below:

  • package visual3d
    • class Visual3D (Main Class)
    • package core
      • class Resource
      • package mexparser
        • class Constants
        • class Expression
        • class Lexer
        • class Parser
        • class Solver
        • class Token
        • class TokenTable
      • package utility
        • class Coefficients
        • class Edge
        • class Face
        • class Render3D
        • class Vector3D
      • package visual
        • class Function
        • class Model
        • class Plotter
        • class Screen
        • class View


A few screenshots:

(sin(x^2) * cos(y^2)) / 3
(x^3*y - y^3*x) / 40
*Update*
I considered adding a few more features for the program.
  • Gradient mapping
  • Added custom theme support
  • View transitions using Numpad(0, 1, 3, 7)

Links point to the new version of Visual3D.

Executable
Source Code