c++ problem, maybe with types...
- by Infinity
Hi guys!
I have a little problem in my code. The variables don't want to change their values. Can you say why?
Here is my code:
vector<coordinate> rocks(N);
double angle;
double x, y;
// other code
while (x > 1.0 || x < -1.0 || y > 1.0 || y < -1.0) {
angle = rand() * 2.0 * M_PI;
cout << angle << endl;
cout << rocks[i - 1].x << endl;
cout << rocks[i - 1].y << endl;
x = rocks[i-1].x + r0 * cos(angle);
y = rocks[i-1].y + r0 * sin(angle);
cout << x << endl;
cout << y << endl << endl;
}
// other code
And the result on the console is:
6.65627e+09
0.99347
0.984713
1.09347
0.984713
1.16964e+09
0.99347
0.984713
1.09347
0.984713
As you see the values of x, y variables doesn't change and this while be an infinity loop. What's the problem? What do you think?