Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3016 connectés 

  FORUM HardWare.fr
  Programmation
  Ada

  Calcul de d'une orthodromie avec Ada

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Calcul de d'une orthodromie avec Ada

n°2204436
Profil sup​primé
Posté le 27-09-2013 à 17:16:59  answer
 

Bonjour, j'essaie de calculer une orthodromie avec Ada, mais j'ai un problème.
 
En effet pour des distance non nulle la fonction me retourne 0.0
 
Alors, j'ai un autre problème au calcul de arccos, qui plante régulièrement et je ne sais pourquoi, mais j'ai fait ceci :

Code :
  1. --
  2.   function Is_in(Target : Gps_Coordonates_Type; item : Gps_Coordonates_Type; Distance : Float) return Boolean is
  3.  
  4.      function Longitude (X : Longitude_Coordonate_Type) return Decimal_Longitude_Type is
  5.      begin
  6.  
  7.         if X.Degr_Lon < 0.0 then
  8.            return -Decimal_Longitude_Type(abs(X.Degr_Lon) + (abs(X.Minu_Lon) / 60.0) + (abs(X.Seco_Lon) / 3600.0));
  9.         else
  10.            return Decimal_Longitude_Type(abs(X.Degr_Lon) + (abs(X.Minu_Lon) / 60.0) + (abs(X.Seco_Lon) / 3600.0));
  11.         end if;
  12.      end Longitude;
  13.  
  14.      function latitude (Y : Latitude_Coordonate_Type) return Decimal_Latitude_Type is
  15.      begin
  16.  
  17.         if Y.Degr_Lat < 0.0 then
  18.            return -Decimal_Latitude_Type(abs(Y.Degr_Lat) + (abs(Y.Minu_Lat) / 60.0) + (abs(Y.Seco_Lat) / 3600.0));
  19.         else
  20.            return Decimal_Latitude_Type(abs(Y.Degr_Lat) + (abs(Y.Minu_Lat) / 60.0) + (abs(Y.Seco_Lat) / 3600.0));
  21.         end if;
  22.      end Latitude;
  23.  
  24.      --  Formule À Appliquer Pour Calculer Une Orthodromie : Cos P = (Sin LA . Sin LB) + (Cos LA . Cos LB . Cos G)                                                                                                
  25.      LA, LB, G: Float := 0.0;
  26.      P : Float := 0.0;
  27.      --    LA Correspond À La Latitude Du Point A.                                                                                                                                                                
  28.      --    LB Correspond À La Latitude Du Point B.                                                                                                                                                                
  29.      --    G Correspond À La Différence De Longitude Entre Le Point A Et Le Point B.                                                                                                                              
  30.   begin
  31.  
  32.      La := Latitude(Target.Latitude);
  33.  
  34.      Lb := Latitude(Item.Latitude);
  35.  
  36.      G  :=  (Longitude(item.Longitude)) - (Longitude(Target.Longitude));
  37.  
  38.      P := arccos(Float'rounding(((Sin(La) * Sin(Lb)) + (Cos(La) * Cos(Lb) * Cos(G))) * 1000000.0) / 1000000.0);
  39.      -- Qui devrait être la suivante mais qui plante si je n'arrondis pas.
  40.      --P := arccos((Sin(La) * Sin(Lb)) + (Cos(La) * Cos(Lb) * Cos(G)));                                                                                                                                            
  41.      P := P * 60.0;
  42.  
  43.      if  P - Distance > 0.0 then
  44.         --Text_Io.Put_Line("False" );                                                                                                                                                                              
  45.         return False;
  46.      else
  47.         Text_Io.Put_Line("TRUE" );
  48.         Text_Io.Put_Line("P = " & Float'Image(P));
  49.         return True;
  50.      end if;
  51.   end Is_in;


 
Donc ligne 38 on trouve une ligne avec un arrondissement un peut obscure que j'ai trouvé sur le net.
Mais sans cet arrondissement le arccos ligne 40 qui devrait remplacer la 38 plante.
 
Si vous avez besoin de precision je suis pas loin.
 
S'il vous plaît.
 
Merci pour votre aide.

mood
Publicité
Posté le 27-09-2013 à 17:16:59  profilanswer
 

n°2204444
Profil sup​primé
Posté le 27-09-2013 à 18:27:52  answer
 

Je ne sais pas si c'est normal, mais j'ai des négatif dans mes produit de sinus et cosinus.
 

cos_produit-6.06473E-01
sin_produit-3.91947E-02
sum_produit-6.45667E-01


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Ada

  Calcul de d'une orthodromie avec Ada

 

Sujets relatifs
[Ada][Débutant POO] Problème d'héritage à l'instantiation d'un paquet[Ada][Gnu/Linux][Xterm] Non_Blocking_Spawn: la commande n'est executée
[Topic unic][Ada][Gnu/Linux] La programmation pas à pas.[EXCEL] Calcul de prono pour le foot :p
calcul de cout d'une requeteCalcul sous Delphi
[Résolu] Besoin aide calcul temps en PHPCalcul différence de deux dates au format FR
calcul de la prime d'un optionCalcul EXCEL
Plus de sujets relatifs à : Calcul de d'une orthodromie avec Ada


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR