hdu 1174 爆头(点到空间直线距离)
2013-10-31 21:41
417 查看
看见这个标题就进去了,然后就水之。。。。
#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; }
相关文章推荐
- HDU_1174——爆头,空间直线方程,直线到点的距离
- hdoj1174爆头【点到直线距离(空间)】
- HDU 1174 爆头(三维空间中求点线距离)
- HDU 4617 立体几何-空间直线距离
- HDU 1174 3维点到直线距离
- HDU 4741 Save Labman No.004 ( 三维计算几何 空间异面直线距离 )
- HDU 4741 空间几何求两直线距离最近点
- hdu 4741 Save Labman No.004 空间两直线最短距离及坐标
- hdu 1174:爆头(计算几何,三维叉积求点到线的距离)
- HDU 1174 爆头(三维空间点与直线关系)
- ACM HDU 1174 爆头(数学题,求空间点到直线的距离,用叉积)
- HDU 4741 Save Labman No.004 (2013杭州网络赛1004题,求三维空间异面直线的距离及最近点)
- 点到空间直线的距离
- 求空间两条直线之间的距离
- HDU 1174 爆头(计算几何)
- 【C\C++】空间中求一点到两点所构成的直线的距离
- hdoj4617Weapon【空间直线间的距离】
- hdu 1174 爆头
- HDU 1174 爆头
- HDU 4617 Weapon (简单三维计算几何,异面直线距离)