-
Notifications
You must be signed in to change notification settings - Fork 14
ASCIIGraph | Examples | Sin Wave
Mitch Talmadge edited this page Oct 2, 2017
·
3 revisions
This shows an example of plotting a sin wave using ASCIIGraph.
public class Example {
public static void main(String... args) {
// The series should be an array of doubles.
double[] sinWaveSeries = new double[120];
// Calculate the Sin Wave.
for (int i = 0; i < sinWaveSeries.length; i++)
sinWaveSeries[i] = 15 * Math.sin(i * ((Math.PI * 4) / sinWaveSeries.length));
// Plot and output the graph.
System.out.println(ASCIIGraph.fromSeries(sinWaveSeries).withNumRows(15).plot());
}
}
ASCIIGraph
ASCIITable