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 ...
随机推荐
- jsp表达式
能够在"<%="和"%>"之间插入一个表达式(注意:不可插入语句. "<%="是一个完整的符号,"<%&q ...
- cuda9,cuda8分享百度云下载
一.文件名称: md5-cuda9cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64.debcuda-repo-ubuntu1604-9-0-local_9. ...
- 【TensorFlow-windows】(四) CNN(卷积神经网络)进行手写数字识别(mnist)
主要内容: 1.基于CNN的mnist手写数字识别(详细代码注释) 2.该实现中的函数总结 平台: 1.windows 10 64位 2.Anaconda3-4.2.0-Windows-x86_64. ...
- Ubuntu 13.10上用户怎样获得root权限,用户怎样获得永久root权限,假设配置root登录
一.用户怎样获得root权限: 1. 进入terminal 2. 输入sudo passwd root 并设置password,提示要你输入两次password.自己设定password,一定要 ...
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
本文转载至 http://blog.csdn.net/liuwuguigui/article/details/39494597 IOS8UIAlertViewUIActionSheet ...
- Message-oriented middleware
en.wikipedia.org/wiki/Message-oriented_middleware Message-oriented middleware (MOM) is software or h ...
- Linux常用命令——持续更新(2018-05-09)
此命令默认是在centos环境下执行,除非特殊标明. 1.查看ip: ifconfig 2.创建指定用户并分配到某个组:创建用户user并分配到root组 useradd -g root user 3 ...
- xcode7和ios9下UIWebView不能加载网页的解决方法
错误描述: App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecu ...
- POJ 2823 Sliding Window (滑动窗口的最值问题 )
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 41264 Accepted: 12229 ...
- Gym - 100283K K. Cubes Shuffling —— 贪心
题目链接:http://codeforces.com/gym/100283/problem/K 题解: 要使其相邻两项的差值之和最小,那么越靠中间,其数值越小. 那么剩下的问题就是如何放数字了.一开始 ...