示例#1
0
void HoleFinderPrivate::buildGrid()
{
  const Eigen::Vector3d v1Step (this->v1.normalized() * this->resolution);
  const Eigen::Vector3d v2Step (this->v2.normalized() * this->resolution);
  const Eigen::Vector3d v3Step (this->v3.normalized() * this->resolution);
  Eigen::Vector3d v1Base;
  Eigen::Vector3d v2Base;
  Eigen::Vector3d v3Base;
  const int v1Steps = floor(v1Norm / this->resolution);
  const int v2Steps = floor(v2Norm / this->resolution);
  const int v3Steps = floor(v3Norm / this->resolution);

  this->holes.clear();
  this->holes.reserve(v1Steps * v2Steps * v3Steps);

  for (int a = 0; a <= v1Steps; ++a) {
    v1Base = v1Step * a;
    for (int b = 0; b <= v2Steps; ++b) {
      v2Base = v2Step * b;
      for (int c = 0; c <= v3Steps; ++c) {
        v3Base = v3Step * c;
        this->holes.push_back(Hole(v1Base + v2Base + v3Base, 0.0));
      }
    }
  }
  DEBUGOUT("buildGrid") "Initial grid constructed. Number of holes:"
      << this->holes.size();
}
示例#2
0
Hole HoleFinderPrivate::reduceHoles(const QVector<Hole *> &holeVec)
{
  // Average the positions, weighted by volume
  Eigen::Vector3d center (0.0, 0.0, 0.0);
  double denom = 0.0;
  foreach (Hole *hole, holeVec) {
    const double volume = hole->volume();
    center += hole->center * volume;
    denom += volume;
  }
  center /= denom;

  // Wrap center into the unit cell
  this->cartToFrac(&center);
  if ((center.x() = fmod(center.x(), 1.0)) < 0) ++center.x();
  if ((center.y() = fmod(center.y(), 1.0)) < 0) ++center.y();
  if ((center.z() = fmod(center.z(), 1.0)) < 0) ++center.z();
  this->fracToCart(&center);

  return Hole(center, 0.0); // radius is set during resizeHoles();
}
示例#3
0
int main( int argv, char* argc[])
{
    //create the hole objects
    Hole Hole1 = Hole(100, -5);
    Hole Hole2 = Hole(80, 20);
    Hole Hole3 = Hole(75, -10);
    Hole Hole4 = Hole(90, 0);
    Hole Hole5 = Hole(60, 15);
    
    int score = 0;
    int currentHole = 1;    
    int player;   
    
    //call title screen
    player = title_screen();
    //return num 1-4
    //create all four playable characters
    Player jimmy = Player("Jimmy Mickle",5,4,"../../music/Harder_than_you_think.wav");
    Player nick = Player("Nick Lance",4,5,"../../music/Mind_heist.wav");
    Player dylan = Player("Dylan Freechild",3,5,"../../music/Who_did_that_to_you.wav");
    Player dan = Player("Dan Bolivar",2,2,"../../music/Hymn.wav");
    Player *myPlayer = NULL;
 
    //choose player from title screen
    switch(player) {
    	case 1:
    		myPlayer = &jimmy;
    		break;
    	case 2:
    		myPlayer = &nick;
    		break;
    	case 3:
    		myPlayer = &dylan;
    		break;
    	case 4:
    		myPlayer = &dan;
    		break;
    	default:
    		myPlayer = &jimmy;
		break;
    }
    
    // choose the current hole to play
    while( currentHole < 6)
    {
        switch( currentHole )
        {
            case 1: 
              playHole(1, Hole1, *myPlayer, &score);
            break;
            case 2: 
              playHole(2, Hole2, *myPlayer, &score);
            break;
            case 3: 
              playHole(3, Hole3, *myPlayer, &score);
            break;
            case 4: 
              playHole(4, Hole4, *myPlayer, &score);
            break;
            case 5: 
              playHole(5, Hole5, *myPlayer, &score);
            break;
        }  
        
        //increment current hole
        currentHole++;
    }
    
    clean_up();
    
    return 0;
}
示例#4
0
void HoleManager::add(ofPoint& point) {
	holes.push_back(Hole());
	holes.back().setup(point);
}