**~350-400**ms first time! After that I get a bit

**~60-32ms**! I want less! I feel, it cant be done, but i don't have any ideas any more, how to do that.

P.S:(I'm not a programmer(as maybe obvious), but drop-out psychology student (please don't laugh), just have a big interest in Computers and Programming). *Pardon my English please, I'm from cold Europe.

#include <cmath> #include <chrono> #include <vector> #include <iostream> #include <string> using namespace std; typedef unsigned long int uLint; const float PI = M_PI; struct fpa{ float* vX; float* vY; uLint sz = 0; }; /* // Unfortunately I didn't save actual first version, (did Ctr+S all the time:( ) * // but(except few calls to convert angle and do something else) it was dumber and (even) more naive than something like this: vf compass_VecPair(const float radius, float angle){ angle = fmodf(angle, 360.0f); //check angle. vf result; result.push_back( radius * (sinf( (angle*PI)/180.0f )) ); // A side length. Changed from: sin( degs_toRads(angle) ) result.push_back( sqrtf( (radius*radius) - (result[0] * result[0]) ) ); // B side length. result[1] = (angle > 90.0f && angle < 270.0f) ? -result[1] : result[1]; return result; } */ // Current version: // remember DON'T PASS END_ANGLE > 360.0. fpa compass(const float radius, const float start_Angle, const float end_Angle, const float angle_Step){ const uLint n_sz = uLint((end_Angle - start_Angle) / angle_Step); float* tmp_Ar = new float[n_sz]; float tmp_compArr[n_sz]; tmp_Ar[0] = start_Angle; tmp_compArr[0] = start_Angle; uLint i = 1; for(; i < n_sz; ++i){ tmp_compArr[i] = angle_Step*i; tmp_Ar[i] = sinf(( tmp_compArr[i] * PI) / 180.0f); } for(i=0; i < n_sz; ++i){ tmp_Ar[i] *= radius; } const float r = radius*radius; float* tmpY = new float[n_sz]; for(i=0; i < n_sz; ++i){ tmpY[i] = sqrtf( r - (tmp_Ar[i] * tmp_Ar[i]) ); tmpY[i] = (tmp_compArr[i] > 90.0f && tmp_compArr[i] < 270.0f) ? -tmpY[i] : tmpY[i]; } fpa result; result.sz = n_sz; result.vX = tmp_Ar; result.vY = tmpY; return result; } const string stars_str = "\n***************************************\n"; const string time_MS_str = "Time spent (ms) -----> \t"; const string time_SEC_str = "\nTime spent (sec)-----> \t"; const unsigned int RUNS = 10; const unsigned int CYCLES = 10001; float sum = 0.0f; vector<fpa> v; int test_Compass(){ using std::chrono::system_clock; auto t1 = chrono::steady_clock::now(); for(unsigned int i=1; i < CYCLES; ++i){ v.push_back( compass(float(i), 0.0f, 360.0f, 1.0f) ); }; auto t2 = chrono::steady_clock::now(); cout << time_SEC_str << chrono::duration_cast<chrono::seconds>(t2 - t1).count() << endl << time_MS_str << chrono::duration_cast<chrono::milliseconds>(t2 - t1).count(); return int(chrono::duration_cast<chrono::milliseconds>(t2 - t1).count()); } int main(){ for(unsigned int i=0; i < RUNS; ++i){ sum += test_Compass(); } cout<< "\nRuns: "<< RUNS << "; Cycles per run: " << CYCLES-1 << endl << "\tAverage time (ms): " << sum/RUNS << endl; return 0; }

Quote

want less! I feel, it

*cant*be doneI meant it

**CAN**be done! *misspell.