Creating a Triagular Wave in Java
I was assign to do produce two graphs using Java. One is the Triangular Wave funtion that look like this:
Fourier Series Examples: Triangle Wave
and another for the half-wave rectifier.
The professor suggested us to used the Fourier Series to approximate the graph of the triangular wave by using that series. The function for the Fourier Series can be found here:
PlanetMath: common Fourier series
My big problem is that I don't have any experience whatsoever in graphing functions using Java. I would like some of you to please give me some suggestions ( where should I start, which java library should I look at, what method would you use).
I would really appreciate it.
Thanks in advance.
Re: Creating a Triagular Wave in Java
Unfortunately, I don't think there's any standard API support for graphing a function directly. However, it is fairly simple to write your own swing utility to plot data given to it. Create your own class that extends JPanel, give it a list of points, and have it plot the data it is given. To plot, over-write the paint method, and draw lines that connect a point with it's two neighboring points (note that to plot the point, you will have to convert the coordinates because the standard x-y access has 0,0 as bottom left, while in Java 0,0 is top left).
If your program must plot the data over any range and zoom, you can have your panel compute the data itself, and use the same data plotter to automatically update to the new graph.
There might be some API packages other users have created, in which case you can probably do a google search to find some.
Re: Creating a Triagular Wave in Java
Re: Creating a Triagular Wave in Java
Inadvertently double posted, removed.
db