Révision 350
Ajouté par Yaye Oumy NDONG il y a environ 3 ans
branch/Ndong_Yaye_Oumy/sp4a12/main.c | ||
---|---|---|
int distance_a_la_plus_proche_zone(Position p,Zone r[],int nb_zones,float *d)
|
||
{
|
||
float d1;
|
||
int a,i;
|
||
int a=0,i;
|
||
*d=calcul_distance(p, r[0].rpos); // on calcule la distance entre la position actuelle et la premiere zone dangereuse du tableau
|
||
if(nb_zones==0)a=-1;
|
||
for(i=1;i<nb_zones;i++)
|
||
for(i=1;i<nb_zones;++i)
|
||
{
|
||
d1=calcul_vitesse(p, r[i].rpos); // a chaque it?ration on calcule la distance entre la position actuelle et une zone dangeureuse
|
||
if(d1<(*d)){ // si cette distance est inf?rieure ? la distance d calcul?e,on remplace d par cette nouvelle distance
|
||
... | ... | |
if(decode_trame(trame,&p))
|
||
{
|
||
printf("latitude:%f longitude:%f \n", p.latitude,p.longitude);
|
||
}*/
|
||
|
||
}
|
||
Position p1={45.750000,3.11006};
|
||
float d;
|
||
int a;
|
||
int nb_zones=4;
|
||
a=distance_a_la_plus_proche_zone(p1,zones,nb_zones,&d);
|
||
printf("%d",a); */
|
||
}
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
Position* p2; // pour tester decode_trame
|
||
p=&a; // on affecte ? chache pointeur l'adresse d'une stru
|
||
p2=&b;
|
||
float d;
|
||
int nb_zones=4;
|
||
|
||
if (5!=5){
|
||
printf ("Erreur Test unitaire basique.\n");
|
||
... | ... | |
printf ("Erreur Test unitaire calcul_vitesse.\n");
|
||
exit(-1);
|
||
}
|
||
if(distance_a_la_plus_proche_zone(p1,zones,nb_zones,&d)!=0){ //test distance_a_la_plus_proche (prise en compte de l'erreur)
|
||
printf ("Erreur Test unitaire calcul_distance_plus_proche.\n");
|
||
exit(-1);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
Formats disponibles : Unified diff
implantation de la fonction distance_a_la_plus_proche_zone