For one, sin takes radians as argument, not degrees, so a random angle should not be between 0 and 360 degrees. I know this because the program
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
cout << sin(30) << endl;
return 0;
}
returns -0.988032, not 0.5.
Furthermore
(double)rand() / (RAND_MAX * 2)
produces a random number between 0 and 0.5, not between 0 and 1. This is because rand() "returns a pseudo-random integral number in the range between 0 and RAND_MAX."