当前位置: 首页>>代码示例>>C++>>正文


C++ Vec3d::add_mul方法代码示例

本文整理汇总了C++中Vec3d::add_mul方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3d::add_mul方法的具体用法?C++ Vec3d::add_mul怎么用?C++ Vec3d::add_mul使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vec3d的用法示例。


在下文中一共展示了Vec3d::add_mul方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sampleGridArroundAtoms

//  sampleGridArroundAtoms
//  	takes from a 3D grid values at grid points which are in area between $atom_Rmin[i] to $atom_Rmaxs[i] distance from any i-th atom at position $atom_posp[i]
//		if $canStore == true it will save values to $sampled_val and postions to $sampled_pos else it only returns number of gridpoints fullfilling the conditions
int sampleGridArroundAtoms( 
	int natoms, Vec3d * atom_pos_, double * atom_Rmin, double * atom_Rmax, bool * atom_mask, 
	double * sampled_val, Vec3d * sampled_pos_, bool canStore, bool pbc, bool show_where
){
	Vec3d * atom_pos    = (Vec3d*) atom_pos_;
	Vec3d * sampled_pos = (Vec3d*) sampled_pos_;
	int nx  = GRID::n.x;
	int ny  = GRID::n.y;
	int nz  = GRID::n.z;
	int nxy = ny * nx; // used in macro i3D( ia, ib, ic )
	Vec3d rProbe;  rProbe.set( 0.0, 0.0, 0.0 ); // we may shift here
	int points_found = 0;
	int nimg = 1; if (pbc) nimg = 27; // PBC ?
	for ( int ia=0; ia<nx; ia++ ){ 
		//printf( " ia %i \n", ia );
		rProbe.add( GRID::dCell.a );  
		for ( int ib=0; ib<ny; ib++ ){ 
			rProbe.add( GRID::dCell.b );
			for ( int ic=0; ic<nz; ic++ ){
				rProbe.add( GRID::dCell.c );
				bool withinRmin = false; 
				bool withinRmax = false; 
				for ( int iimg=0; iimg<nimg; iimg++ ){
					Vec3d cell_shift;
					cell_shift.set_lincomb( images[iimg][0], images[iimg][1], images[iimg][2], GRID::cell.a, GRID::cell.b, GRID::cell.c );
					for ( int iatom=0; iatom<natoms; iatom++ ){
						Vec3d dr;
						dr.set_sub( rProbe, atom_pos[iatom] );
						dr.sub( cell_shift ); 
						double r2   = dr.norm2();
						double rmin = atom_Rmin[iatom];
						double rmax = atom_Rmax[iatom];
						if( r2<(rmax*rmax) ){ 
							if( atom_mask[iatom] ){ withinRmax = true; }  
							if( r2<(rmin*rmin)   ){ withinRmin = true; break; }
						}
					}
				}
				if( withinRmax && (!withinRmin) ){
					if( canStore ){
						sampled_val[points_found] = GRID::grid[ i3D( ia, ib, ic ) ];
						if( show_where ) GRID::grid[ i3D( ia, ib, ic ) ] = +100.0d;
						sampled_pos[points_found].set( rProbe );
					}
					points_found++;
				}
			} 
			rProbe.add_mul( GRID::dCell.c, -nz );
		} 
		rProbe.add_mul( GRID::dCell.b, -ny );
	}
	return points_found;
}
开发者ID:ProkopHapala,项目名称:ProbeParticleModel,代码行数:56,代码来源:Multipoles.cpp

示例2: eventHandling

void TestAppMesh::eventHandling ( const SDL_Event& event  ){
    //printf( "NonInert_seats::eventHandling() \n" );
    switch( event.type ){
        case SDL_KEYDOWN :
            switch( event.key.keysym.sym ){
                case SDLK_p:  first_person = !first_person; break;
                case SDLK_o:  perspective  = !perspective; break;
                //case SDLK_r:  world.fireProjectile( warrior1 ); break;
            }
            break;
        case SDL_MOUSEBUTTONDOWN:
            switch( event.button.button ){
                case SDL_BUTTON_LEFT:
                    Vec3d ray0;
                    ray0.set_lincomb( 1, mouse_begin_x, mouse_begin_y, camPos, camMat.a, camMat.b );
                    //glColor3f(1,1,1); Draw3D::drawPointCross( ray0, 0.2 );
                    ipicked= mesh.pickVertex( ray0, camMat.c );
                    mouse0.set(mouse_begin_x, mouse_begin_y);
                    dragging=true;
                    break;
            }
            break;
        case SDL_MOUSEBUTTONUP:
            switch( event.button.button ){
                case SDL_BUTTON_LEFT:
                    if(dragging){
                        Vec3d d;
                        d.set_lincomb( 1, mouse_begin_x, mouse_begin_y, camPos, camMat.a, camMat.b );
                        d.sub(mesh.points[ipicked]);
                        double c = d.dot(camMat.c);  d.add_mul(camMat.c, -c);
                        mesh.points[ipicked].add(d);

                        glDeleteLists(mesh.rendered_shape, 1);
                        mesh.rendered_shape = glGenLists(1);
                        glNewList( mesh.rendered_shape , GL_COMPILE );
                            glEnable( GL_LIGHTING );
                            glColor3f( 0.8f, 0.8f, 0.8f );
                            Draw3D::drawMesh( mesh );
                            mesh.tris2normals(true);
                            glColor3f(0.0f,0.0f,0.9f);
                            for(int i=0; i<mesh.points.size(); i++){
                                Draw3D::drawVecInPos( mesh.normals[i], mesh.points[i] );
                            }
                        glEndList();
                    }
                    dragging=false;
                    break;
            }
    };
    AppSDL2OGL::eventHandling( event );
}
开发者ID:ProkopHapala,项目名称:SimpleSimulationEngine,代码行数:51,代码来源:test_Mesh.cpp

示例3: drawForces

    void drawForces( double scale, bool DEBUG ){
	    if( ( world.truss.points != NULL )&&( world.truss.forces != NULL ) ){
            glBegin( GL_LINES );
            for( int i=0; i<world.truss.npoints; i++ ){
                Vec3d& p  =  world.truss.points[i];
                Vec3d& f  =  world.truss.forces[i];
                Vec3d  pf; pf.set(p); pf.add_mul( f, scale );
                glVertex3f( (float)p.x, (float)p.y, (float)p.z );
                glVertex3f( (float)pf.x, (float)pf.y, (float)pf.z );
                if( DEBUG ){
                    //printf( " %i  %i %i   (%3.3f,%3.3f,%3.3f)  (%3.3f,%3.3f,%3.3f)\n",  i,   bond.i, bond.j,  pi.x, pi.y, pi.z,  f.x, f.y, f.z  );
                    printf( " %i  (%3.3f,%3.3f,%3.3f) \n",  i, f.x, f.y, f.z  );
                }
            }
            glEnd();
	    }
	}
开发者ID:ProkopHapala,项目名称:SimpleSimulationEngine,代码行数:17,代码来源:main.cpp


注:本文中的Vec3d::add_mul方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。