HDU 1174 爆头 两向量夹角

题目是中文的,就不再赘述了。其实方法比题意还简单。

设警头心为O1,匪头心O2,警头心到匪头切点为D,枪方向向量为O1B;

只要∠BO1O2 <= ∠O2O1D 就能爆头。。。。

可能是后台比较水吧,对精度什么要求不太高。。

总之又是一道水题。。。

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

struct N
{
    double x,y,z,h,r;
}t,p;

struct V
{
    double x,y,z;
}v1,v2,v3;

double callen(V v)
{
    return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}

double calcos(V v1,V v2)
{
    return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/( sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z)*sqrt(v2.x*v2.x + v2.y*v2.y + v2.z*v2.z) );
}

int main()
{
    int T;

    double a1,a2,l1;

    scanf("%d",&T);
    while(T--)
    {
        scanf("%lf %lf %lf %lf %lf",&t.h,&t.r,&t.x,&t.y,&t.z);
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&p.h,&p.r,&p.x,&p.y,&p.z,&v1.x,&v1.y,&v1.z);

        p.h *= 0.9;

        p.z += p.h - p.r;
        t.z += t.h - t.r;

        v2.x = (t.x - p.x);
        v2.y = (t.y - p.y);
        v2.z = (t.z - p.z);

        l1 = callen(v2);

        a1 = t.r/l1;
        a1 = asin(a1);

        a2 = acos(calcos(v1,v2));

        if(a2 > a1)
            cout<<"NO"<<endl;
        else cout<<"YES"<<endl;

    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值