//--------------------------------------------------------------
void testApp::update()
{
	kinect.update();

	if(kinect.isNewSkeleton()) {
		for( int i = 0; i < kinect.getSkeletons().size(); i++) 
		{

			if(kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD) != kinect.getSkeletons().at(i).end())
			{

				// just get the first one
				SkeletonBone headBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD)->second;
				SkeletonBone lHandBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_LEFT)->second;
				SkeletonBone rHandBone = kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_RIGHT)->second;
				ofVec3f hb( headBone.getScreenPosition().x, headBone.getScreenPosition().y, 0 );
				head = head.getInterpolated(hb, 0.5);
				head.z =  ofInterpolateCosine( head.z, headBone.getStartPosition().x, 0.5) + 0.1;
				ofVec3f lhb(lHandBone.getScreenPosition().x, lHandBone.getScreenPosition().y, 0);
				lHand = lHand.getInterpolated( lhb, 0.5);
				lHand.z = ofInterpolateCosine( lHand.z, lHandBone.getStartPosition().x, 0.5);
				ofVec3f rhb(rHandBone.getScreenPosition().x, rHandBone.getScreenPosition().y, 0);
				rHand = rHand.getInterpolated( rhb, 0.5);
				rHand.z = ofInterpolateCosine( rHand.z, rHandBone.getStartPosition().x, 0.5);

				cout << headBone.getScreenPosition()  << endl;
				cout << rHandBone.getScreenPosition() << endl;
				cout << lHandBone.getScreenPosition() << endl;

				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HEAD)->second.getScreenPosition() << endl;
				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_LEFT)->second.getScreenPosition() << endl;
				//cout << kinect.getSkeletons().at(i).find(NUI_SKELETON_POSITION_HAND_RIGHT)->second.getScreenPosition() << endl;

				jointDistance = head.distance(rHand);
				jointDistance += lHand.distance(rHand);
				jointDistance += lHand.distance(head);

				hasSkeleton = true;

				return;
			}
		}
	}
}
Exemple #2
0
  void EAM::calcForce(InteractionData &idat) {

    if (!initialized_) initialize();

    if (haveCutoffRadius_) 
      if ( *(idat.rij) > eamRcut_) return;
   

    int eamtid1 = EAMtids[idat.atid1];
    int eamtid2 = EAMtids[idat.atid2];
    
    EAMAtomData &data1 = EAMdata[eamtid1];
    EAMAtomData &data2 = EAMdata[eamtid2];
    
    // get type-specific cutoff radii
    
    RealType rci = data1.rcut;
    RealType rcj = data2.rcut;
    
    RealType rha(0.0), drha(0.0), rhb(0.0), drhb(0.0);
    RealType pha(0.0), dpha(0.0), phb(0.0), dphb(0.0);
    RealType phab(0.0), dvpdr(0.0);
    RealType drhoidr, drhojdr, dudr;
    
    if ( *(idat.rij) < rci) {
      data1.rho->getValueAndDerivativeAt( *(idat.rij), rha, drha);
      CubicSpline* phi = MixingMap[eamtid1][eamtid1].phi;
      phi->getValueAndDerivativeAt( *(idat.rij), pha, dpha);
    }
    
    if ( *(idat.rij) < rcj) {
      data2.rho->getValueAndDerivativeAt( *(idat.rij), rhb, drhb );
      CubicSpline* phi = MixingMap[eamtid2][eamtid2].phi;
      phi->getValueAndDerivativeAt( *(idat.rij), phb, dphb);
    }

    switch(mixMeth_) {
    case eamJohnson:
      
      if ( *(idat.rij) < rci) {
        phab = phab + 0.5 * (rhb / rha) * pha;
        dvpdr = dvpdr + 0.5*((rhb/rha)*dpha + 
                             pha*((drhb/rha) - (rhb*drha/rha/rha)));
      }
      
      
      
      if ( *(idat.rij) < rcj) {
        phab = phab + 0.5 * (rha / rhb) * phb;
        dvpdr = dvpdr + 0.5 * ((rha/rhb)*dphb + 
                               phb*((drha/rhb) - (rha*drhb/rhb/rhb)));
      }
      
      break;
      
    case eamDaw:
      
      if ( *(idat.rij) <  MixingMap[eamtid1][eamtid2].rcut) {
        MixingMap[eamtid1][eamtid2].phi->getValueAndDerivativeAt( *(idat.rij), 
                                                                  phab, dvpdr);
      }
      
      break;
    case eamUnknown:
    default:
      
      sprintf(painCave.errMsg,
              "EAM::calcForce hit a mixing method it doesn't know about!\n"
              );
      painCave.severity = OPENMD_ERROR;
      painCave.isFatal = 1;
      simError();        
      
    }
    
    drhoidr = drha;
    drhojdr = drhb;
    
    dudr = drhojdr* *(idat.dfrho1) + drhoidr* *(idat.dfrho2) + dvpdr; 
    
    *(idat.f1) += *(idat.d) * dudr / *(idat.rij);

        
    if (idat.doParticlePot) {
      // particlePot is the difference between the full potential and
      // the full potential without the presence of a particular
      // particle (atom1).
      //
      // This reduces the density at other particle locations, so we
      // need to recompute the density at atom2 assuming atom1 didn't
      // contribute.  This then requires recomputing the density
      // functional for atom2 as well.
      
      *(idat.particlePot1) += data2.F->getValueAt( *(idat.rho2) - rha ) 
        - *(idat.frho2);
      
      *(idat.particlePot2) += data1.F->getValueAt( *(idat.rho1) - rhb) 
        - *(idat.frho1);
    }
    
    (*(idat.pot))[METALLIC_FAMILY] += phab;
    
    *(idat.vpair) += phab;
  
    return;
    
  }