tetrahedron

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 889    Accepted Submission(s): 382

Problem Description
Given four points ABCD, if ABCD is a tetrahedron, calculate the inscribed sphere of ABCD.
 
Input
Multiple test cases (test cases ≤100).

Each test cases contains a line of 12 integers [−1e6,1e6] indicate the coordinates of four vertices of ABCD.

Input ends by EOF.

 
Output
Print the coordinate of the center of the sphere and the radius, rounded to 4 decimal places.

If there is no such sphere, output "O O O O".

 
Sample Input
0 0 0 2 0 0 0 0 2 0 2 0
0 0 0 2 0 0 3 0 0 4 0 0
 
Sample Output
0.4226 0.4226 0.4226 0.4226
O O O O
 
Author
HIT
 
Source
 
题意:给你四个点的坐标,判断是否有内切圆,如果有内切圆的话,输出内切圆圆心的坐标和半径;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MM(a,b) memset(a,b,sizeof(a));
#define inf 0x7f7f7f7f
#define FOR(i,n) for(int i=1;i<=n;i++)
#define CT continue;
#define PF printf
#define SC scanf
const int mod=1000000007;
const int N=1e6+100;
int n,m,c[N],pre[N],sum[N],a[N],ans[N]; struct Point{
ll x,y,z;
void read()
{
scanf("%lld%lld%lld",&x,&y,&z);
}
}p[6]; Point operator-(Point a,Point b)
{
return (Point){b.x-a.x,b.y-a.y,b.z-a.z};
} double dis(Point a)
{
return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);
} Point cross(Point a,Point b)
{
return (Point){a.y*b.z-b.y*a.z,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
} double dot(Point a,Point b)
{
return a.x*b.x+a.y*b.y+a.z*b.z;
} double pointtoface(Point c,Point a,Point b,Point d)
{
Point m=cross(b-a,d-a);
return dot(m,c-a)/dis(m);
}//三维几何中点到面的距离利用 向量a*向量b=|a|*|b|cos(ang) int main()
{
double s[5];
while(~scanf("%lld%lld%lld",&p[1].x,&p[1].y,&p[1].z))
{
p[2].read();p[3].read();p[4].read();
if(dot(cross(p[2]-p[1],p[3]-p[1]),p[4])==0) {printf("O O O O\n");CT;}
double ts=0;
s[1]=dis(cross(p[3]-p[2],p[4]-p[2]))/2;
s[2]=dis(cross(p[3]-p[1],p[4]-p[1]))/2;
s[3]=dis(cross(p[2]-p[1],p[4]-p[1]))/2;
s[4]=dis(cross(p[3]-p[1],p[2]-p[1]))/2;
for(int i=1;i<=4;i++) ts+=s[i]; double h=pointtoface(p[3],p[1],p[2],p[4]);
double r=fabs(s[3]/ts*h); double x=(s[1]*p[1].x+s[2]*p[2].x+s[3]*p[3].x+s[4]*p[4].x)/ts;
double y=(s[1]*p[1].y+s[2]*p[2].y+s[3]*p[3].y+s[4]*p[4].y)/ts;
double z=(s[1]*p[1].z+s[2]*p[2].z+s[3]*p[3].z+s[4]*p[4].z)/ts; printf("%.4f %.4f %.4f %.4f\n",x,y,z,r);
}
return 0;
}

  内切球坐标公式:http://www.docin.com/p-504197705.html?qq-pf-to=pcqq.c2c

这道题目了解下内切球球心公式就好,其他没有什么难的

hdu 5733 tetrahedron 四面体内切球球心公式的更多相关文章

  1. HDU #5733 tetrahedron

    tetrahedron 传送门 Time Limit: 2000/1000 MS (Java/Others)   Memory Limit: 65536/65536 K (Java/Others) P ...

  2. HDU 5733 tetrahedron(计算几何)

    题目链接 tetrahedron 题目大意 输入一个四面体求其内心,若不存在内心则输出"O O O O" 解题思路 其实这道题思路很简单,只要类推一下三角形内心公式就可以了. 至于 ...

  3. 【HDU 5733】tetrahedron

    输入4个点三维坐标,如果是六面体,则输出内切球的球心坐标和半径. 点pi对面的面积为si,点a,b,c组成的面积=|ab叉乘ac|/2. 内心为a,公式: s0=s1+s2+s3+s4 a.x=∑si ...

  4. hdu 5726 tetrahedron 立体几何

    tetrahedron/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Given four p ...

  5. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

  6. HDU 1014 Uniform Generator(模拟和公式)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1014 Uniform Generator Time Limit: 2000/1000 MS (Java ...

  7. HDU 4661 Message Passing ( 树DP + 推公式 )

    参考了: http://www.cnblogs.com/zhsl/archive/2013/08/10/3250755.html http://blog.csdn.net/chaobaimingtia ...

  8. hdu 4535(排列组合之错排公式)

    吉哥系列故事——礼尚往来 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  9. HDU - 5492 Find a path(方差公式+dp)

    Find a path Frog fell into a maze. This maze is a rectangle containing NN rows and MM columns. Each ...

随机推荐

  1. MySQL-存储引擎-创建表-字段数据类型-严格模式-字段约束-键-02

    目录 扩展点 查看服务端字符.IP.端口配置 取消本次错误输入 例外情况 database 数据库操作 table 数据表操作 查看MySQL存储引擎 常见几个存储引擎 InnoDB MyISAM M ...

  2. 简单的pycharm使用秘籍视频

    ttp://edu.51cto.com/center/course/lesson/index?id=163794 这个免费视频是我自己找的别人的,一些常用的基本上都还有,所以说善用百度之类的搜索引擎很 ...

  3. 03docker镜像

    docker的镜像操作 Union文件系统是Docker镜像的基础. UnionFS(联合文件系统):Union文件系统是一种分层,轻量级并且高性能的文件系统.它支持对文件系统的修改作为一次提交来一层 ...

  4. 【原创】大数据基础之Kudu(6)kudu tserver内存占用统计分析

    kudu tserver占用内存过高后会拒绝部分写请求,日志如下: 19/06/01 13:34:12 INFO AsyncKuduClient: Invalidating location 34b1 ...

  5. MVC4中使用EntityFramework

    首先,MVC4不支持EntityFramwok 6版本,如果安装了EntityFramwok 6,则vs不会自动引用dll和修改web.config配置.先删除旧的版本,执行指令:Uninstall- ...

  6. 2.vi 和 vim 编辑器

    Linux系统的命令行下的文本编辑器 三种模式 一般模式:打开文档的默认模式 编辑模式 可以进行编辑,要按下  i  a  o  r 等字母后才能从一般模式进入编辑模式 按下ESC 退出编辑模式 命令 ...

  7. linux命令详解——top

    简介 TOP是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止.比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系 ...

  8. 华硕B360主板装机找不到固态硬盘启动

      1.开机点按F2进入BIOS中,在security选项卡中选择secure boot menu,secure boot control按Enter选择Disable,按F10保存:   2.电脑重 ...

  9. 【转】__cplusplus的含义

    有点代码中会看到以下形式的代码: #ifdef __cplusplus extern "C" {#endif #ifdef __cplusplus}#endif 这些代码是什么意思 ...

  10. 【转】float与double的范围和精度

    原文:http://blog.csdn.net/wuna66320/article/details/1691734 1 范围 float和double的范围是由指数的位数来决定的. float的指数位 ...