#include using namespace std; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< vx, vy; REP(i,t){ double x = 1.0, y = 0.0; FOR(j,i+1,t){ double nx = x - omega*y + v*x; double ny = y + omega*x + v*y; x = nx; y = ny; } vx.push_back(x); vy.push_back(y); x = 0.0, y = 1.0; FOR(j,i+1,t){ double nx = x - omega*y + v*x; double ny = y + omega*x + v*y; x = nx; y = ny; } vx.push_back(x); vy.push_back(y); } double sx = 1.0, sy = 0.0; REP(i,t){ double nx = sx - omega*sy + v*sx; double ny = sy + omega*sx + v*sy; sx = nx; sy = ny; } double ax = gx-sx, ay = gy-sy; m = 2*t; // Ax = b REP(i,m)A[0][i] = vx[i]; REP(i,m)A[1][i] = vy[i]; b[0] = ax; b[1] = ay; // AAT = AA^T REP(i,2)REP(j,2)AAT[i][j] = 0.0; REP(i,2)REP(j,2)REP(k,m)AAT[i][j] += A[i][k] * A[j][k]; // AAT y = b double detA = AAT[0][0] * AAT[1][1] - AAT[0][1] * AAT[1][0]; AATinv[0][0] = AAT[1][1] / detA; AATinv[0][1] = -AAT[0][1] / detA; AATinv[1][0] = -AAT[1][0] / detA; AATinv[1][1] = AAT[0][0] / detA; // y = AATinv b yy[0] = AATinv[0][0] * b[0] + AATinv[0][1] * b[1]; yy[1] = AATinv[1][0] * b[0] + AATinv[1][1] * b[1]; // x = A^T y REP(i,m)xx[i] = A[0][i] * yy[0] + A[1][i] * yy[1]; // simulate double simx = 1.0, simy = 0.0; double power = 0.0; REP(i,t){ double ux = xx[2*i], uy = xx[2*i+1]; printf("%.40Lf %.40Lf\n", ux, uy); power += ux*ux + uy*uy; double nx = simx - omega*simy + v*simx + ux; double ny = simy + omega*simx + v*simy + uy; simx = nx; simy = ny; } // printf("(%.5f, %.5f) is goal, (%.5f, %.5f) is answer, power is %.5f(<= %.5f)\n", gx, gy, simx, simy, power, p); } int main(){ int n; scanf("%d",&n); while(n--)solve(); return 0; }