#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<sstream>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
using namespace std;
#define ABS(a)  (((a)>0)?(a):-(a))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
typedef __int64 LL;
typedef pair<int,int> PII;
typedef pair<int,PII> PIP;
typedef pair<PII,int> PPI;
typedef pair<PII,PII> PPP;
typedef string str;
struct Point
{
 LL x,y,z;
};
Point p[30];
#define S(X) ((X)*(X))
#define D(a,b) ( sqrt( S(p[a].x-p[b].x) + S(p[a].z-p[b].z) + S(p[a].y-p[b].y) ) )
double area(int a,int b,int c)
{
 double s1 = D(a,b);
 double s2 = D(c,b);
 double s3 = D(a,c);
 double s = (s1+s2+s3)/2.;
 return sqrt(s*(s-s1)*(s-s2)*(s-s3));
}
LL FIND(int a,int b,int c,int d)
{
 LL x1 = p[a].x, y1=p[a].y, z1=p[a].z;
 LL x2 = p[b].x, y2=p[b].y, z2=p[b].z;
 LL x3 = p[c].x, y3=p[c].y, z3=p[c].z;
 LL x4 = p[d].x, y4=p[d].y, z4=p[d].z;
 return (x4-x1)*(y2-y1)*(z3-z1)
  + (y4-y1)*(z2-z1)*(x3-x1)
  + (z4-z1)*(x2-x1)*(y3-y1)
  - (x4-x1)*(z2-z1)*(y3-y1)
  - (y4-y1)*(x2-x1)*(z3-z1)
  - (z4-z1)*(y2-y1)*(x3-x1);
}
int main()
{
 double ans;
 LL temp;
 int pos,neg,i,j,k,m,n,T,ks=0;
 
 while(scanf("%d",&n)!=EOF && n)
 {
  ks++;
  for(i=0;i<n;i++)
   scanf("%I64d%I64d%I64d",&p[i].x,&p[i].y,&p[i].z);
  ans = 0;
  for(i=0;i<n;i++)
   for(j=i+1;j<n;j++)
    for(k=j+1;k<n;k++)
    {
     pos=neg=0;
     for(m=0;m<n;m++)
     {
      temp = FIND(i,j,k,m);
      if(temp > 0) pos++;
      else if(temp<0) neg++;
     }
     if(!neg || !pos)
     {
//      printf("%d %d %d\n",i,j,k);
      ans += area(i,j,k);
     }
    }
  printf("Case %d: %.2lf\n",ks,ans);
 }
 return 0;
}
 
No comments:
Post a Comment