// Time 234 ms; Memory 244 K
#include<iostream>
#include<cstdio>
#include<cmath> using namespace std; typedef struct point
{
double x,y,z;
point(double xx=0,double yy=0,double zz=0):x(xx),y(yy),z(zz){}
}vector;
vector operator - (point a,point b)
{
return vector(a.x-b.x,a.y-b.y,a.z-b.z);
}
point operator + (point a,vector b)
{
return point(a.x+b.x,a.y+b.y,a.z+b.z);
}
vector operator * (vector a,double b)
{
return vector(a.x*b,a.y*b,a.z*b);
}
double dot(vector a,vector b)
{
return a.x*b.x+a.y*b.y+a.z*b.z;
}
double len(vector a)
{
return sqrt(dot(a,a));
}
vector cross(vector a,vector b)
{
return vector(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
point inter(point a,point b,point c,point d,point e)
{
point fa=cross(b-a,c-a);
double t=dot(fa,a-d)/dot(fa,e-d);
return d+(e-d)*t;
}
vector resize(vector a,double b)
{
b/=len(a);
return a*b;
}
point ptol(point o,point a,point b)
{
point fa=cross(a-o,b-o);
point vec=cross(b-a,fa);
return o+resize(vec,len(fa)/len(b-a));
}
void gc(point a,point b,point c,point d,point &p1,point &p2)
{
point e=d+cross(a-b,c-d);
p1=inter(c,d,e,a,b);
p2=ptol(p1,c,d);
} int main()
{
int t;
point a,b,c,d,p,q;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&a.z,&b.x,&b.y,&b.z);
scanf("%lf%lf%lf%lf%lf%lf",&c.x,&c.y,&c.z,&d.x,&d.y,&d.z);
gc(a,b,c,d,p,q);
double l=len(p-q);
printf("%.6lf\n",l);
printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",p.x,p.y,p.z,q.x,q.y,q.z);
}
return 0;
}

hdu 4741 Save Labman No.004 [2013年杭州ACM网络赛]的更多相关文章

  1. HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...

  2. HDU 4741 Save Labman No.004 (2013杭州网络赛1004题,求三维空间异面直线的距离及最近点)

    Save Labman No.004 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  3. hdu 4741 Save Labman No.004异面直线间的距离既构成最小距离的两个端点

    Save Labman No.004 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  4. hdu 4741 Save Labman No.004(2013杭州网络赛)

    http://blog.sina.com.cn/s/blog_a401a1ea0101ij9z.html 空间两直线上最近点对. 这个博客上给出了很好的点法式公式了...其实没有那么多的tricky. ...

  5. HDU 4741 Save Labman No.004(计算几何)

    题目链接 抄的模版...mark一下. #include <iostream> #include <cstring> #include <cstdio> #incl ...

  6. [HDU 4741]Save Labman No.004[计算几何][精度]

    题意: 求两条空间直线的距离,以及对应那条距离线段的两端点坐标. 思路: 有一个参数方程算最短距离的公式, 代入求即可. 但是这题卡精度... 用另外的公式(先算出a直线上到b最近的点p的坐标, 再算 ...

  7. hdu 4741 Save Labman No.004 (异面直线的距离)

    转载学习: #include <cstdio> #include <cstdlib> #include <cstring> #include <algorit ...

  8. HDU 4741 Save Labman No.004 ( 三维计算几何 空间异面直线距离 )

    空间异面直线的距离直接套模板. 求交点:求出两条直线的公共法向量,其中一条直线与法向量构成的平面 与 另一条直线 的交点即可.还是套模板o(╯□╰)o 1.不会有两条线平行的情况. 2.两条直线可能相 ...

  9. HDU 4741 Save Labman No.004 (几何)

    题意:求空间两线的最短距离和最短线的交点 题解: 线性代数和空间几何,主要是用叉积,点积,几何. 知道两个方向向量s1,s2,求叉积可以得出他们的公共垂直向量,然后公共垂直向量gamma和两线上的点形 ...

随机推荐

  1. GMTED2010 高程数据下载

    http://topotools.cr.usgs.gov/GMTED_viewer/viewer.htm

  2. delphi 线程池基础 TSimplePool

    1. TSimpleThread 2. TSimpleList 3. 以1,2构成 TSimplePool 用法 先定义: TDoSomeThingThread=class(TSimpleThread ...

  3. 在windows下进行linux开发:利用Vagrant+virtualbox(ShowDoc与mp3dish的作者)

    1,介绍Vagrant 我们做web开发的时候经常要安装各种本地测试环境,比如apache,php,mysql,redis等等.出于个人使用习惯,可能我们还是比较习惯用windows.虽然说在wind ...

  4. nodejs中使用递归案例

    var http = require('http'); //1.正常逻辑第一步正常请求,动作进行一次的方法: function seqRequest(i,limit){ var req = http. ...

  5. A Simple Problem with Integers(线段树,区间更新)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 83822   ...

  6. 数学题(找规律)-hdu-4371-Minimum palindrome

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4731 题目大意: 给一个n表示有n种字母(全部小写),给一个m,求一个由不超过n种字母组成的m个小写 ...

  7. 自己定义View常处理的回调函数

    onFinishInflate() 当View中全部的子控件均被映射成xml后触发 onMeasure(int, int) 确定全部子元素的大小 onLayout(boolean, int, int, ...

  8. linq中的GroupBy总结

    1.简单形式: var q = from p in db.Products group p by p.CategoryID into g select g; 语句描述:Linq使用Group By按C ...

  9. Linux学习之挂载

    linux的系统组织方式是——整个系统从根开始,按树形目录依次向下逐渐扩大,分类存放不同用途的文件,/读作“斜线”,英文slash:当其写作一个路径时,第一个/表示根,即root,其他的/表示路径分割 ...

  10. hadoop搭建杂记:Linux下虚拟机集群网络搭建

    VirtualBox搭建hadoop伪分布式模式 VirtualBox搭建hadoop伪分布式模式 master: ip:192.168.56.120 机器名: master 启动NameNode 启 ...