UVALive 4589 Asteroids(3D 볼록 & & 무게 중심)

2905 단어 기하학
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define FRER() freopen("/Users/seven7777777/Desktop/Code/TESTXCODE/TESTXCODE/in.txt","r",stdin)
#define FREW() freopen("/Users/seven7777777/Desktop/Code/TESTXCODE/TESTXCODE/out.txt","w",stdout)
#define go int T;cin>>T;for(int kase=0;kase pii;
const int maxn = 100 + 7;
struct Point3
{
    double x,y,z;
    Point3(double x = 0 , double y = 0,double z = 0):x(x),y(y),z(z){}
    void print(){
        printf("x:%lf y:%lf z:%lf",x,y,z);
    }
};
typedef Point3 Vector3;
Vector3 operator + (Vector3 A,Vector3 B){
    return Vector3(A.x+B.x,A.y+B.y,A.z+B.z);
}
Vector3 operator - (Vector3 A,Vector3 B){
    return Vector3(A.x-B.x,A.y-B.y,A.z-B.z);
}
Vector3 operator * (Vector3 A,double p){
    return Vector3(A.x*p,A.y*p,A.z*p);
}
Vector3 operator / (Vector3 A,double p){
    return Vector3(A.x/p,A.y/p,A.z/p);
}
double Dot(Vector3 A,Vector3 B){
    return A.x*B.x + A.y*B.y + A.z*B.z;
}
Vector3 Cross(Vector3 A,Vector3 B){
    return Vector3(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 Volume6(Point3 A,Point3 B,Point3 C,Point3 D){
    return Dot(D-A,Cross(B-A, C-A));
}
struct Face{
    int v[3];
    Face(int a=0,int b=0,int c=0){
        v[0] = a;
        v[1] = b;
        v[2] = c;
    }
    Vector3 Normal(Point3* p)const{
        return Cross(p[v[1]]-p[v[0]],p[v[2]]-p[v[0]]);
    }
    int cansee(Point3 *p,int i)const{
        return Dot(p[i]-p[v[0]],Normal(p)) > 0 ? 1 : 0;
    }
    void print(Point3 *p){
        cout< CH3D(Point3* p,int n){
    int vis[maxn][maxn];
    vectorcur;
    cur.push_back(Face(0,1,2));
    cur.push_back(Face(2,1,0));
    for(int i=3;inxt;
        for(int j=0;jf = CH3D(_p, n);
    Point3 base;
    int len = (int)f.size();
    double totv = 0;
    for(int i=0;i

좋은 웹페이지 즐겨찾기