HDU - 6559 The Tower (计算几何)

Description:

The Tower shows a tall tower perched on the top of a rocky mountain. Lightning strikes, setting the building alight, and two people leap from the windows, head first and arms outstretched. It is a scene of chaos and destruction. 

There is a cone tower with base center at (0, 0, 0), base radius r and apex (0, 0, h). At time 0 , a point located at (x0x0, y0y0, z0z0) with velocity (vxvx, vyvy, vzvz). What time will they collide? Here is the cone tower. 

Input

The first line contains testcase number TT (TT ≤ 1000), For each testcase the first line contains spaceseparated real numbers rr and hh (1 ≤ rr, hh ≤ 1000) — the base radius and the cone height correspondingly. 
For each testcase the second line contains three real numbers x0x0, y0y0, z0z0 (0 ≤ |x0x0|, |y0y0|, z0z0 ≤ 1000). For each testcase the third line contains three real numbers vxvx, vyvy, vzvz (1 ≤ v2xvx2 + v2yvy2 + v2zvz2 ≤ 3 × 106106). It is guaranteed that at time 0 the point is outside the cone and they will always collide.

Output

For each testcase print Case ii : and then print the answer in one line, with absolute or relative error not exceeding 10−610−6

Sample Input

2
1 2
1 1 1
-1.5 -1.5 -0.5
1 1
1 1 1
-1 -1 -1

Sample Output

Case 1: 0.3855293381
Case 2: 0.5857864376

给出一个圆锥体的半径和高,圆锥的地面圆心在坐标轴原点,又给出了一个质点的坐标和移动速度,求最短经过多长时间可以使质点和圆锥相交。

 

设ttt为碰撞时间,建立圆锥曲面和运动轨迹的方程,联立方程解。
则运动轨迹方程组为:

圆锥曲面方程组为:

化简然后求t

AC代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<iomanip>
#include<math.h>
using namespace std;
double deta(double a,double b,double c)
{
    double ans=b*b-4*a*c;
    ans=sqrt(ans);
    return ans;
}
int main()
{
    int t,Case=0;
    cin>>t;
    double r,h;
    double x0,y0,z0,vx,vy,vz;
    while(t--)
    {
        cin>>r>>h;
        cin>>x0>>y0>>z0;
        cin>>vx>>vy>>vz;
        double a,b,c;
        a=vx*vx+vy*vy-vz*vz*r*r/(h*h);
        b=2*x0*vx+2*y0*vy+2*r*r*vz/h-2*z0*vz*r*r/(h*h);
        c=x0*x0+y0*y0-r*r+2*r*r*z0/h-r*r*z0*z0/(h*h);
        double t2=(-b-deta(a,b,c))/(2*a);
        printf("Case %d: %.10lf\n",++Case,t2);
    }

    return 0;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值