Skip to content
This repository was archived by the owner on Dec 6, 2021. It is now read-only.

Commit 94d1395

Browse files
author
OverPoweredDev
committed
added sine encoder
Note: doesn't encode anything
1 parent f4e5b2a commit 94d1395

File tree

7 files changed

+89
-7
lines changed

7 files changed

+89
-7
lines changed

cpp_implementation/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
GPP = g++
2+
3+
FLAGS = -Wall -L $(SFML_LIB) -I $(SFML_HEADERS)
4+
LIBS = -lgraph
5+
6+
BIN = plotter
7+
8+
.PHONY: all plotter clean
9+
create:
10+
$(GPP) $(FLAGS) -o $(BIN) plotter.cpp $(LIBS)
11+
./$(BIN)
12+
13+
remove:
14+
rm -r ./$(BIN)
File renamed without changes.
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
GPP = g++
2+
3+
FLAGS = -Wall -L $(SFML_LIB) -I $(SFML_HEADERS)
4+
LIBS = -lgraph
5+
6+
BIN = plotter
7+
8+
.PHONY: all plotter clean
9+
create:
10+
$(GPP) $(FLAGS) -o $(BIN) plotter.cpp $(LIBS)
11+
./$(BIN)
12+
13+
remove:
14+
rm -r ./$(BIN)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <math.h>
2+
#include <graphics.h>
3+
#define PI 3.141
4+
5+
void drawAxes(int offset_x, int freq) {
6+
line(0, getmaxy() / 2, getmaxx(), getmaxy() / 2);
7+
for(int x = offset_x; x < getmaxx(); x += freq){
8+
circle(x, getmaxy()/2, 3);
9+
}
10+
line(offset_x, 0, offset_x, getmaxy());
11+
}
12+
13+
void sine_wave(double offset_x, double amplitude, double phase_shift, double time_period){
14+
double y;
15+
for (double angle = 0, x = offset_x; x < getmaxx(); x += 1, angle += 1) {
16+
//angle is in degrees, not radians
17+
// y = amplitude * sin((((360.0/151.0)*(angle + rads)) * PI / 180.0));(2*PI/time_period)*
18+
y = amplitude * sin((angle + phase_shift)*(2*PI/time_period));
19+
y = getmaxy()/2 - y;
20+
21+
putpixel(x, y, 2);
22+
delay(10);
23+
}
24+
}
25+
26+
int main() {
27+
//graph
28+
int gd = DETECT, gm;
29+
double offset_x = 100;
30+
31+
//assignment variables
32+
double rollnum = 49.0;
33+
int amplitude = 100;
34+
// double time_period = 360;
35+
// double rads = 0;
36+
double time_period = 200 - rollnum; // 151
37+
double rads = rollnum/20.0; // 2.45
38+
double phase_shift = rads*(time_period/(2*PI)); // 140.4
39+
40+
initgraph(&gd, &gm, nullptr);
41+
drawAxes(offset_x, time_period);
42+
sine_wave(offset_x,amplitude, phase_shift, time_period);
43+
44+
delay(1000);
45+
closegraph();
46+
47+
return 0;
48+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<graphics.h>
2+
3+
int main()
4+
{
5+
6+
initwindow(400, 700);
7+
8+
circle(250, 200, 50);
9+
10+
closegraph();
11+
12+
return 0;
13+
}

0 commit comments

Comments
 (0)