# VisGraph: Visualization of Math functions

# VisGraph: Simple, Tiny, Visual

VisGraph API is a simple and tiny API for plotting standard math functions like **sin(), cos(), abs()** etc. that are provided by the **java.lang.math** package.

VisGraph implemens all methods as **static methods** so you can use them like the ones provided in java.lang.Math.

`//plot a sin curve in green given the points below`

double[] points = {2, 3, 4, 5, 6, 9, 12};

plotSin(points, BasicMath.TWO_PI, Color.green);

This plots a sin curve with the points given in a range of **TWO_PI** which is a constant of the class BasicMath in which plotSin() is defined.

With VisGraph you can plot i.g. a line that is defined as a **Vector** or as **Points**.

`//plot a line defined as two points in blue`

Point2D one = new Point2D(2, 4); //define a Point

Point2D two = new Point2D(3, 1); //another point

plotPoint2D(one, two, Color.red);

There are similar methods for Vector types:

`//plot a line defined as two vectors`

Vector2D x = new Vector2D(3, 1);

Vector2D y = new Vector2D(2, 1);

plotVector2D(x, y, Color.blue);

Since all methods are static you can call them in your app without any object. VisGraph uses the Java 2D API methods for drawing the plots so its a bit limited to Java 2D capabilities.

- Login or register to post comments
- Printer-friendly version
- alexanderschunk's blog
- 1273 reads