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. 运用加密技术保护Java源代码(转)

    出处:运用加密技术保护Java源代码 为什么要加密? 对于传统的C或C++之类的语言来说,要在Web上保护源代码是很容易的,只要不发布它就可以.遗憾的是,Java程序的源代码很容易被别人偷看.只要有一 ...

  2. Annotation Type ManyToMany->>>>>Oracle

    Example 1: // In Customer class: @ManyToMany @JoinTable(name="CUST_PHONES") public Set< ...

  3. 一键部署etcd集群

    这里使用三个节点,系统版本为CentOS7 # vim deploy-etcd.sh #!/bin/bash set -x set -e #更改这里的IP, 只支持部署3个节点etcd集群 decla ...

  4. wcf可以返回的类型有哪些

    Windows Communication Foundation (WCF) 使用 DataContractSerializer 作为其默认的序列化引擎以将数据转换到 XML 并将 XML 转换回数据 ...

  5. GTA4 EFLC cheat code

    GTA4 EFLC cheat code 提示警告:您的图像设置接近或超出您的系统推荐资源限制,为了使游戏运行更加流畅推荐你降低你的图像设置. 在游戏目录新建名为 commandline的txt文本文 ...

  6. Huge Packet Drops (Tx drops) Observed on NetScaler

    Huge Packet Drops (Tx drops) Observed on NetScaler 来源  https://support.citrix.com/article/CTX215843 ...

  7. maven:无效的目标发行版:11

    maven:无效的目标发行版:11 我之前在博客里是不记录bug和error的处理的,昨天听了一个资深程序员的视频,决定要改习惯了,记录一些自己平时遇到的问题 这个是我在mvn clean insta ...

  8. O054、Attach Volume 操作(Part II)

    参考https://www.cnblogs.com/CloudMan6/p/5631328.html     计算节点作为iSCSI initiator 访问存储节点 iSCSI Target 上的v ...

  9. O052、Create Volume 操作 (Part III)

    参考https://www.cnblogs.com/CloudMan6/p/5617980.html       Jun 20 17:15:56 DevStack-Rocky-Compute-22 c ...

  10. java基础3(异常)

    1.异常的体系 1)请描述异常的继承体系 异常继承体系为:异常的根类是 java.lang.Throwable,其下有两个子类:java.lang.Error 与 java.util.Exceptio ...