-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvertical.cpp
More file actions
50 lines (38 loc) · 1.1 KB
/
vertical.cpp
File metadata and controls
50 lines (38 loc) · 1.1 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
48
49
50
/*
Function to represent Vertical Sine Wave
*/
void SineWave :: verticalWave ()
{
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(row = originY; row <= originY + sineHeight1; row++)
{
column = originX;
sine[row][column] = '|';
}
//to draw sine wave
int sineWaveY = originY;
for(double sineWaveX = graphStart; sineWaveX <= graphEnd; sineWaveX += unitStepY)
{
double pointStartX = sin(sineWaveX);
double pointStartX1 = pointStartX * ( ( middleOfGraphWidth / 5 ) * scalingFactor ) + originX;
int pointStartX2 = round(pointStartX1);
sine[sineWaveY][pointStartX2] = '*';
sineWaveY++;
}
//Print the complete array
for(row = 0; row <= sineHeight; row++)
{
for(column = 0; column <= sineWidth; column++)
{
cout<<sine[row][column];
}
cout<<endl;
}
}