-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhorizontal.cpp
More file actions
48 lines (38 loc) · 1.08 KB
/
horizontal.cpp
File metadata and controls
48 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Function to represent Horizontal Sine Wave
*/
void SineWave :: horizontalWave ()
{
reset(); //reset the values
//empty spaces to every location in array
for(row = 0; row <= sineHeight; row++)
{
for(column = 0; column <= sineWidth; column++)
sine[row][column] = ' ';
}
//to draw x-axis of graph
for(column = originX; column <= originX + sineWidth1; column++)
{
row = originY;
sine[row][column] = '-';
}
//to draw sine wave
pointStartX = graphStart;
for(int sineWaveX = originX; sineWaveX <= originX + sineWidth1; sineWaveX++)
{
double sineWaveY = sin(pointStartX);
double sineWaveY1 = - sineWaveY * (( middleOfGraphHeight / 5 ) * scalingFactor ) + originY;
int sineWaveY2 = round(sineWaveY1);
sine[sineWaveY2][sineWaveX] = '*';
pointStartX += unitStepX;
}
//Print the complete array
for(row = 0; row <= sineHeight; row++)
{
for(column = 0; column <= sineWidth; column++)
{
cout<<sine[row][column];
}
cout<<"\n";
}
}