Reputation: 315
How to draw an image (of any type, png, jpg, bmp etc) of a Sine wave knowing frequency with amplitude = 1
?
Example:
Upvotes: 0
Views: 1534
Reputation: 7529
One option is to use AndroidPlot
. Firstly add it to your dependencies:
dependencies {
compile "com.androidplot:androidplot-core:1.4.0"
}
Add an XYPlot
to your layout and then start by amending the following example
More specifically have a look at:
public Number getY(int series, int index) {
if (index >= SAMPLE_SIZE) {
throw new IllegalArgumentException();
}
double angle = (index + (phase))/FREQUENCY;
double amp = sinAmp * Math.sin(angle);
switch (series) {
case SINE1:
return amp;
case SINE2:
return -amp;
default:
throw new IllegalArgumentException();
}
}
And try changing sinAmp
to your desired value.
Upvotes: 2