Sine wave output generation
I am doing a project, and currently stuck at middle of c++ programming. I am anticipating an output which the value is fluctuating between -1 and 1, just as sine wave. The software I am using is Microsoft Visual Studio.
To cut it short, I will roughly jot down the important part of my program code:
I suppose other parts of my programming is running fine, because I am doing the robot simulation based on Open Dynamics Engine, and the robot runs fine with simpler code.
#include <cmath> //header to retrieve trigonometry function
int x = 0;
long double rad = 0;
long double sin (long double y)
long double result;
rad = (x/180) * M_PI; //(M_PI is defined as 3.14159) convert degree to radian
result = sin (rad); // the result will show the sine wave
x += 1;
if (x = 361)
x = 0; //x is the value of angle which increase from 0 to 360, then back to zero again, thus formed a loop
The only problem faced at the moment is the sine function. Please provide me some advise for the situation above, Thank you very much.