题目大意:
思路:
首先我们需要求出整个凸多面体的重心
可以通过把多面体剖分为四面体 求出每个四面体的重心
四面体的重心为四个点的坐标和/4
对每个四面体的重心 加上它们体积的权 加权平均数即为整个的重心
(求每个四面体的体积可以用三个向量的混合积
因为给出了求凸面三角形的公式
因此一个凸面上凸N边形的公式为它的内角和-(N-2)*pi
这样这个面的答案为面积/整个圆的表面积即4pi
(求二面角可以用叉积 求出两个法向量然后运用课内知识求出二面角
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define inf 2139062143
#define ll long long
#define MAXN 200
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-;ch=getchar();}
while(isdigit(ch)) {x=x*+ch-'';ch=getchar();}
return x*f;
}
const double pi=acos(-);
int n,m,alpha[MAXN][MAXN],num[MAXN];
struct Vector{double x,y,z;}p[MAXN];
Vector operator + (const Vector &a,const Vector &b) {return (Vector){a.x+b.x,a.y+b.y,a.z+b.z};}
Vector operator - (const Vector &a,const Vector &b) {return (Vector){a.x-b.x,a.y-b.y,a.z-b.z};}
Vector operator * (const Vector &a,const double &b) {return (Vector){a.x*b,a.y*b,a.z*b};}
Vector operator / (const Vector &a,const double &b) {return (Vector){a.x/b,a.y/b,a.z/b};}
Vector operator ^ (const Vector &a,const Vector &b) {return (Vector){a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};}
double operator & (const Vector &a,const Vector &b) {return a.x*b.x+a.y*b.y+a.z*b.z;}
inline double len(Vector a) {return sqrt(a&a);}
inline double getV(Vector a,Vector b,Vector c) {return a&(b^c);}
inline double getA(Vector a,Vector b,Vector c)
{
Vector x=a^c,y=a^b;return acos(x&y/len(x)/len(y));
}
int main()
{
n=read(),m=read();Vector tmp,ctr;double x,vs=0.0,ans;
for(int i=;i<=n;i++)
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);
for(int i=;i<=m;i++)
{
num[i]=read();
for(int j=;j<=num[i];j++) alpha[i][j]=read();
}
for(int i=;i<=m;i++)
for(int j=;j<num[i];j++)
{
tmp=p[alpha[i][]]+p[alpha[i][j]]+p[alpha[i][j+]];
x=getV(p[alpha[i][]],p[alpha[i][j]],p[alpha[i][j+]]);
vs+=x,ctr=ctr+tmp*x;
}
ctr=ctr/(vs*);
for(int i=;i<=n;i++) p[i]=p[i]-ctr;
for(int i=;i<=m;i++)
{
ans=;
for(int j=;j<=num[i];j++) ans+=getA(p[alpha[i][j]],p[alpha[i][j!=?j-:num[i]]],p[alpha[i][j!=num[i]?j+:]]);
printf("%.7lf\n",(ans-(num[i]-)*pi)/(pi*));
}
}