轉啊轉
Time Limit: 1000 MS | Memory Limit: 65536 KB |
Total Submissions: 59 | Accepted: 15 |
Description
動點初始時刻在圓的三點鐘方向(即與x軸正方向平行),並以逆時針方向繞圓轉。
Input
先輸入一個整數T,表示T(T<50)組數據。
每組數據一行七個實數a,b,r(r>0),x,y,w(w>=0),t(t>=0) 分別表示圓的圓心座標(a,b),半徑r,固定點座標(x,y),角速度w,要查詢的時刻t。
上述所有數據的絕對值小於10000。
Output
輸出答案佔一行,保留2位小數。
Sample Input
1 1 1 3 1 3 0
Sample Output
Hint
角速度定義:
一個以弧度爲單位的圓(一個圓周爲2π,即:360度=2π),在單位時間內所走的弧度即爲角速度。
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
double a, b, r, x, y, w, t;
scanf("%lf%lf%lf%lf%lf%lf%lf", &a, &b, &r, &x, &y, &w, &t);
double bx = a + r * cos(w*t);
double by = b + r * sin(w*t);
double k = (by - y) / (bx - x);//斜率k
double l = y - k * x;
double d = pow(k * a - b + l, 2) / (k * k + 1);//點到直線的距離公式
double ans = sqrt(r * r - d) * 2;
printf("%.2lf\n", ans);
}
return 0;
}