コード例 #1
0
ファイル: graph3d.cpp プロジェクト: AspireONE/berusky2
void graph3d::grid_draw(void)
{  
  mesh_material::set_default();
  
  VECT vn(0.0f,0.0f,-1.0f);
  VECT vf(0.0f,0.0f, 1.0f);
  
  GPIPE *p_gpipe = gpipe_get();
  p_gpipe->screen_normal_to_world(&vn);
  p_gpipe->screen_normal_to_world(&vf);
  
  // v1->v2 
  VECT dir;
  dir  = vf-vn;
  dir *= 0.5f;  
  vn  += dir;
  vn.y = 0.0f;
  
  VECT vl(-1.0f,0.0f,1.0f);
  VECT vr( 1.0f,0.0f,1.0f);
  
  p_gpipe->screen_normal_to_world(&vl);
  p_gpipe->screen_normal_to_world(&vr);
  
  VECT width;
  width = vr-vl;
  draw_floor_line(&vn,width.size(),2,40);
}
コード例 #2
0
//This calculates the potential energy of an Alavi Hydrogen at a particular centre of mass position and orientation
double CoulombPotential(interfaceStor *interface, H2_orient *lin_mol) {
	
	double potential, q_centre, q_mol, V_ceil;
	VECT zeroVec;
	
	
	
	zeroVec.DIM(3);
	zeroVec.COOR(0) = 0.0;
	zeroVec.COOR(1) = 0.0;
	zeroVec.COOR(2) = 0.0;
	
	q_centre = interface->potential->centreCharge;
	q_mol = interface->potential->molCharge;
	V_ceil = interface->potential->coulombPotentialCeil;
	
	potential = CoulombEng(zeroVec, q_centre, *(lin_mol->CM), q_mol);
	
	//potential =0.0;
	
	if (fabs(potential) > fabs(V_ceil)) {
		potential = V_ceil;
	} 
	
	return potential;
}
コード例 #3
0
ファイル: mn_vect.cpp プロジェクト: mnogala/csvfilter
void VECT::CopyFrom(VECT& hg)
{
int nel = hg.Nelem();
if(!nel)
  {
   Free();
   size = hg.Size();
   return;
  }
int s = hg.Size();
if(!s)
  {
   Free();
   size = 0;
   return;
  }

Alloc(nel, s);
memcpy(ptr, hg.Ptr(), nbytes);
}
コード例 #4
0
ファイル: find.cpp プロジェクト: wmgaca/facebook-hacker-cup
INT solve(INT n, INT k, INT a, INT b, INT c, INT r) {
		
		VECT* m = new VECT();
		MAP* used = new MAP();

		gen(a, b, c, r, k, m, used);

		VECT* unused = new VECT();
		for (INT x = 0; x < 2*k; ++x) {
				if (used->find(x) == used->end()) {
						unused->push_back(x);
				}
		}

		m->push_back((*unused)[0]);
		(*used)[(*unused)[0]] = 1;
		unused->pop_front();

		INT last = m->size() - 1;
		INT limit = 2 * k;
		INT currval;

		printf("limit = %lu\n", limit);

		while (last != 2 * k) {
				if (last % 100 == 0) {
						printf("%d %lu\n", m->size(), last);
						
				}
						
				currval = (*m)[0];

				if (unused->size() == 0) {
						printf("Big bad error (n=%lu, k=%lu)\n", n, k);
						return 0;
				}

				if (used->find(currval) == used->end()) {
						(*used)[currval] = 0;
				}
				
				if ((*used)[currval] == 0) {
						if (currval < (*unused)[0]) {
								m->push_back(currval);
								(*used)[currval] = 1;
						} else {
								m->push_back((*unused)[0]);
								(*used)[(*unused)[0]] = 1;
								unused->pop_front();
								unused->push_back(currval);
								sort(unused->begin(), unused->end());
						}
				} else if ((*used)[currval] > 1) {
						(*used)[currval] -= 1;
						m->push_back((*unused)[0]);
						unused->pop_front();
				} else if ((*used)[currval] == 1) {
						if (currval < (*unused)[0]) {
								m->push_back(currval);
						} else {
								(*used)[currval] = 0;
								m->push_back((*unused)[0]);
								(*used)[(*unused)[0]] = 1;
								unused->pop_front();
								unused->push_back(currval);
								sort(unused->begin(), unused->end());
								/*
								x = (*unused)[unused->size() - 1];
								while (true) {
										if (used->find(x) == used->end()) {
												unused->push_back(x);
												break;
										}
										++x;
								}// */		
						}
				}

				m->pop_front();
				++last;
		}
		printf("Done...\n");

		printf("m->size() = %lu\n", (INT)m->size()); 
		return m->back();
}