Articles les plus consultés

jeudi 27 septembre 2018

Programme Processing pour calcul de cap

Pour ne pas "fatiguer" mon arduino en chargeant et rechargeant des programme d'essai, j'ai mis au point ce programme tournant sur Processing (qui fait exactement la même chose, dans un langage assez proche,mais sur ordinateur):
Il faut entrer les Latitudes & Longitudes, ainsi que les directions dans les premiéres lignes du programme pour tester...
Comparez vos résultats avec les résultats de sites et vous serez surpris de la précision.
Par ex:
 https://www.sunearthtools.com/fr/tools/distance.php



float LatDepart = 47.3771;
char DirectionLatDepart = 'N';
float LongDepart = 0.7082;
char DirectionLongDepart = 'E';

float LatArrive = 47.9027;
char DirectionLatArrive = 'N';
Float LongArrive = 1.9057;
char DirectionLongArrive = 'E';

char Tendance1 = 'A'; // pour Nord ou Sud 
char Tendance2 = 'A'; // pour Est ou West
Float DimensionRectangleLatitudeDegres = 0.3;
Float DimensionRectangleLongitudeDegres = 0.3;
Float DimensionRectangleLatitudeMetres = 0.3;
Float DimensionRectangleLongitudeMetres = 0.3;
Float DimensionRectanglePourcent = 025.03;
int DegresBase = 0;
int Cap =0;
void draw() {
 DetectionDirectionLatitude (); 
 DetectionDirectionLongitude ();
 DefinitionRectanglePourcent ();
 DefinitionRectangleDegres ();
 DefinitionCap ();
}
void DetectionDirectionLatitude (){
if ((LatDepart > LatArrive) && (DirectionLatDepart == 'N') && (DirectionLatArrive == 'N')){
  Tendance1 = 'S';
  DimensionRectangleLatitudeDegres = LatDepart - LatArrive;
}
if ((LatDepart > LatArrive) && (DirectionLatDepart == 'S') && (DirectionLatArrive == 'S')){
  Tendance1 = 'N';
   DimensionRectangleLatitudeDegres = LatDepart - LatArrive;
}
if ((LatDepart < LatArrive) && (DirectionLatDepart == 'N') && (DirectionLatArrive == 'N')){
  Tendance1 = 'N';
   DimensionRectangleLatitudeDegres = LatArrive - LatDepart;
}
if ((LatDepart < LatArrive) && (DirectionLatDepart == 'S') && (DirectionLatArrive == 'S')){
  Tendance1 = 'S';
  DimensionRectangleLatitudeDegres = LatArrive - LatDepart;
}
if  (DirectionLatDepart != DirectionLatArrive){
  Tendance1 = DirectionLatArrive;
   DimensionRectangleLatitudeDegres = LatDepart + LatArrive;
}
 DimensionRectangleLatitudeMetres = DimensionRectangleLatitudeDegres * 111730;
} 
void DetectionDirectionLongitude (){
if ((LongDepart > LongArrive) && (DirectionLongDepart == 'E') && (DirectionLongArrive == 'E')){
  Tendance2 = 'W';
  DimensionRectangleLongitudeDegres = LongDepart - LongArrive;
}
if ((LongDepart > LongArrive) && (DirectionLongDepart == 'W') && (DirectionLongArrive == 'W')){
  Tendance2 = 'E';
  DimensionRectangleLongitudeDegres = LongDepart - LongArrive;
}
if ((LongDepart < LongArrive) && (DirectionLongDepart == 'E') && (DirectionLongArrive == 'E')){
  Tendance2 = 'E';
  DimensionRectangleLongitudeDegres = LongArrive - LongDepart;
}
if ((LongDepart < LongArrive) && (DirectionLongDepart == 'W') && (DirectionLongArrive == 'W')){
  Tendance2 = 'W';
   DimensionRectangleLongitudeDegres = LongArrive - LongDepart;
}
if  (DirectionLongDepart != DirectionLongArrive){
  Tendance2 = DirectionLongArrive;
  DimensionRectangleLongitudeDegres = LongDepart + LongArrive;
}
DimensionRectangleLongitudeMetres = DimensionRectangleLongitudeDegres * 75840;
  println ("Tendance  =    " + Tendance1 + "," + Tendance2);
  println ("  Dimension Rectangle Latitude en Degres =   "+ DimensionRectangleLatitudeDegres);
  println ("                               en metres =   "+ DimensionRectangleLatitudeMetres);
  println ("  Dimension Rectangle Longitude en Degres =  "+ DimensionRectangleLongitudeDegres);
  println ("                               en metres =   "+ DimensionRectangleLongitudeMetres);
} 
//-----------------------------------------------------------------------------------------------------
void DefinitionRectanglePourcent (){
  if (DimensionRectangleLatitudeMetres > DimensionRectangleLongitudeMetres ){
    DimensionRectanglePourcent = (100 * DimensionRectangleLongitudeMetres) / DimensionRectangleLatitudeMetres;
}
 if (DimensionRectangleLatitudeMetres < DimensionRectangleLongitudeMetres ){
    DimensionRectanglePourcent = (100 * DimensionRectangleLatitudeMetres) / DimensionRectangleLongitudeMetres;
 }
  println ("                               en pourcent =   "+ DimensionRectanglePourcent +"  %");

}
void DefinitionRectangleDegres (){
  if (DimensionRectanglePourcent <= 5.241){
    DegresBase = 0;
  }
  if (DimensionRectanglePourcent > 5.241){
    DegresBase = 3;
  }
   if (DimensionRectanglePourcent > 9){
    DegresBase = 6;
  }
   if (DimensionRectanglePourcent > 12){
    DegresBase = 9;
  }
   if (DimensionRectanglePourcent > 20){
    DegresBase = 12;
  }
   if (DimensionRectanglePourcent > 24){
    DegresBase = 15;
  }
   if (DimensionRectanglePourcent > 30){
    DegresBase = 18;
  }
   if (DimensionRectanglePourcent > 35){
    DegresBase = 21;
  }
   if (DimensionRectanglePourcent > 42){
    DegresBase = 24;
  }
   if (DimensionRectanglePourcent > 48){
    DegresBase = 27;
  }
   if (DimensionRectanglePourcent > 55){
    DegresBase = 30;
  }
   if (DimensionRectanglePourcent > 62){
    DegresBase = 33;
  }
   if (DimensionRectanglePourcent >70){
    DegresBase = 36;
  }
   if (DimensionRectanglePourcent > 78){
    DegresBase = 39;
  }
   if (DimensionRectanglePourcent > 88){
    DegresBase = 42;
  }
   if (DimensionRectanglePourcent > 93){
    DegresBase = 45;
  }
println ("Degres de base  =    " + DegresBase + "   degres");   
}
void DefinitionCap () { 
  if  ((Tendance1== 'N') && (Tendance2 == 'E') && (DimensionRectangleLongitudeDegres < DimensionRectangleLatitudeDegres)){
  Cap = DegresBase;
}
if  ((Tendance1== 'N') && (Tendance2 == 'E') && (DimensionRectangleLongitudeDegres > DimensionRectangleLatitudeDegres)){
  Cap = 90 - DegresBase;
}
 if  ((Tendance1== 'S') && (Tendance2 == 'E') && (DimensionRectangleLongitudeDegres < DimensionRectangleLatitudeDegres)){
  Cap = 180 - DegresBase;
}
if  ((Tendance1== 'S') && (Tendance2 == 'E') && (DimensionRectangleLongitudeDegres > DimensionRectangleLatitudeDegres)){
  Cap = 90 + DegresBase;
}
 if  ((Tendance1== 'S') && (Tendance2 == 'W') && (DimensionRectangleLongitudeDegres < DimensionRectangleLatitudeDegres)){
  Cap = 180 + DegresBase;
}
if  ((Tendance1== 'S') && (Tendance2 == 'W') && (DimensionRectangleLongitudeDegres > DimensionRectangleLatitudeDegres)){
  Cap = 270 - DegresBase;
}
 if  ((Tendance1== 'N') && (Tendance2 == 'W') && (DimensionRectangleLongitudeDegres < DimensionRectangleLatitudeDegres)){
  Cap = 360 - DegresBase;
}
if  ((Tendance1== 'N') && (Tendance2 == 'W') && (DimensionRectangleLongitudeDegres > DimensionRectangleLatitudeDegres)){
  Cap = 270 + DegresBase;
}
println ("CAP ==  " + Cap);
  
    
}

Aucun commentaire:

Enregistrer un commentaire