示例#1
0
GLvoid initPolice(){
	/* POS per le prove	
	police[0].pos=g_camera.getPos();
	police[0].pos.x +=10;
	police[0].pos.z +=40;
	
	police[0].dir=directionRel(police[0].pos,me);
	police[0].dirCorr=true;
	police[0].drawExp=true;
	police[0].rad=radiusPolice;
	police[0].index=0;
	police[0].type='p';
	police[0].life=100;
	police[0].move=false;
	*/
	
	for(int i=0;i<NUM_POLICE;i++){
		police[i].pos=pointDir(posPlanet[i], directionRel(posPlanet[i],me), radius[i]+radius[i]/5);
		if(i==2 || i==4)	police[i].pos=pointDir(police[i].pos, g_camera.getUp(), 15);
		if(i==8)		police[i].pos=pointDir(posPlanet[i], directionRel(posPlanet[i],me), radius[i]*2);
		police[i].dir=directionRel(police[i].pos,me);
		police[i].dirCorr=true;
		police[i].drawExp=true;
		police[i].rad=radiusPolice;
		police[i].index=i;
		police[i].type='p';
		police[i].life=100;
		police[i].move=false;
	}
}
示例#2
0
/* DISEGNO DELLE NAVICELLE SPAZIALI (solar_system.c) */
GLvoid insertEnemy(){
	
	// FOR PER TUTTI I NEMICI
	numEnemyDraw=0;	// se il numero di polizia è minore di 2 se ne disegna un'altra fuori dalla sfera dello sfondo
				// questo per evitare che i movimenti (laser, satelliti) siano troppo veloci
	me=g_camera.getPos();
	for(int i=0;i<NUM_ENEMY;i++){
		dist=distance(enemy[i].pos,me);
		if(dist<=DIST_RADAR && enemy[i].life>0){
		//if(enemy[i].life>0){
			setPosDir(&enemy[i]);	// gli passo l'indirizzo di memoria dove sta quella variabile
			drawEnemy(enemyModel,enemy[i].pos,enemy[i].dir);
			numEnemyDraw++;
			//drawShield(enemy[i].pos,radShootEnemy);
			// sparo dei nemici
			if(enemy[i].dirCorr && abs(clock()-enemyClock)>=CLOCKS_PER_SEC*1) 
			{
				newEnemyLaser(i);
				enemyClock=clock();
				glutPostRedisplay();
			}
		}
	}
	while (numEnemyDraw<2){ // disegno tante navette fuori dalla sfera dello sfondo
		extraPos=pointDir(me, g_camera.getUp(), 1200);
		drawEnemy(enemyModel,extraPos,g_camera.getUp());
		numEnemyDraw++;
	}
}
示例#3
0
GLvoid insertPolice(){
	
	// FOR PER TUTTE LE NAVETTE DELLA POLIZIA
	numPoliceDraw=0;	// se il numero di polizia è minore di 2 se ne disegna un'altra fuori dalla sfera dello sfondo
				// questo per evitare che i movimenti (laser, satelliti) siano troppo veloci
	me=g_camera.getPos();
	for(int i=0;i<NUM_POLICE;i++){
		dist=distance(police[i].pos,me);
		if(dist<=DIST_RADAR && police[i].life>0){
		//if(police[i].life>0){	
			if ( (isIllegal() || police[i].life<100) )
			{	// la polizia si muove solo se abbiamo commerciato illegalmente o gli stiamo sparando
				setPosDir(&police[i]);
			}
			drawPolice(policeModel,police[i].pos,police[i].dir);
			numPoliceDraw++;
			//drawShield(police[i].pos,radShootPolice);
			if( (isIllegal() || police[i].life<100) && police[i].dirCorr){
				if(abs(clock()-policeClock)>=CLOCKS_PER_SEC*1) {
					newPoliceLaser(i);
					policeClock=clock();
					glutPostRedisplay();
				}
				//newEnemyLaser(i);
			}
		}
	}
	while (numPoliceDraw<2){ // disegno tante navette fuori dalla sfera dello sfondo
		extraPos=pointDir(me, g_camera.getUp(), 1200);
		drawPolice(policeModel,extraPos,g_camera.getUp());
		numPoliceDraw++;
	}
}
示例#4
0
/*!
From a point on the line compute the section on the line corrisponding to the specified point, the section
is in [0,1] interval, where 0 is the begin and 1 is the end of the line.

\param thePoint
Point on the line to use for section computation

\return
Section of the line computed from thePoint, 0 = begin 1 = end, return -DBL_MAX if the line or thePoinr are
not valid or if thePoint is not on the line
*/
double GM_3dLine::sectionFromPoint(GM_3dPoint thePoint) const {
	double ret = -DBL_MAX;
	if (!isValid() || !thePoint.isValid())
		return ret;

	GM_3dVector lineDir(dx(), dy(), dz());
	lineDir.normalize();
	GM_3dVector pointDir(thePoint.x() - mBegin.x(), thePoint.y() - mBegin.y(), thePoint.z() - mBegin.z());
	pointDir.normalize();

	if (fabs((lineDir * pointDir) - 1.0) < GM_DIFF_TOLERANCE) {
		double distFromBegin = thePoint.distFrom(mBegin);
		double distFromEnd = thePoint.distFrom(mEnd);
		double lineLen = length();
		if (fabs(distFromBegin + distFromEnd - lineLen) < GM_DIFF_TOLERANCE) {
			ret = distFromBegin / lineLen;
		}
	}

	return ret;
}
示例#5
0
void EvtD0gammaDalitz::decay( EvtParticle* part )
{
  // Check if the D is from a B+- -> D0 K+- decay with the appropriate model.
  EvtParticle* parent = part->getParent(); // If there are no mistakes, should be B+ or B-.
  if (parent != 0 && EvtDecayTable::getInstance()->getDecayFunc( parent )->getName() == "BTODDALITZCPK" )
  {
    EvtId parId = parent->getId();
    if ( ( parId == _BP ) || ( parId == _BM ) ||
         ( parId == _B0 ) || ( parId == _B0B) )
    {
      _bFlavor = parId;
    }
    else
    {
      reportInvalidAndExit();
    }
  }
  else
  {
    reportInvalidAndExit();
  }

  // Read the D decay parameters from the B decay model.
  // Gamma angle in rad.
  double gamma = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 0 );
  // Strong phase in rad.
  double delta = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 1 );
  // Ratio between B->D0K and B->D0barK
  double rB    = EvtDecayTable::getInstance()->getDecayFunc( parent )->getArg( 2 );

  // Same structure for all of these decays.
  part->initializePhaseSpace( getNDaug(), getDaugs() );
  EvtVector4R pA = part->getDaug( _d1 )->getP4();
  EvtVector4R pB = part->getDaug( _d2 )->getP4();
  EvtVector4R pC = part->getDaug( _d3 )->getP4();

  // Squared invariant masses.
  double mSqAB = ( pA + pB ).mass2();
  double mSqAC = ( pA + pC ).mass2();
  double mSqBC = ( pB + pC ).mass2();

  EvtComplex amp( 1.0, 0.0 );

  // Direct and conjugated amplitudes.
  EvtComplex ampDir;
  EvtComplex ampCnj;

  if ( _isKsPiPi )
  {
    // Direct and conjugated Dalitz points.
    EvtDalitzPoint pointDir( _mKs, _mPi, _mPi, mSqAB, mSqBC, mSqAC );
    EvtDalitzPoint pointCnj( _mKs, _mPi, _mPi, mSqAC, mSqBC, mSqAB );

    // Direct and conjugated amplitudes.
    ampDir = dalitzKsPiPi( pointDir );
    ampCnj = dalitzKsPiPi( pointCnj );
  }
  else
  {
    // Direct and conjugated Dalitz points.
    EvtDalitzPoint pointDir( _mKs, _mK, _mK, mSqAB, mSqBC, mSqAC );
    EvtDalitzPoint pointCnj( _mKs, _mK, _mK, mSqAC, mSqBC, mSqAB );

    // Direct and conjugated amplitudes.
    ampDir = dalitzKsKK( pointDir );
    ampCnj = dalitzKsKK( pointCnj );
  }

  if ( _bFlavor == _BP || _bFlavor == _B0 )
  {
    amp = ampCnj + rB * exp( EvtComplex( 0., delta + gamma ) ) * ampDir;
  }
  else
  {
    amp = ampDir + rB * exp( EvtComplex( 0., delta - gamma ) ) * ampCnj;
  }

  vertex( amp );

  return;

}