POJ 2208 Pyramids 计算几何 四面体体积

题意:给出四面体的6条边,求四面体体积

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
#define LL long long
#define eps 1e-6

int main()
{
    double AB, AC, AD, BC, BD, CD;
    double xc,xd,yd,x,y,z,v,Sbcd,theta;
    while(scanf("%lf%lf%lf%lf%lf%lf",&AB,&AC,&AD,&BC,&BD,&CD)!=EOF)
    {
        xc=BC;
        theta=acos((BC*BC+BD*BD-CD*CD)/(2*BC*BD));
        xd=BD*cos(theta);
        yd=BD*sin(theta);
        x=(AB*AB-AC*AC+xc*xc)/(2*xc);
        y=(AC*AC-AD*AD-(x-xc)*(x-xc)+(x-xd)*(x-xd)+yd*yd)/(2*yd);
        z=sqrt(AB*AB-x*x-y*y); //
        Sbcd=BC*BD*sin(theta);
        v=Sbcd*z/6.0;
        printf("%.4f
",v);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zuferj115/p/5224974.html