Exemple #1
0
  bool Tile::overlap(const Tile& tile)const noexcept{
    for(int i=0, j=1; i<4; ++i, j=(i+1)%4){
      for(int k=0, l=1; k<4; ++k, l=(k+1)%4){
	if(IsCrossLines(at(i), at(j), tile.at(k), tile.at(l))){
	  return true;
	}
      }
    }
    return false;
  }
Exemple #2
0
  EdgePairor0 OverlapEdge(const Tile& lhs, const Tile& rhs)noexcept{
    bool plus=false;
    const auto diff
      =abs(lhs.at(0)-rhs.at(1))-abs(lhs.at(0)-rhs.at(3));
    switch(rhs.getDegree() - lhs.getDegree()){
    case 72:
      plus=true;
    case -72:
      if(lhs.getType()!=rhs.getType()){
	return boost::none;
      }else if(plus){
	return EdgePair{3,0};
      }else{
	return EdgePair{0,3};
      }
      break;
    case 144:
      plus=true;
    case -144:
      if(lhs.getType()==TileType::Kite){
	if(rhs.getType()==TileType::Kite){
	  if(plus){
	    return EdgePair{1,2};
	  }else{
	    return EdgePair{2,1};
	  }
	}else{
	  if(plus){
	    return EdgePair{1,1};
	  }else{
	    return EdgePair{2,2};
	  }
	}
      }else{
	if(rhs.getType()==TileType::Kite){
	  if(plus){
	    return EdgePair{2,2};
	  }else{
	    return EdgePair{1,1};
	  }
	}else{
	  return boost::none;
	}
      }
      break;
    case 180:
      if(lhs.getType()==rhs.getType()){
	return boost::none;
      }else if(diff==0.0){
	return boost::none;
      }else if(diff<0.0){
	return EdgePair{0,0};
      }else{
	return EdgePair{3,3};
      }
      break;
    default:
      break;
    }
    return boost::none;
  }