hdu 1174 爆头(点到空间直线距离)

看见这个标题就进去了,然后就水之。。。。

#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>

#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;

const int inf=0x7ffffff;
const double PI=acos(-1.0);
const double eps=1e-8;
const double e=2.7182818284590452354;

struct point
{
	double x,y,z;
	point() {}
	point(double x,double y,double z): x(x),y(y),z(z) {}	
};

point operator + (point a,point b){ return point(a.x+b.x,a.y+b.y,a.z+b.z);}
point operator - (point a,point b){ return point(a.x-b.x,a.y-b.y,a.z-b.z);}
point operator * (double a,point b) { return point(a*b.x,a*b.y,a*b.z);}

double dmult(point u,point v)
{ 
	return u.x*v.x+u.y*v.y+u.z*v.z; 
}
point xmult(point u,point v)
{ 
	point ret; 
	ret.x=u.y*v.z-v.y*u.z; 
	ret.y=u.z*v.x-u.x*v.z; 
	ret.z=u.x*v.y-u.y*v.x; 
	return ret; 
}
int main()
{
	int t;
	point pc,te,dir,te_head,pc_head;
	double h1,h2,h3,h4,r1,r2;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lf%lf%lf%lf%lf",&h1,&r1,&te.x,&te.y,&te.z);
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&h2,&r2,&pc.x,&pc.y,&pc.z,&dir.x,&dir.y,&dir.z);
		h2=h2*0.9;
		h4=h2-r2;
		h3=h1-r1;
		te_head=point(te.x,te.y,te.z+h3);
		pc_head=point(pc.x,pc.y,pc.z+h4);
		point n=te_head-pc_head;
		point pp=xmult(n,dir);
		double d=sqrt((pp.x*pp.x+pp.y*pp.y+pp.z*pp.z)/(dir.x*dir.x+dir.y*dir.y+dir.z*dir.z));
		if(d<=r1 && dmult(n,dir)>0)
			puts("YES");
		else puts("NO");
		
	}
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值