Example #1
0
File: tp5.cpp Project: dtbinh/M1S2
bool voxelAppartientCylindre(Point origine, Vector vecteur,double rayon, Voxel v){

	Point limite(origine.getX()+vecteur.getX(), origine.getY()+vecteur.getY(),origine.getZ()+vecteur.getZ());
	int distancePointProjete;
	int distanceOrigineProjete;

	for( int i = 0; i<8; i++ ){
		Point projete(v.getSommet(i).projectOnLine(origine,limite));
		distancePointProjete = sqrt( pow(v.getSommet(i).getX()-projete.getX(),2)
				           + pow(v.getSommet(i).getY()-projete.getY(),2) 
				           + pow(v.getSommet(i).getZ()-projete.getZ(),2) 
				   );

		distanceOrigineProjete = sqrt( pow(origine.getX()-projete.getX(),2)
				      	     + pow(origine.getY()-projete.getY(),2) 
				             + pow(origine.getZ()-projete.getZ(),2) 
				   );				   
				   
		if( distancePointProjete > rayon || projete.getY() < origine.getY() || projete.getY() > limite.getY()   ){
			return false;
		}

	}
	
	return true;
}
Example #2
0
mur * trouver_mur(coordonnee * depart, double d_x, double d_y, carte * map, int boolean)
{
  int i, j;
  coordonnee * point;
  double val_distance_point, val_portion_texture;
  point = coordonnee_cp(depart);
  while(limite(point)){

    i = coordonnee_get_x(point) / 100;
    j = coordonnee_get_y(point) / 100;

    if(carte_get_info(map,i,j) != 0){
      val_distance_point = distance_point(depart, point);
      val_portion_texture = gen_portion_texture(point, boolean);
      coordonnee_free(point);
      return mur_new(carte_get_info(map,i,j), val_distance_point, val_portion_texture);
    }
    if(carte_get_info(map,i-1,j) != 0){
      val_distance_point = distance_point(depart, point);
      val_portion_texture = gen_portion_texture(point, boolean);
      coordonnee_free(point);
      return mur_new(carte_get_info(map,i-1,j), val_distance_point, val_portion_texture);
    }
    if(carte_get_info(map,i,j-1) != 0){
      val_distance_point = distance_point(depart, point);
      val_portion_texture = gen_portion_texture(point, boolean);
      coordonnee_free(point);
      return mur_new(carte_get_info(map,i,j-1), val_distance_point, val_portion_texture);
    }
    if(carte_get_info(map,i-1,j-1) != 0){
      val_distance_point = distance_point(depart, point);
      val_portion_texture = gen_portion_texture(point, boolean);
      coordonnee_free(point);
      return mur_new(carte_get_info(map,i-1,j-1), val_distance_point, val_portion_texture);}
    
    //on avance à la prochaine intersection
    coordonnee_set_x(point, coordonnee_get_x(point) + d_x);
    coordonnee_set_y(point, coordonnee_get_y(point) + d_y);
  }
  coordonnee_set_x(point, MAX_X);
  coordonnee_set_y(point, MAX_Y);
  val_distance_point = distance_point(depart, point);
  coordonnee_free(point);
  return  mur_new(-1, val_distance_point, 0);
}
Example #3
0
void axele(double *d)
{
int c;
double zero[3];
void limite(double *d,double *e);
void drawaxe(double *f);
	puts("Did you want axes ? (y/n)");
	flushall();
	c=bioskey(0);
	if(c==5465||c==5497)
	{
		limite(d,zero);
		drawaxe(zero);
	}
	else
		cleardevice();
	return;
}
Example #4
0
File: tp5.cpp Project: dtbinh/M1S2
bool voxelHorsCylindre(Point origine, Vector vecteur,double rayon, Voxel v){

	Point limite(origine.getX()+vecteur.getX(), origine.getY()+vecteur.getY(),origine.getZ()+vecteur.getZ());
	int distancePointProjete;

	for( int i = 0; i<8; i++ ){
		Point projete(v.getSommet(i).projectOnLine(origine,limite));
		distancePointProjete = sqrt( pow(v.getSommet(i).getX()-projete.getX(),2)
				           + pow(v.getSommet(i).getY()-projete.getY(),2) 
				           + pow(v.getSommet(i).getZ()-projete.getZ(),2) 
				   );			   
	
		if( distancePointProjete <= rayon && projete.getY() >= origine.getY() && projete.getY() <= limite.getY()   ){
			return false;
		}

	}
	
	return true;
}
Example #5
0
File: tp5.cpp Project: dtbinh/M1S2
std::vector<Voxel> cylindreVolumique(Point origineAxe, Vector axeVecteur, double rayon,double resolution){

	afficheCylindre(10);

	Point limite(origineAxe.getX()+axeVecteur.getX(), origineAxe.getY()+axeVecteur.getY(),origineAxe.getZ()+axeVecteur.getZ());
	int distanceLimite = sqrt( pow(limite.getX()-origineAxe.getX(),2) + pow(limite.getY()-origineAxe.getY(),2) + pow(limite.getZ()-origineAxe.getZ(),2) );
	Voxel v(origineAxe, distanceLimite);
	
	std::vector<Voxel> listeVoxel;

	if( voxelAppartientCylindre(origineAxe,axeVecteur, rayon,v)){
		listeVoxel.push_back(v);
	}else if ( v.getRayon() > resolution){
	
		for(int i=0; i<8; i++){
		
			Point centreSubVoxel( 	(v.getSommet(i).getX()+origineAxe.getX())/2,
						(v.getSommet(i).getY()+origineAxe.getY())/2, 
						(v.getSommet(i).getZ()+origineAxe.getZ())/2
					);				
						
			Voxel voxel(centreSubVoxel, distanceLimite/2);
			
			if(voxelAppartientCylindre(origineAxe,axeVecteur, rayon,voxel)){
				listeVoxel.push_back(voxel);
			}else if (!voxelHorsCylindre(origineAxe,axeVecteur, rayon,voxel)){
				std::vector<Voxel> listeTmp;
				listeTmp = voxelCylindre(origineAxe, axeVecteur, rayon, centreSubVoxel, distanceLimite/2, resolution);
				
				for(Voxel vox : listeTmp){
					listeVoxel.push_back(vox);
				}
			}
		}
	}
	
	return listeVoxel;
}