题目大意
一个人在一个给定角度和半径的弯道漂移,规定漂移时右前轮必须紧挨弯道,问赛道的长度最小需要多长?
思路
这题写了将近四个小时,没出,原因是我们被上图的 d d d较大的情况蒙蔽了,当 d > α d>\alpha d>α求出来的结果之所以无论如何都不变是因为前侧连接圆心和左后轮连接圆心的角度是固定的,需要考虑 d d d较小的情况,具体解释参见以下博客
//
// Created by Happig on 2020/10/10
//
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ins insert
#define Vector Point
#define ENDL "\n"
#define lowbit(x) (x&(-x))
#define mkp(x, y) make_pair(x,y)
#define mem(a, x) memset(a,x,sizeof a);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double dinf = 1e300;
const ll INF = 1e18;
const int Mod = 1e9 + 7;
const int maxn = 2e5 + 10;
int T;
double a, b, r, d;
double ans;
int dcmp(double d) {
return d < eps ? 1 : 0;
}
double dis(double x, double y) {
return sqrt(x * x + y * y);
}
int main() {
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
//ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
scanf("%d", &T);
while (T--) {
scanf("%lf%lf%lf%lf", &a, &b, &r, &d);
d = d / 180 * pi;
double alpha = atan(b / (a + r));
if (alpha < d) {
ans = dis(b, a + r) - r;
} else {
double beta = alpha - d;
double l = 2.0 * dis(b, a + r) * sin(beta / 2.0);
double phi = (pi - beta) / 2;
double x = cos(phi) * l;
ans = dis(b, a + r) - x - r;
}
printf("%.10lf\n", ans);
}
return 0;
}