⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proj_points.c

📁 任意给定三维空间的点集
💻 C
字号:
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* * proj_points.C - *     Project points to a 2d grid, and remove bottom and top  * point from each slab...\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/#include  <iostream>#include  <assert.h>#include  <stdlib.h>#include  <stdio.h>#include  <time.h>#include  <math.h>#include  <queue>#include  <qapplication.h>#include  <qgl.h>//'#include  "dmalloc.h"#include  "_generic.h"#include  "sarray.h"#include  "real.h"#include  "point.h"#include  "bbox.h"#include  "ftree.h"#include  "ftreeptr.h"#include  "ftree2d.h"#include  "TreeDiam.h"#include  "algorithm.h"#include  "proj_points.h"/*--- Constants ---*//*--- Start of Code ---*/void   ProjPoints::do_projection( ArrPoint3d  & _arr ) {    x_vec_n.normalize();    y_vec_n.normalize();    //z_vec.normalize();        if  ( fabs( x_vec_n.dot_prod( y_vec_n ) ) > REAL_EPSILON ) {        x_vec_n.print();        y_vec_n.print();        fflush( stdout );        assert( fabs( x_vec_n.dot_prod( y_vec_n ) ) <= REAL_EPSILON );    }    if  ( fabs( x_vec_n.dot_prod( z_vec ) ) > REAL_EPSILON ) {        x_vec_n.print();        printf( "\n" );        z_vec.print();        printf( "\nvalue: %g\n",fabs( x_vec_n.dot_prod( z_vec ) ) );        fflush( stdout );        assert( fabs( x_vec_n.dot_prod( z_vec ) ) <= REAL_EPSILON );    }    assert( fabs( y_vec_n.dot_prod( z_vec ) ) <= REAL_EPSILON );        arr.init( _arr.size(), 453565 );        for  ( int  ind = 0; ind < _arr.size(); ind++ ) {        Point2d  pnt( x_vec_n.dot_prod( _arr[ ind ] ),                      y_vec_n.dot_prod( _arr[ ind ] ) );        //printf( "id: %d\n", _arr[ ind ].getID() );        pnt.setID( _arr[ ind ].getID() );        arr.pushx( pnt );    }}void  ProjPoints::init( ArrPoint3d  & _arr, Point3d  & dir ) {    assert( dir.length() != 0.0 );        z_vec = dir;        if  ( ( dir[ 0 ] != 0.0 )  ||  ( dir[ 1 ] != 0.0 ) ) {        x_vec_n = Point3d( -dir[ 1 ], dir[ 0 ], 0 );        y_vec_n = cross_prod( dir, x_vec_n );        do_projection( _arr );        return;    }    x_vec_n = Point3d( 1, 0, 0 );    y_vec_n = Point3d( 0, 1, 0 );    do_projection( _arr );}void  ProjPoints::grid_clean( int  num,                              ArrPoint2dPtr  &  out_arr ){    BBox2d  bb;    ArrPoint2dPtr  tops, bottoms;    real  min_x, delta_x;    out_arr.init( 2 * num, 43534 );    assert( num > 0 );    bb.init();    for  ( int  ind = 0; ind < arr.size(); ind++ )         bb.bound( arr[ ind ] );        min_x = bb.get_min_coord( 0 );    delta_x = ( bb.get_max_coord( 0 ) - min_x ) * 1.000001 / (double)num;    tops.init( num, 453 );    bottoms.init( num, 453 );    for  ( int  ind = 0; ind < num; ind++ ) {        tops.pushx( NULL );        bottoms.pushx( NULL );    }    for  ( int  ind = 0; ind < arr.size(); ind++ ) {        int  bucket;        bucket = (int)( ( (arr[ ind ])[ 0 ] - min_x ) / delta_x );        assert( ( 0 <= bucket )  &&  ( bucket < num ) );        if  ( ( tops[ bucket ] == NULL )               ||  ( (*(tops[ bucket ]))[ 1 ] < (arr[ ind ])[ 1 ] ) )             tops[ bucket ] = &( arr[ ind ] );        if  ( ( bottoms[ bucket ] == NULL )               ||  ( (*(bottoms[ bucket ]))[ 1 ] > (arr[ ind ])[ 1 ] ) )             bottoms[ bucket ] = &( arr[ ind ] );    }    for  ( int  ind = 0; ind < num; ind++ ) {        if  ( ( tops[ ind ] != NULL )                &&  ( tops[ ind ] == bottoms[ ind ] ) ) {            out_arr.pushx( tops[ ind ] );            continue;        }        if  ( tops[ ind ] != NULL )              out_arr.pushx( tops[ ind ] );        if  ( bottoms[ ind ] != NULL )              out_arr.pushx( bottoms[ ind ] );    }    }/* proj_points.C - End of File ------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -