亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? inhedron.c

?? 判斷點是否在多面體之中
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*This code is described in "Computational Geometry in C" (Second Edition),Chapter 7.  It is not written to be comprehensible without theexplanation in that book.Compile:    gcc -o inhedron inhedron.c -lmRun (e.g.): inhedron < i.8Written by Joseph O'Rourke, with contributions by Min Xu.Last modified: April 1998Questions to orourke@cs.smith.edu.--------------------------------------------------------------------This code is Copyright 1998 by Joseph O'Rourke.  It may be freelyredistributed in its entirety provided that this copyright notice isnot removed.--------------------------------------------------------------------*/#include <stdio.h>#include <math.h>#define EXIT_FAILURE 1#define X 0#define Y 1#define Z 2#define MAX_INT   2147483647 typedef enum { FALSE, TRUE } bool;#define DIM 3                  /* Dimension of points */typedef int    tPointi[DIM];   /* Type integer point */typedef double tPointd[DIM];   /* Type double point */#define PMAX 10000             /* Max # of pts */tPointi Vertices[PMAX];        /* All the points */tPointi Faces[PMAX];           /* Each triangle face is 3 indices */int check = 0;tPointi Box[PMAX][2];          /* Box around each face *//*---------------------------------------------------------------------Function prototypes.---------------------------------------------------------------------*/char 	InPolyhedron( int F, tPointi q, tPointi bmin, tPointi bmax, int radius );char    SegPlaneInt( tPointi Triangle, tPointi q, tPointi r, tPointd p, int *m );int     PlaneCoeff( tPointi T, tPointd N, double *D );void    Assigndi( tPointd p, tPointi a );int     ReadVertices( void );int     ReadFaces( void );void    NormalVec( tPointi q, tPointi b, tPointi c, tPointd N );double  Dot( tPointi q, tPointd d );void    SubVec( tPointi q, tPointi b, tPointi c );char    InTri3D( tPointi T, int m, tPointi p );char    InTri2D( tPointi Tp[3], tPointi pp );int     AreaSign( tPointi q, tPointi b, tPointi c );char    SegTriInt( tPointi Triangle, tPointi q, tPointi r, tPointd p );char    InPlane( tPointi Triangle, int m, tPointi q, tPointi r, tPointd p);int     VolumeSign( tPointi a, tPointi b, tPointi c, tPointi d );char    SegTriCross( tPointi Triangle, tPointi q, tPointi r );int  	ComputeBox( int F, tPointi bmin, tPointi bmax );void 	RandomRay( tPointi ray, int radius );void 	AddVec( tPointi q, tPointi ray );int  	InBox( tPointi q, tPointi bmin, tPointi bmax );char 	BoxTest ( int n, tPointi a, tPointi b );void 	PrintPoint( tPointi q );/*-------------------------------------------------------------------*/main(){  int n, F, i;  tPointi q, bmin, bmax;  int radius;  srandom( (int) time( (long *) 0 ) );   n = ReadVertices();  F = ReadFaces();  /* Initialize the bounding box */  for ( i = 0; i < DIM; i++ )    bmin[i] = bmax[i] = Vertices[0][i];  radius = ComputeBox( n, bmin, bmax );  printf("radius=%d\n", radius);  while( scanf( "%d %d %d", &q[X], &q[Y], &q[Z] ) != EOF ) {    printf( "\n----------->q = %d %d %d\n",        q[X], q[Y], q[Z] );    printf( "In = %c\n",        InPolyhedron( F, q, bmin, bmax, radius ) );  }}/*  This function returns a char:    'V': the query point a coincides with a Vertex of polyhedron P.    'E': the query point a is in the relative interior of an Edge of polyhedron P.    'F': the query point a is in the relative interior of a Face of polyhedron P.    'i': the query point a is strictly interior to polyhedron P.    'o': the query point a is strictly exterior to( or outside of) polyhedron P.*/char InPolyhedron( int F, tPointi q, tPointi bmin, tPointi bmax, int radius ){   tPointi r;  /* Ray endpoint. */   tPointd p;  /* Intersection point; not used. */   int f, k = 0, crossings = 0;   char code = '?';    /* If query point is outside bounding box, finished. */   if ( !InBox( q, bmin, bmax ) )      return 'o';     LOOP:   while( k++ < F ) {      crossings = 0;        RandomRay( r, radius );       AddVec( q, r );       printf("Ray endpoint: (%d,%d,%d)\n", r[0],r[1],r[2] );        for ( f = 0; f < F; f++ ) {  /* Begin check each face */         if ( BoxTest( f, q, r ) == '0' ) {              code = '0';              printf("BoxTest = 0!\n");         }         else code = SegTriInt( Faces[f], q, r, p );         printf( "Face = %d: BoxTest/SegTriInt returns %c\n\n", f, code );         /* If ray is degenerate, then goto outer while to generate another. */         if ( code == 'p' || code == 'v' || code == 'e' ) {            printf("Degenerate ray\n");            goto LOOP;         }            /* If ray hits face at interior point, increment crossings. */         else if ( code == 'f' ) {            crossings++;            printf( "crossings = %d\n", crossings );         }         /* If query endpoint q sits on a V/E/F, return that code. */         else if ( code == 'V' || code == 'E' || code == 'F' )            return( code );         /* If ray misses triangle, do nothing. */         else if ( code == '0' )            ;         else             fprintf( stderr, "Error, exit(EXIT_FAILURE)\n" ), exit(1);      } /* End check each face */      /* No degeneracies encountered: ray is generic, so finished. */      break;   } /* End while loop */    printf( "Crossings = %d\n", crossings );   /* q strictly interior to polyhedron iff an odd number of crossings. */   if( ( crossings % 2 ) == 1 )      return   'i';   else return 'o';}int ComputeBox( int F, tPointi bmin, tPointi bmax ){  int i, j, k;  double radius;    for( i = 0; i < F; i++ )    for( j = 0; j < DIM; j++ ) {      if( Vertices[i][j] < bmin[j] )	bmin[j] = Vertices[i][j];      if( Vertices[i][j] > bmax[j] ) 	bmax[j] = Vertices[i][j];    }    radius = sqrt( pow( (double)(bmax[X] - bmin[X]), 2.0 ) +                 pow( (double)(bmax[Y] - bmin[Y]), 2.0 ) +                 pow( (double)(bmax[Z] - bmin[Z]), 2.0 ) );  printf("radius = %lf\n", radius);  return irint( radius +1 ) + 1;}/* Return a random ray endpoint */void RandomRay( tPointi ray, int radius ){  double x, y, z, w, t;  /* Generate a random point on a sphere of radius 1. */  /* the sphere is sliced at z, and a random point at angle t     generated on the circle of intersection. */  z = 2.0 * (double) random() / MAX_INT - 1.0;  t = 2.0 * M_PI * (double) random() / MAX_INT;  w = sqrt( 1 - z*z );  x = w * cos( t );  y = w * sin( t );    ray[X] = (irint) ( radius * x );  ray[Y] = (irint) ( radius * y );  ray[Z] = (irint) ( radius * z );    /*printf( "RandomRay returns %6d %6d %6d\n", ray[X], ray[Y], ray[Z] );*/}void AddVec( tPointi q, tPointi ray ){  int i;    for( i = 0; i < DIM; i++ )    ray[i] = q[i] + ray[i];}int InBox( tPointi q, tPointi bmin, tPointi bmax ){  int i;  if( ( bmin[X] <= q[X] ) && ( q[X] <= bmax[X] ) &&      ( bmin[Y] <= q[Y] ) && ( q[Y] <= bmax[Y] ) &&      ( bmin[Z] <= q[Z] ) && ( q[Z] <= bmax[Z] ) )    return TRUE;  return FALSE;}    /*---------------------------------------------------------------------    'p': The segment lies wholly within the plane.    'q': The q endpoint is on the plane (but not 'p').    'r': The r endpoint is on the plane (but not 'p').    '0': The segment lies strictly to one side or the other of the plane.    '1': The segement intersects the plane, and 'p' does not hold.---------------------------------------------------------------------*/char	SegPlaneInt( tPointi T, tPointi q, tPointi r, tPointd p, int *m){    tPointd N; double D;    tPointi rq;    double num, denom, t;    int i;    *m = PlaneCoeff( T, N, &D );    /*printf("m=%d; plane=(%lf,%lf,%lf,%lf)\n", m, N[X],N[Y],N[Z],D);*/    num = D - Dot( q, N );    SubVec( r, q, rq );    denom = Dot( rq, N );    /*printf("SegPlaneInt: num=%lf, denom=%lf\n", num, denom );*/    if ( denom == 0.0 ) {  /* Segment is parallel to plane. */       if ( num == 0.0 )   /* q is on plane. */           return 'p';       else           return '0';    }    else       t = num / denom;    /*printf("SegPlaneInt: t=%lf \n", t );*/    for( i = 0; i < DIM; i++ )       p[i] = q[i] + t * ( r[i] - q[i] );    if ( (0.0 < t) && (t < 1.0) )         return '1';    else if ( num == 0.0 )   /* t == 0 */         return 'q';    else if ( num == denom ) /* t == 1 */         return 'r';    else return '0';}/*---------------------------------------------------------------------Computes N & D and returns index m of largest component.---------------------------------------------------------------------*/int	PlaneCoeff( tPointi T, tPointd N, double *D ){    int i;    double t;              /* Temp storage */    double biggest = 0.0;  /* Largest component of normal vector. */    int m = 0;             /* Index of largest component. */    NormalVec( Vertices[T[0]], Vertices[T[1]], Vertices[T[2]], N );    /*printf("PlaneCoeff: N=(%lf,%lf,%lf)\n", N[X],N[Y],N[Z]);*/    *D = Dot( Vertices[T[0]], N );    /* Find the largest component of N. */    for ( i = 0; i < DIM; i++ ) {      t = fabs( N[i] );      if ( t > biggest ) {        biggest = t;        m = i;      }    }    return m;}/*---------------------------------------------------------------------Reads in the number and coordinates of the vertices of a polyhedronfrom stdin, and returns n, the number of vertices.---------------------------------------------------------------------*/int 	ReadVertices( void ){   int   i, n;   do {     scanf( "%d", &n );     if ( n <= PMAX )       break;     printf("Error in read_vertex:  too many points; max is %d\n", PMAX);   }   while ( 1 );   printf( "Polyhedron Vertices:\n" );   printf( "  i:   x   y   z\n");   for ( i = 0; i < n; i++ ) {     scanf( "%d %d %d", &Vertices[i][X], &Vertices[i][Y], &Vertices[i][Z] );     printf( "%3d:%4d%4d%4d\n", i, Vertices[i][X], Vertices[i][Y], Vertices[i][Z

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产主播一区二区三区| 蜜桃一区二区三区在线观看| 亚洲综合免费观看高清完整版在线 | 国内外成人在线视频| 99久久99久久免费精品蜜臀| 欧美一区二区在线视频| 久久午夜羞羞影院免费观看| 午夜精品一区在线观看| 成人国产精品免费网站| 精品国产人成亚洲区| 水蜜桃久久夜色精品一区的特点| 中文字幕中文乱码欧美一区二区| 国产欧美日韩精品在线| 亚洲成av人综合在线观看| 国产91精品欧美| 欧美成人综合网站| 亚洲bt欧美bt精品| 欧美三级资源在线| 国产精品国产三级国产a| 国产伦精品一区二区三区免费| 国产成人日日夜夜| 欧美草草影院在线视频| 日韩电影一区二区三区| 欧美亚洲国产一卡| 一区二区三区在线免费观看 | 欧美成人激情免费网| 亚洲精品国产精华液| jizz一区二区| 国产精品电影一区二区| 成人高清免费观看| 国产精品久久久久久久久免费樱桃| 亚洲激情在线激情| 91久久香蕉国产日韩欧美9色| 欧美精品在线观看播放| 亚洲男人的天堂一区二区| eeuss国产一区二区三区| 国产精品久久二区二区| 成人午夜伦理影院| 亚洲欧洲美洲综合色网| www.成人网.com| 亚洲在线成人精品| 在线成人免费观看| 日本aⅴ精品一区二区三区| 日韩一区二区三区在线| 另类小说欧美激情| 国产肉丝袜一区二区| 成人污污视频在线观看| 亚洲欧美电影院| 欧美日韩亚洲不卡| 九九**精品视频免费播放| 国产日产欧美一区二区视频| 91免费视频网| 亚洲女人小视频在线观看| 欧美日韩一区小说| 麻豆传媒一区二区三区| 国产日韩av一区二区| 一本一道波多野结衣一区二区| 精品电影一区二区| eeuss国产一区二区三区| 亚洲影院理伦片| 精品国产乱码久久久久久浪潮 | 中文字幕欧美国产| 色狠狠色狠狠综合| 男男gaygay亚洲| 中文字幕一区二区三区四区| 欧美日韩精品欧美日韩精品一 | 国产丝袜欧美中文另类| 91天堂素人约啪| 无码av免费一区二区三区试看| 一本一道久久a久久精品| 日本欧美一区二区三区乱码| 国产校园另类小说区| 91啪亚洲精品| 激情图片小说一区| 亚洲国产日韩精品| 中文字幕国产一区| 欧美一区二区在线观看| 成人av免费在线| 精品中文字幕一区二区| 一区二区高清免费观看影视大全| 99精品在线免费| 九九精品一区二区| 亚洲成av人片在线| 中文字幕免费在线观看视频一区| 国产成人综合在线| 日韩精品午夜视频| 亚洲欧洲一区二区三区| 久久综合久久鬼色| 欧美久久免费观看| 91丝袜高跟美女视频| 国产自产视频一区二区三区| 天堂va蜜桃一区二区三区漫画版| 91国产视频在线观看| 国产不卡视频在线观看| 久久国内精品视频| 日本亚洲视频在线| 亚洲乱码精品一二三四区日韩在线| 色哟哟亚洲精品| 成人av在线资源网站| 国产呦精品一区二区三区网站| 久久久精品国产免大香伊| 欧美丰满嫩嫩电影| 欧美日韩精品一区二区在线播放| 午夜欧美一区二区三区在线播放| 欧美日本在线观看| 欧美性猛片aaaaaaa做受| 国产精品99久久久久| 午夜国产精品一区| 91精品国产综合久久久蜜臀图片| 青青草原综合久久大伊人精品| 欧美成人精精品一区二区频| 欧美日韩一区二区三区在线看| 老司机一区二区| 日本特黄久久久高潮| 日本人妖一区二区| 日韩av午夜在线观看| 亚洲va韩国va欧美va精品 | 在线观看视频一区二区| 91丨九色丨蝌蚪丨老版| 不卡视频在线看| 色欧美片视频在线观看在线视频| 日韩电影一二三区| 欧美aaaaaa午夜精品| 久久99久久99小草精品免视看| 国产精品理论在线观看| 国产精品久久午夜夜伦鲁鲁| 国产欧美日本一区视频| 国产精品久久久一本精品| 亚洲欧美二区三区| 天天影视网天天综合色在线播放| 国产日韩欧美高清在线| 中文字幕乱码亚洲精品一区| 自拍视频在线观看一区二区| 亚洲免费在线观看| 性感美女极品91精品| 久久99精品久久只有精品| 高清beeg欧美| 日本乱人伦aⅴ精品| 欧美丰满高潮xxxx喷水动漫| 欧美哺乳videos| 国产精品乱子久久久久| 亚洲一区二区av电影| 看电影不卡的网站| 不卡高清视频专区| 91福利资源站| 久久久影院官网| 亚洲精品免费在线| 免费高清在线视频一区·| 国产精品91xxx| 欧美三级三级三级| 久久久精品天堂| 亚洲一级二级三级在线免费观看| 18成人在线观看| 蜜芽一区二区三区| 大白屁股一区二区视频| 在线看国产日韩| 久久先锋影音av| 午夜久久福利影院| 成人白浆超碰人人人人| 欧美一级精品在线| ...xxx性欧美| 精品一区二区综合| 91国偷自产一区二区开放时间 | 欧美sm美女调教| 亚洲免费观看在线视频| 天天影视色香欲综合网老头| 成人国产精品免费| 日韩欧美黄色影院| 亚洲第一搞黄网站| 99久久婷婷国产综合精品电影 | 国产在线精品免费| 欧美性色综合网| 中文字幕亚洲视频| 精品一区二区三区在线视频| 色婷婷国产精品综合在线观看| 一本久久精品一区二区| 国产网站一区二区三区| 美女任你摸久久| 欧美高清dvd| 亚洲国产精品一区二区www在线| 香港成人在线视频| 色偷偷成人一区二区三区91 | 不卡的电影网站| 久久久99免费| 精品一区二区三区蜜桃| 制服丝袜亚洲精品中文字幕| 精品国产伦一区二区三区观看方式 | 99国产精品国产精品久久| 日韩女优制服丝袜电影| 日韩一区欧美二区| 欧美在线你懂得| 一区二区三区欧美| 色域天天综合网| 亚洲人精品一区| 91网站最新地址| 中文字幕综合网| 99免费精品在线| 亚洲视频一区二区免费在线观看| 亚洲一区在线看| 欧美三级视频在线播放|