hdu 5733 tetrahedron 四面体内切球球心公式
tetrahedron
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 889 Accepted Submission(s): 382
Each test cases contains a line of 12 integers [−1e6,1e6] indicate the coordinates of four vertices of ABCD.
Input ends by EOF.
If there is no such sphere, output "O O O O".
0 0 0 2 0 0 3 0 0 4 0 0
O O O O
#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 四面体内切球球心公式的更多相关文章
- HDU #5733 tetrahedron
tetrahedron 传送门 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) P ...
- HDU 5733 tetrahedron(计算几何)
题目链接 tetrahedron 题目大意 输入一个四面体求其内心,若不存在内心则输出"O O O O" 解题思路 其实这道题思路很简单,只要类推一下三角形内心公式就可以了. 至于 ...
- 【HDU 5733】tetrahedron
输入4个点三维坐标,如果是六面体,则输出内切球的球心坐标和半径. 点pi对面的面积为si,点a,b,c组成的面积=|ab叉乘ac|/2. 内心为a,公式: s0=s1+s2+s3+s4 a.x=∑si ...
- hdu 5726 tetrahedron 立体几何
tetrahedron/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Given four p ...
- hdu 3117 Fibonacci Numbers 矩阵快速幂+公式
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...
- HDU 1014 Uniform Generator(模拟和公式)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1014 Uniform Generator Time Limit: 2000/1000 MS (Java ...
- HDU 4661 Message Passing ( 树DP + 推公式 )
参考了: http://www.cnblogs.com/zhsl/archive/2013/08/10/3250755.html http://blog.csdn.net/chaobaimingtia ...
- hdu 4535(排列组合之错排公式)
吉哥系列故事——礼尚往来 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...
- 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 ...
随机推荐
- nginx.conf and dockerfile带颜色
wget http://www.vim.org/scripts/download_script.php?src_id=14376 -O nginx.vim mv nginx.vim /usr/shar ...
- MySql 中锁的定义
行级锁,一般是指排它锁,即被锁定行不可进行修改,删除,只可以被其他会话select.行级锁之前需要先加表结构共享锁. 表级锁,一般是指表结构共享锁锁,是不可对该表执行DDL操作,但对DML操作都不限制 ...
- Java New IO
1.NIO介绍 应用程序中,通常会涉及两种类型的计算:计算密集型和I/O密集型.对多数应用来说,花费在等待IO上的时间是比较大的.因此提高IO操作效率对应用的性能至关重要. 面向流的IO系统一次处理一 ...
- js ajax return false了,仍然会往下执行
function checkMust(){ var flag=false; $.getJSON("../Ajax/Carton/Ajax_TMSOrder_Create.ashx?r=&qu ...
- MFC六大核心机制
MFC六大核心机制概述 我们选择了C++,主要是因为它够艺术.够自由,使用它我们可以实现各种想法,而MFC将多种可灵活使用的功能封装起来,我们岂能忍受这种“黑盒”操作?于是研究分析MFC的核心机制成为 ...
- java实现spark常用算子之Union
import org.apache.spark.SparkConf;import org.apache.spark.api.java.JavaRDD;import org.apache.spark.a ...
- 精心整理的一些 Python 学习资料
今天花了些时间给大家精心整理一份 Python 学习资料.我觉得不错的资料我都整理进来了,如果你是学习python的,我觉得这一份资料对你应该有用. 1.知乎上超过 10k 的python相关回答 Y ...
- 10 select、poll以及epoll
IO复用:为了解释这个名词,首先来理解下复用这个概念,复用也就是共用的意思,这样理解还是有些抽象,为此,咱们来理解下复用在通信领域的使用, 在通信领域中为了充分利用网络连接的物理介质,往往在同一条网络 ...
- 记录一则ORA
应用服务器:Windows Server 2008 R2 Enterprise故障现象:项目侧同事反映应用服务器上的程序连接数据库报错:ORA-12560: TNS: 协议适配器错误 1.故障重现 2 ...
- bizcharts在火狐上的Invalid date报错
bizcharts在火狐上的Invalid date报错,是因为 bizcharts 所用到的 fecha在 火狐上 只能接收日期对象类型的日期,不能接收日期字符串.