Keiichi Tsuchiya the Drift King Gym - 102028D(计算几何)

Drifting is a driving style in which the driver uses the throttle, brakes, clutch, gear shifting and steering input to keep the car in a state of oversteer while manoeuvring from turn to turn. As a sport, the drifting was first practised in Japan in the late 80s before gaining worldwide popularity in the decade that followed.

Keiichi Tsuchiya is a Japanese driver who is better known as the Drift King. He played an important role in popularizing the art of drifting. This pioneer inspired many successful drivers. He appeared in the movie The Fast and the Furious: Tokyo Drift and he is often employed on various movie sets as both driver and stunt coordinator. Keiichi Tsuchiya’s talent in the drifting is especially true of his big stunt, the ultimate drifting.

Here is what he could do. The drift car he drives is shaped like a rectangular box of width aa inches and of length bb inches. He makes a right turn of a curve whose internal boundary is an arc with dd degrees in a circle with a radius of rr inches. As a super-skilled driver, he maintains his car to keep the contact and tangency at the internal boundary. That is, the right front corner of the car should always run along the internal boundary and the direction of the car body should always be tangential to the internal boundary.
在这里插入图片描述

We have measured that the straightaways before and after the curve are long enough, and the width of the lane is invariable. As what we meet in real life, if a lane has a fixed width, for each point of its one side, the distance to the nearest point of the other side is exactly its width. Now you are asked to calculate the minimal width ww of the lane so that the Drift King could drive throughout the curve without drifting out of the lane.

Input
The input contains several test cases, and the first line contains a positive integer TT indicating the number of test cases which is up to 104104.

For each test case, the only one line contains four integers aa, bb, rr and dd, where 0<a,b,r<1000<a,b,r<100 and 0<d<1800<d<180.

Output
For each test case, output a line containing the minimal width (in inches) of the lane with an absolute or relative error of at most 10−610−6. Precisely speaking, assuming that your answer is aa and the jury’s answer is bb, your answer will be considered correct if |a−b|max{1,|b|}≤10−6|a−b|max{1,|b|}≤10−6.

Example
Input
4
1 2 2 120
1 2 2 60
1 2 2 30
1 2 2 15
Output
1.605551275464
1.605551275464
1.598076211353
1.415415569072
比较恶心的一道计算几何题目,把模型抽象出来就很简单,但是画图实在是太差了。。。
分为两种情况:第一种再出圆弧的时候恰左上角恰好擦着边在这里插入图片描述
第二种情况:在这里插入图片描述
代码如下:

#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
using namespace std;

double a1,b1,r1,jd;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lf%lf%lf%lf",&a1,&b1,&r1,&jd);
		double x1=(b1)/(a1+r1);
		if(x1<tan(jd*pi/180.0)||(x1>0&&tan(jd*pi/180.0)<0))
		{
			double xx=sqrt((a1+r1)*(a1+r1)+b1*b1)-(r1);
			printf("%.12lf\n",xx);
		}
		else
		{
			double Sin=sin(jd*pi/180.0);
			double Cos=cos(jd*pi/180.0);
			double xx=a1*Cos+b1*Sin+r1*Cos-r1;
			printf("%.12lf\n",xx);
		}
	}
}

努力加油a啊,(o)/~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

starlet_kiss

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值