Skip to content

Repository files navigation

📐 MathPlotter – Project Tour

MathPlotter is a Java Swing desktop app for plotting mathematical functions, performing numerical analysis (integrals, intersections, derivatives, roots, etc.), and exporting results to SVG or JSON.


Architecture

The project follows a lightweight MVC structure:

  • Model → Function, GraphSettings, Point
  • View → MainFrame, GraphPanel, ControlPanel (with FunctionInputPanel, CalculationPanel)
  • Utils → MathParser, NumericalMethods, SVGExporter

📂 Key Files

  • Main.java → Entry point, launches MainFrame
  • MainFrame.java → Sets up the main window, menus, status bar
  • GraphPanel.java → Core canvas (draws grid, axes, functions, shaded areas, special points; supports pan/zoom/cursor snap)
  • ControlPanel.java → Sidebar controls (add/remove functions, zoom, analysis tools)
  • FunctionInputPanel.java → Enter functions, toggle visibility, assign colors
  • CalculationPanel.java → Run analyses (intersections, definite integrals, derivatives)
  • MathParser.java → Custom recursive-descent parser for math expressions
  • NumericalMethods.java → Intersections, integration (Simpson’s rule), derivatives, roots, inflection points
  • SVGExporter.java → Exports the current graph view as vector graphics

Expression Parsing

Expressions are parsed with a custom recursive-descent parser supporting:

  • Operators: + - * / ^
  • Parentheses and unary +/-
  • Constants: pi, e
  • Functions: sin, cos, tan, sqrt, abs, log, log10, exp, etc.
  • Variables: x

Example:

10 * sin(2*x) + log(2, x)

Parse Tree:

          (+)
         /   \
       (*)    (log base 2)
      /   \       \
   (10)   (sin)    (x)
           |
           (*)
          /   \
        (2)   (x)

Evaluates as:

f(x) = 10 * sin(2*x) + log(x)/log(2)

Features

  • Plot multiple functions with colors & visibility toggles

  • Pan, zoom, and reset view

  • Snap-to-curve cursor with live coordinates

  • Numerical analysis:

    • Intersections between functions
    • Definite integrals (shaded area)
    • Derivatives (auto-added as new functions)
  • Export graph as SVG

  • Save/load functions as JSON (including derivative chains)


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages