c++ - Array Value keeps adding calculated value to previous value of array -


my array keeps adding previous value of array value can out solve need calculated value not previous value added

here's portion of code calculates , sorts value:

 (int = 0; < arraysize; i++)         {              angle = random_angle(angle, step_size);               // compute initial speed, using selected angle.             xspeed = initspeed * cos(2 * pi * angle / 360.0);             yspeed = initspeed * sin(2 * pi * angle / 360.0);              //look windspeed             if (beaufort == 6)             {                 wind = random_speed(strong_breeze_lo, strong_breeze_hi, step_size);                 wave = random_wave(b6_wave_lo, b6_wave_hi, step_size);             }             else if (beaufort == 5)             {                 wind = random_speed(fresh_breeze_lo, fresh_breeze_hi, step_size);                 wave = random_wave(b5_wave_lo, b5_wave_hi, step_size);             }             else if (beaufort == 4)             {                 wind = random_speed(moderate_breeze_lo, moderate_breeze_hi, step_size);                 wave = random_wave(b4_wave_lo, b4_wave_hi, step_size);             }             else if (beaufort == 3)             {                 wind = random_speed(gentle_breeze_lo, gentle_breeze_hi, step_size);                 wave = random_wave(b3_wave_lo, b3_wave_hi, step_size);             }             else if (beaufort == 2)             {                 wind = random_speed(light_breeze_lo, light_breeze_hi, step_size);                 wave = random_wave(b2_wave_lo, b2_wave_hi, step_size);             }             else if (beaufort == 1)             {                 wind = random_speed(light_air_lo, light_air_hi, step_size);                 wave = random_wave(b1_wave_lo, b1_wave_hi, step_size);             }             else             {                 wind = random_speed(calm_lo, calm_hi, step_size);             }              //repeat following, long y-position greater equal wave height or speed in y-direction positive             while(ycoord >= wave || yspeed >= 0)             {                 //compute new positions                 xcoord = xcoord + xspeed * delta_t;                 ycoord = ycoord + yspeed * delta_t;                 //compute new speeds                 xspeed = xspeed - delta_t * drag * (xspeed + wind);                 yspeed = yspeed - delta_t * gravity - delta_t * drag * yspeed;             }              array[i] = xcoord;                 } 

 xcoord = xcoord + xspeed * delta_t; 

you adding previous value calculated value here

 array[i] = xcoord;      

and u assign array.

you might missing steps reset xcoord/ycoord etc


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -