tetrahedron
题意:
求解一个四面体的内切球。
解法:
首先假设内切球球心为$(x0,x1,x2)$,可以用$r = \frac{3V}{S_1+S_2+S_3+S_4}$得出半径,
这样对于四个平面列出三个方程,解得
$x_n = \sum_{i=0}^3{Ai_{x_n} \cdot S_i } / (S_1 + S_2 + S_3 + S_4)$
这样,即可得出内切球。
时间复杂度$O(1)$。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> #define LD double
#define sqr(x) ((x)*(x))
#define eps 1e-13 using namespace std; struct node
{
LD x,y,z;
void scan()
{
scanf("%lf%lf%lf",&x,&y,&z);
}
void print()
{
printf("%.4lf %.4lf %.4lf\n",x,y,z);
}
LD length()
{
return sqrt(sqr(x)+sqr(y)+sqr(z));
}
node operator+(const node &tmp)
{
return (node){x+tmp.x,y+tmp.y,z+tmp.z};
}
node operator-(const node &tmp)
{
return (node){x-tmp.x,y-tmp.y,z-tmp.z};
}
node operator/(LD tmp)
{
return (node){x/tmp,y/tmp,z/tmp};
}
node operator*(LD tmp)
{
return (node){x*tmp,y*tmp,z*tmp};
}
}; node cross(node a,node b)
{
node ans;
ans.x = a.y*b.z - b.y*a.z;
ans.y = b.x*a.z - a.x*b.z;
ans.z = a.x*b.y - b.x*a.y;
return ans;
} LD dist(node a,node b)
{
return (b-a).length();
} LD dot(node a,node b)
{
return a.x*b.x + a.y*b.y + a.z*b.z;
} LD get_angle(node a,node b)
{
LD tmp = dot(a,b)/a.length()/b.length();
return acos(tmp);
} node get_node(node A,node B,node C)
{
LD Lth = (B-A).length() + (C-A).length() + (C-B).length();
cout << sqr(Lth-) << endl;
LD r = fabs(cross(B-A,C-A).length()) / Lth;
cout << r*r << endl;
node v1 = C-A;
node v2 = B-A;
node v = (v1+v2)/(v1+v2).length();
LD d = (C-A).length()/;
LD L = sqrt(sqr(d)+sqr(r));
v = v*L;
return A+v;
} int main()
{
node A,B,C,D;
while(~scanf("%lf%lf%lf",&A.x,&A.y,&A.z))
{
B.scan();
C.scan();
D.scan();
if(fabs(dot(cross(B-A,C-A),D-A)) < eps)
{
puts("O O O O");
continue;
}
LD S1 = fabs(cross(B-D,C-D).length())/;
LD S2 = fabs(cross(D-A,C-A).length())/;
LD S3 = fabs(cross(B-A,D-A).length())/;
LD S4 = fabs(cross(B-A,C-A).length())/;
LD Ve = fabs(dot(cross(B-A,C-A),D-A))/;
LD R = *Ve / ((S1+S2+S3+S4));
node ans;
ans.x = (S1*A.x + S2*B.x + S3*C.x + S4*D.x)/(S1+S2+S3+S4);
ans.y = (S1*A.y + S2*B.y + S3*C.y + S4*D.y)/(S1+S2+S3+S4);
ans.z = (S1*A.z + S2*B.z + S3*C.z + S4*D.z)/(S1+S2+S3+S4);
printf("%.4lf %.4lf %.4lf %.4lf\n",ans.x,ans.y,ans.z,R);
}
return ;
}
/*
0 0 0 2 0 0 0 0 2 0 2 0
0 0 0 2 0 0 3 0 0 4 0 0
*/
tetrahedron的更多相关文章
- HDU #5733 tetrahedron
tetrahedron 传送门 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) P ...
- CodeForces 166E -Tetrahedron解题报告
这是本人写的第一次博客,学了半年的基础C语言,初学算法,若有错误还请指正. 题目链接:http://codeforces.com/contest/166/problem/E E. Tetrahedro ...
- E. Tetrahedron(数学推导)
E. Tetrahedron 分类: AC路漫漫2013-08-08 16:07 465人阅读 评论(0) 收藏 举报 time limit per test 2 seconds memory lim ...
- 计算几何----判断空间点是否在一个四面体(tetrahedron)内部
DESCRIPTION: 判断空间点 P(x, y, z)是否在一个四面体的内部? Let the tetrahedron have vertices V1 = (x1, y1, z1) V2 = ( ...
- (四面体)CCPC网络赛 HDU5839 Special Tetrahedron
CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...
- HDU 5839 Special Tetrahedron (计算几何)
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- HDU 5839 Special Tetrahedron
HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n ...
- HDU 5839 Special Tetrahedron 计算几何
Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- hdu 5726 tetrahedron 立体几何
tetrahedron/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Given four p ...
- CF 166E Tetrahedron
E. Tetrahedron time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
随机推荐
- cocosStudio中使用PageView,ListView和ScrollView
晚上吃东西好像吃坏肚子了,.但是技术还要继续研究.最近工作中要使用CocosStudio做界面,好吧,不管对他有什么偏见,学习一下吧.这里主要记录一下三个控件的使用和说明.就是ScrollView,L ...
- Android开发之实现锁屏功能
锁屏须要引入设备超级管理员.在文档Android开发文档的Administration中有具体的说明. Android设备管理系统功能和控制訪问. 主要有一下几个步骤: 1 创建广播接收者,实现De ...
- 系统安全-Man in the middleattack
窃听VS加密(解决数据机密性) 加密由两部分组成:算法&秘钥(算法要够复杂,秘钥要够安全) 对称加密:(Symmetric encryption) 采用单秘钥密码系统的加密方法,同一个秘钥可以 ...
- python--内置函数补充
内置函数补充 基础数据类型相关 和数字相关:数据类型: bool 布尔 int 整型 float 浮点 complex 复数 只有在强转中会用进制转换: bin() 二进制转换 比如0b开头表示的是二 ...
- angular 指令封装弹出框效果
就直接用bs的警告框啦~,Duang~ 功能 可以设置message和type,type就是bs内置的几种颜色 默认提示3秒框自动关闭,或者点击x号关闭 代码 模板 <div class=&qu ...
- WPF触发器(Trigger、DataTrigger、EventTrigger)
WPF中有种叫做触发器的东西(记住不是数据库的trigger哦).它的主要作用是根据trigger的不同条件来自动更改外观属性,或者执行动画等操作. WPFtrigger的主要类型有:Trigger. ...
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
本文转载至 http://blog.csdn.net/liuwuguigui/article/details/39494597 IOS8UIAlertViewUIActionSheet ...
- EasyDarwin幼教云视频平台在幼教平台领域大放异彩!
在之前的一篇方案<基于EasyDarwin云视频平台的幼儿园视频直播(手机直播/微信直播)解决方案>中,我们提到一种可以广泛应用于幼教.工厂.建筑工地以及各种现场监控的云视频平台方案,这种 ...
- Apache JServ Protocol
ajp_百度百科 https://baike.baidu.com/item/ajp/1187933 AJP(Apache JServ Protocol)是定向包协议.因为性能原因,使用二进制格式来传输 ...
- (转)CentOS6.5安装Darwin Streaming Server搭建RTSP流媒体服务器
参考: 1,CentOS6.5安装Darwin Streaming Server搭建RTSP流媒体服务器 http://www.yimiju.com/articles/567.html