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. Web 开发和数据科学家仍是 Python 开发的两大主力

    由于 Python 2 即将退役,使用 Python 3 的开发者大约为 90%,Python 2 的使用量正在迅速减少.而去年仍有 1/4 的人使用 Python 2. Web 开发和数据科学家仍是 ...

  2. Java多线程(一):线程与进程

    1.线程和进程 1.1 进程 进程是操作系统的概念,我们运行的一个TIM.exe就是一个进程. 进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位 ...

  3. java——HashSet类中的常见方法

    package com.xt.set; import java.util.HashSet; import java.util.Iterator; import java.util.Set; publi ...

  4. javascript头像上传

    上传头像: 相关关键词:ondragover(拖动元素在投放区内移动) ondrop (元素放在投放区触发但是要去处理浏览器默认事件的影响:ondragenter.ondragover) dataTr ...

  5. java八个框架

    在本文中,我只是整理了以下主流框架: 1.阿帕切米纳 项目主页:http://mina.apache.org/ 它为开发高性能和高可用性网络应用提供了一个非常方便的框架,支持基于Java NIO技术的 ...

  6. vue2.0+按需引入element-ui报错

    项目使用vue脚手架自动生成的,vue版本为^2.5.16.项目中需要按需使用element-ui,根据element-ui的官方文档,一开始在babel.config.js文件中修改配置 modul ...

  7. 使用脚本启动fabric时出错

    Error: got unexpected status: BAD_REQUEST -- error authorizing update: error validating ReadSet: rea ...

  8. Shell脚本——for,while,until循环

    1.for循环: 语句格式: for i in 循环判断 do 循环体 done 举例:九九乘法表(for循环版本) #!/bin/bash # Author: Sean Martin # Blog: ...

  9. mysql精准模糊查询使用CONCAT加占位符(下划线“_”)的使用,直接限定了长度和格式

    比如现在有张表t_user,如下:(表中只是引用某某某的话,并无恶意) id name 1 司马懿 2 司马老贼 3 司马老贼OR司马懿 4 司马大叔 1.模糊查询一般用的模糊查询都是like关键词, ...

  10. C语言求π的方法

    #include <stdio.h> #include <math.h> int main() { int r; double PI,s; scanf("%d&quo ...