#include using namespace std; #define fi first #define se second #define pii pair #define bend(v) v.begin(),v.end() #define vect vector #define prq priority_queue #define umap unordered_map #define eb emplace_back #define pb push_back #define pob pop_back #define ef emplace_front #define pf push_front #define pof pop_front #define el "\n" #define deb cout<<"\nok\n";return #define nextl cout<<"\n" #define lwb lower_bound #define upb upper_bound #define rs resize #define popcnt __builtin_popcountll #define clz __builtin_clzll #define ctz __builtin_ctzll #define ull unsigned long long #define ll long long #define dbl long double #define FILE "ijustwannabepartofyourskibidi" void IO(){ if(fopen(FILE".in", "r")){ freopen(FILE".in", "r", stdin); freopen(FILE".out", "w", stdout); } else if(fopen(FILE".inp", "r")){ freopen(FILE".inp", "r", stdin); freopen(FILE".out", "w", stdout); } } const ll N = 1e5 + 10, MOD = 1e9+7, INF = 1000000000000000069; mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rand(ll l, ll r){ return uniform_int_distribution(l, r)(rng); } ll pm(ll a,const int b=MOD){return (a%=b) < 0 ? a + b : a;} ll sq(ll x){return x*x;} ll __lcm(ll a, ll b, const ll lim=LLONG_MAX){ if(a == -1 || b == -1)return -1; ll g = __gcd(a,b); if(b/g > lim/a)return -1; return (a/g)*b; } const dbl PI = acosl(-1); struct Matrix{ dbl mat[3][3]; Matrix(){ memset(mat, 0, sizeof mat); } auto &operator [](int id){return mat[id];} const auto &operator [](int id)const{return mat[id];} void make_identity(){ memset(mat, 0, sizeof mat); mat[0][0] = mat[1][1] = mat[2][2] = 1; } Matrix operator * (const Matrix &o) const{ Matrix res; for(int i=0; 3>i; i++){ for(int j=0; 3>j; j++){ for(int k=0; 3>k; k++){ res[i][k] += (mat[i][j] * o[j][k]); } } } return res; } }; struct Vector{ dbl vec[3]; Vector(){memset(vec, 0, sizeof vec);} auto &operator [](int id){return vec[id];} const auto &operator [](int id)const{return vec[id];}; Vector operator * (const Matrix &o) const{ Vector res; for(int j=0; 3>j; j++){ for(int k=0; 3>k; k++){ res[k] += vec[j] * o[j][k]; } } return res; } }; int n, q, masks[N]; Matrix a[N], sus[N][20]; void dnc(int l, int r, int dep){ if(l == r) return; int mid = (l + r) / 2; sus[mid][dep] = a[mid]; sus[mid+1][dep] = a[mid+1]; for(int i=mid-1; i>=l; i--) sus[i][dep] = a[i] * sus[i+1][dep]; for(int i=mid+2; r>=i; i++) sus[i][dep] = sus[i-1][dep] * a[i]; for(int i=mid+1; r>=i; i++) masks[i] ^= 1<> n; for(int i=0; n>i; i++){ dbl p, q, theta; cin >> p >> q >> theta; theta = theta / 180.0l * PI; // cout << theta << ' ' << cosl(PI) << el; auto &mat = a[i]; mat[0][0] = cosl(theta); mat[1][0] = -sinl(theta); mat[2][0] = -p*cosl(theta) + q*sinl(theta) + p; mat[0][1] = sinl(theta); mat[1][1] = cosl(theta); mat[2][1] = -q*cosl(theta) - p*sinl(theta) + q; mat[0][2] = mat[1][2] = 0; mat[2][2] = 1; // for(int i=0; 3>i; i++) for(int j=0; 3>j; j++){ // cout << mat[i][j] << " \n"[j==2]; // } // nextl; } // return; dnc(0, n-1, 0); cout << fixed << setprecision(6); cin >> q; while(q--){ int l, r; cin >> l >> r; l--, r--; dbl x, y; cin >> x >> y; Vector v; v[0] = x, v[1] = y, v[2] = 1; if(l == r) v = v * a[l]; else { int dep = __builtin_ctzll(masks[l] ^ masks[r]); v = (v * sus[l][dep]) * sus[r][dep]; } cout << v[0] << ' ' << v[1] << el; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL); IO(); int t = 1; // cin >> t; while(t--) sol(); } /* ...-%%%%%%%%%%%... .:**#%=%%%%%+........-%%%%. . .%%%%%%=-..%#. .#%%. %%%+.. .: *%%. .%%. :. :%%%%%:. .%%. ... .: :: .=%%%. ..%%. #%#:%. : :.. =%%. %%+..: .%*::::%-::::::-::::::.. .:-%%%%. .*%%.. .%# :.%:::::::%%%%%%%%%%%%%+...%%%+::::%#. .%%. .%%. ..:.%=::::*%#***#%::::::::%%%%=:::::::%%. .%%. =%%%...-%%%:::*%********%:::%%%****%::::::::%% .%- .%::::%%***%=:%%**********%%********%:::::::=%-:. .%.. #%:::%#*****%%**********************%:::+%%%*%%-.: .::..%%. .%%::%%*****==**==*****#************#%%%%#******%%..::::.. .%%. .%%#%+%%***************##*+=+*==********************%%.:. .%% .%%***%%****************#**==**==******==**+=+********%%%%%%%%% %%. .#%#*********************%%**************++************%%::::::%* .%%%. .%%***************#*****%%%****************************%%::::::%% .-%%%. .#%***************#****%%--%*********%*****************%#::::-%%%%%%%%%%. .%%**************#**%%%----%********%%**************#***#%%%#**%#******%* .%%**************#%%%--.....%%*******%%**************#**********#%******%%. .%%*************%%...........%%******%-%*************#***********%%*****%%. .%%*************%%...%%%%%.....%%%%%%%.=%%%%%%%%##****#****##::::+%%*****%# .%%************%%...%. %%.................%%%%-.....%*****#*****%%*****%% .#%#*#****#****%%:::%- %%.................%. #-....%*****#*#####%#****%%. .%%##****%%%**%%:::::##...................%= .%+:::%#*****#:####*%%****%%. .+%%#**%%.#%%%%::::::........###+.:*##-....%%%:::::%*****##******%%****%%- ..%%*%%.......:::.......##..#*...#+..#*....:::::%******#*****##%%*****%%. .%%%%%................#-##=--##+-+###-#....:::%******#:###*::%%#*****%%. .%%****%%..............#----------------=*...#%#****##**##::#**%%*******%%. .%%%%%*=+%%*...........#-----------------#.....#%%%%%%+:##*##:*%%*******%%%. ..:*%====%%%%........#-----------------#:.........%#********%%*****%%%%%%. .%%=======*%%%%%%%.%%+----#-%------%%#.......%%%%::::::::%%==***#%###%%. ..%%=============+%%-:#%%%%-::%%%%%%::%%%%%%%%%=%%*******%%=====**%%###%%.. -%%%%%%%%%%%%%%%%+%.%+:+%::%::::%::%:::%%#%... .%%******%%%========#%####%%. .%%++#############%%# ..%%.**%%#%%%%%%%#%***%. :%%*****%%%=+%%%%%%%%%%#####%%. .%%++++*############*++% .%************#****%. #%*%%%%+++%%%%###############%%. .+%%%%%%%%%%####+##########*+++++%%. .%**#**********#****% %%**%%%++++###################%: =%%%%######################++++++++%%*%.-%%#***********#****% .%****%%+++++###################%% .%%%#######################*%%%%%%%%.%%*#%+%###################%.%%***%%%+++++###################%% *%%######################+#%%++++++%*. =%*%. .:%%%%########%%%%%%%%%#*#%.%%++#####################%% .%%%#####################%%%%%+++++++%- %*#%%. .%%%*++++++*%%%....%%#####################%%* %%######%%%%%#%%%%%######%%.%*+++++++%. %****#. .%%+++*+++++*++%%...=%%###################%%%. %%%%%%%%#-=##%...%%######%%.%%+++++++%%..*%***#%%%%%. ..%+++++++++++++++%%...%%##################%%%. .%:. .#%#####%%.%%+++++++++%. %*********%%%%%++++++++++++++++%%...%%##############%%%%.. :%#####%% .%%+++++++%% .%%**********%%++++++++++++++++%%.....%#########%%%%%% . *%#####%%. .%%+++++++%%:. .%%********%%++++++++++++++++%%....%%%%%%%%%%%%*.. .%%##%%% .%%*+++++++%%. ..#%%%#****%%+++++++++++++++%%%%%% . ..... %%#%%%. .:%%%%%%%%%%%...-%. ......%%+++++++++++++%%. ..%%%. ... .%%%#%%%=:#%%%%%%%%*++++++%%%# .-%%+. ... .%%%%%%%:. */