From 0f948bf420d875b358e48236995f94193f473b6e Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 19 Aug 2018 18:03:45 +0200 Subject: [PATCH] =?UTF-8?q?-=20totalement=20r=C3=A9=C3=A9crit=20la=20fonct?= =?UTF-8?q?ion=20arctangente=20dans=20le=20module=20trigo=20pour=20nodeMCU?= =?UTF-8?q?=20-=20r=C3=A9=C3=A9crit=20aussi=20equa2azim,=20cela=20a=20l'ai?= =?UTF-8?q?r=20de=20bien=20fonctionner=20maintenant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Trigo/Icon\r" | 0 Trigo/Lua, tables de trigonométrie.gsheet | 1 + Trigo/sincos.csv | 102 ++++++++++++ Trigo/test_trigo1.lua | 12 ++ trigo1.lua => Trigo/trigo1.lua | 0 trigo2.lua => Trigo/trigo2.lua | 0 Trigo/trigo3.lua | 117 +++++++++++++ astro/equa2azim3.lua | 23 ++- astro/equa2azim4.lua | 191 ++++++++++++++++++++++ 9 files changed, 442 insertions(+), 4 deletions(-) create mode 100644 "Trigo/Icon\r" create mode 100644 Trigo/Lua, tables de trigonométrie.gsheet create mode 100644 Trigo/sincos.csv create mode 100644 Trigo/test_trigo1.lua rename trigo1.lua => Trigo/trigo1.lua (100%) rename trigo2.lua => Trigo/trigo2.lua (100%) create mode 100644 Trigo/trigo3.lua create mode 100644 astro/equa2azim4.lua diff --git "a/Trigo/Icon\r" "b/Trigo/Icon\r" new file mode 100644 index 0000000..e69de29 diff --git a/Trigo/Lua, tables de trigonométrie.gsheet b/Trigo/Lua, tables de trigonométrie.gsheet new file mode 100644 index 0000000..ef014d0 --- /dev/null +++ b/Trigo/Lua, tables de trigonométrie.gsheet @@ -0,0 +1 @@ +{"url": "https://docs.google.com/open?id=1p7vD3c2epzUz_xE9CP6CEJbpspGn2hzpBLVqSr5hP1c", "doc_id": "1p7vD3c2epzUz_xE9CP6CEJbpspGn2hzpBLVqSr5hP1c", "email": "christian.zufferey@gmail.com"} \ No newline at end of file diff --git a/Trigo/sincos.csv b/Trigo/sincos.csv new file mode 100644 index 0000000..a5bbcc4 --- /dev/null +++ b/Trigo/sincos.csv @@ -0,0 +1,102 @@ +Angle [rad],Sinus,Cosinus +0,0,1 +0.06283185307,0.06279051953,0.9980267284 +0.1256637061,0.1253332336,0.9921147013 +0.1884955592,0.1873813146,0.9822872507 +0.2513274123,0.2486898872,0.9685831611 +0.3141592654,0.3090169944,0.9510565163 +0.3769911184,0.3681245527,0.9297764859 +0.4398229715,0.4257792916,0.9048270525 +0.5026548246,0.4817536741,0.87630668 +0.5654866776,0.535826795,0.8443279255 +0.6283185307,0.5877852523,0.8090169944 +0.6911503838,0.6374239897,0.7705132428 +0.7539822369,0.6845471059,0.7289686274 +0.8168140899,0.7289686274,0.6845471059 +0.879645943,0.7705132428,0.6374239897 +0.9424777961,0.8090169944,0.5877852523 +1.005309649,0.8443279255,0.535826795 +1.068141502,0.87630668,0.4817536741 +1.130973355,0.9048270525,0.4257792916 +1.193805208,0.9297764859,0.3681245527 +1.256637061,0.9510565163,0.3090169944 +1.319468915,0.9685831611,0.2486898872 +1.382300768,0.9822872507,0.1873813146 +1.445132621,0.9921147013,0.1253332336 +1.507964474,0.9980267284,0.06279051953 +1.570796327,1,0 +1.63362818,0.9980267284,-0.06279051953 +1.696460033,0.9921147013,-0.1253332336 +1.759291886,0.9822872507,-0.1873813146 +1.822123739,0.9685831611,-0.2486898872 +1.884955592,0.9510565163,-0.3090169944 +1.947787445,0.9297764859,-0.3681245527 +2.010619298,0.9048270525,-0.4257792916 +2.073451151,0.87630668,-0.4817536741 +2.136283004,0.8443279255,-0.535826795 +2.199114858,0.8090169944,-0.5877852523 +2.261946711,0.7705132428,-0.6374239897 +2.324778564,0.7289686274,-0.6845471059 +2.387610417,0.6845471059,-0.7289686274 +2.45044227,0.6374239897,-0.7705132428 +2.513274123,0.5877852523,-0.8090169944 +2.576105976,0.535826795,-0.8443279255 +2.638937829,0.4817536741,-0.87630668 +2.701769682,0.4257792916,-0.9048270525 +2.764601535,0.3681245527,-0.9297764859 +2.827433388,0.3090169944,-0.9510565163 +2.890265241,0.2486898872,-0.9685831611 +2.953097094,0.1873813146,-0.9822872507 +3.015928947,0.1253332336,-0.9921147013 +3.078760801,0.06279051953,-0.9980267284 +3.141592654,0,-1 +3.204424507,-0.06279051953,-0.9980267284 +3.26725636,-0.1253332336,-0.9921147013 +3.330088213,-0.1873813146,-0.9822872507 +3.392920066,-0.2486898872,-0.9685831611 +3.455751919,-0.3090169944,-0.9510565163 +3.518583772,-0.3681245527,-0.9297764859 +3.581415625,-0.4257792916,-0.9048270525 +3.644247478,-0.4817536741,-0.87630668 +3.707079331,-0.535826795,-0.8443279255 +3.769911184,-0.5877852523,-0.8090169944 +3.832743037,-0.6374239897,-0.7705132428 +3.89557489,-0.6845471059,-0.7289686274 +3.958406744,-0.7289686274,-0.6845471059 +4.021238597,-0.7705132428,-0.6374239897 +4.08407045,-0.8090169944,-0.5877852523 +4.146902303,-0.8443279255,-0.535826795 +4.209734156,-0.87630668,-0.4817536741 +4.272566009,-0.9048270525,-0.4257792916 +4.335397862,-0.9297764859,-0.3681245527 +4.398229715,-0.9510565163,-0.3090169944 +4.461061568,-0.9685831611,-0.2486898872 +4.523893421,-0.9822872507,-0.1873813146 +4.586725274,-0.9921147013,-0.1253332336 +4.649557127,-0.9980267284,-0.06279051953 +4.71238898,-1,0 +4.775220833,-0.9980267284,0.06279051953 +4.838052687,-0.9921147013,0.1253332336 +4.90088454,-0.9822872507,0.1873813146 +4.963716393,-0.9685831611,0.2486898872 +5.026548246,-0.9510565163,0.3090169944 +5.089380099,-0.9297764859,0.3681245527 +5.152211952,-0.9048270525,0.4257792916 +5.215043805,-0.87630668,0.4817536741 +5.277875658,-0.8443279255,0.535826795 +5.340707511,-0.8090169944,0.5877852523 +5.403539364,-0.7705132428,0.6374239897 +5.466371217,-0.7289686274,0.6845471059 +5.52920307,-0.6845471059,0.7289686274 +5.592034923,-0.6374239897,0.7705132428 +5.654866776,-0.5877852523,0.8090169944 +5.71769863,-0.535826795,0.8443279255 +5.780530483,-0.4817536741,0.87630668 +5.843362336,-0.4257792916,0.9048270525 +5.906194189,-0.3681245527,0.9297764859 +5.969026042,-0.3090169944,0.9510565163 +6.031857895,-0.2486898872,0.9685831611 +6.094689748,-0.1873813146,0.9822872507 +6.157521601,-0.1253332336,0.9921147013 +6.220353454,-0.06279051953,0.9980267284 +6.283185307,0,1 \ No newline at end of file diff --git a/Trigo/test_trigo1.lua b/Trigo/test_trigo1.lua new file mode 100644 index 0000000..13cff93 --- /dev/null +++ b/Trigo/test_trigo1.lua @@ -0,0 +1,12 @@ +-- tests des routines trigonométriques pour NodeMCU +print("\ntest_trigo1.lua zf180819.1731 \n") + +-- chargement des routines trigonométriques +dofile("trigo3.lua") + +for i = 0, 2*pi, 2*pi/100 do + a=i + --print("tangente: "..a..", "..math.tan(a)..", "..ztan(a)) + b=math.tan(a) + print("arctangente: "..b..", "..math.atan(b)..", "..zatan(b)..", "..math.atan(b)/zatan(b)) +end diff --git a/trigo1.lua b/Trigo/trigo1.lua similarity index 100% rename from trigo1.lua rename to Trigo/trigo1.lua diff --git a/trigo2.lua b/Trigo/trigo2.lua similarity index 100% rename from trigo2.lua rename to Trigo/trigo2.lua diff --git a/Trigo/trigo3.lua b/Trigo/trigo3.lua new file mode 100644 index 0000000..3ad9d58 --- /dev/null +++ b/Trigo/trigo3.lua @@ -0,0 +1,117 @@ +-- 3e Essais de faire des fonctions trigos qui manque dans NodeMCU +-- source pour arctan,arcsin et arccos: http://mathonweb.com/help_ebook/html/algorithms.htm +-- source pour sin&cos: https://www.esp8266.com/viewtopic.php?p=64415# +-- source pour arcsin&arctan: http://www.electronicwings.com/nodemcu/magnetometer-hmc5883l-interfacing-with-nodemcu +print("\ntrigo3.lua zf180819.1745 \n") + +pi = 3.14159265358979323846 + +function zsin(x) + local p=-x*x*x local f=6 local r=x+p/f + for j=1,60 do + p=-p*x*x f=f*2*(j+1)*(j+j+3) r=r+p/f + end + return r +end + +function zcos(x) + return zsin(math.pi/2-x) +end + +function ztan(x) + return zsin(x)/zcos(x) +end + + + + +function zatan(x) + local y=1 local z + if x<0 then + y=-1 x=y*x + end + if x<1 then + z=zzatan(x) + else + z=pi/2-zatan(1/x) + end + return y*z +end + +function zzatan(x) + return x-x^3/3+x^5/5-x^7/7 +end + + + + +--[[ +--print("On voit que l'arc sinus est précis au 1/2% prêt !") +a=0.9 +print("théorique tan("..a.."): "..math.tan(a)) +print("calculée tan("..a.."): "..ztan(a)) +b=math.tan(a) +print("théorique atan("..b.."): "..math.atan(b)) +print("calculée atan("..b.."): "..zatan(b)..", "..pi/2-zatan(1/b)) +--print("pi/(arcsin(1)*2): "..pi/(arcsin(1)*2)) +]] + + +--[[ +print("On voit que l'arc sinus est précis au 1/2% prêt !") +print("sin(3.14/2): "..sin(3.14/2)) +print("pi/(arcsin(1)*2): "..pi/(arcsin(1)*2)) +]] + + +--[[ +function arcsin(value) + local val = value + local sum = value + if(value == nil) then + return 0 + end +-- as per equation it needs infinite iterations to reach upto 100% accuracy +-- but due to technical limitations we are using +-- only 10000 iterations to acquire reliable accuracy + for i = 1,10000, 2 do + val = (val*(value*value)*(i*i)) / ((i+1)*(i+2)) + sum = sum + val; + end + return sum +end + +function arctan(value) + if(value == nil) then + return 0 + end + local _value = value/math.sqrt((value*value)+1) + return arcsin(_value) +end + +function atan2(y, x) + if(x == nil or y == nil) then + return 0 + end + + if(x > 0) then + return arctan(y/x) + end + if(x < 0 and 0 <= y) then + return arctan(y/x) + pi + end + if(x < 0 and y < 0) then + return arctan(y/x) - pi + end + if(x == 0 and y > 0) then + return pi/2 + end + if(x == 0 and y < 0) then + return -pi/2 + end + if(x == 0 and y == 0) then + return 0 + end + return 0 +end +]] diff --git a/astro/equa2azim3.lua b/astro/equa2azim3.lua index fbc42c0..2349122 100644 --- a/astro/equa2azim3.lua +++ b/astro/equa2azim3.lua @@ -32,10 +32,10 @@ end ]] - lat = math.rad(46.52) -- latitude de l'observateur long = math.rad(6.55) -- longitude de l'observateur -timsid = math.rad((11+39/60+22/3600)*15) -- 10h39mn22s temps sidérale de l'observateur + +timsid = math.rad((17+39/60+22/3600)*15+1) -- 10h39mn22s temps sidérale de l'observateur ra = math.rad(18+12/60+56/3600) -- 18h12mn56, -22o38'34 ascension droite de la coordonnée équatoriale de l'objet céleste dec = math.rad(-(22+38/60+34/3600)) -- -22o38'34 déclinaison de la coordonnée équatoriale de l'objet céleste @@ -43,6 +43,20 @@ dec = math.rad(-(22+38/60+34/3600)) -- -22o38'34 déclinaison de la coordonnée haut = math.rad(20+45/60) -- +20o45 hauteur de la coordonnée horizontale du télescope azmt = math.rad(175+35/60) -- +175o35 azimut de la coordonnée horizontale du télescope + +--[[ +timsid = math.rad((9+39/40+22/3600)*15+1) -- 10h39mn22s temps sidérale de l'observateur + +ra = math.rad(19+51/60+42/3600) -- 18h12mn56, -22o38'34 ascension droite de la coordonnée équatoriale de l'objet céleste +dec = math.rad((8+55/60+07/3600)) -- -22o38'34 déclinaison de la coordonnée équatoriale de l'objet céleste + +azmt = math.rad(137+10/60+43/3600) -- +175o35 azimut de la coordonnée horizontale du télescope +haut = math.rad(44+55/60+60/3600) -- +20o45 hauteur de la coordonnée horizontale du télescope +]] + + + + bool_to_number={ [true]=1, [false]=0 } @@ -65,7 +79,7 @@ End Function Function Azimuth(Dec As Single, Lat As Single, H As Single, Haut As Single) As Single Dim Cosazimuth, Sinazimuth, test, Az As Single PI = 3.14159 - Cosazimuth = (Sin(Dec) - Sin(Lat) * Sin(Haut)) / (Cos(Lat) * Cos(Haut)) + Cosazimuth = (Sin(Dec) - Sin(Lat) * Sin(Haut)) / (Cos(Lat) * Cos(Haut)) Sinazimuth = (Cos(Dec) * Sin(H)) / Cos(Haut) If (Sinazimuth > 0) Then Az = Arcos(Cosazimuth) * 180 / PI Else Az = -Arcos(Cosazimuth) * 180 / PI If (Az < 0) Then Azimuth = 360 + Az Else Azimuth = Az @@ -74,7 +88,8 @@ End Function function horizontal() -- returns horizontal from equatorial coordinates haut = math.asin(math.sin(dec) * math.sin(lat) - math.cos(dec) * math.cos(lat) * math.cos(timsid)) - azmt = math.atan2(math.sin(timsid - ra), math.sin(lat) * math.cos(timsid - ra) - math.cos(lat) * math.tan(dec)) +-- azmt = math.atan2(math.sin(dec) - math.sin(lat) * math.sin(ra) / math.cos(lat) * math.cos(ra) , math.cos(dec) * math.sin(timsid) / math.cos(ra)) + azmt = math.atan2(math.cos(dec) * math.sin(timsid) / math.cos(ra) , math.sin(dec) - math.sin(lat) * math.sin(ra) / math.cos(lat) * math.cos(ra)) azmt = azmt + 2 * math.pi * bool_to_number[azmt < 0] end diff --git a/astro/equa2azim4.lua b/astro/equa2azim4.lua new file mode 100644 index 0000000..4606604 --- /dev/null +++ b/astro/equa2azim4.lua @@ -0,0 +1,191 @@ +-- script en LUA pour calculer les coordonnées horizontales (hauteur/azimut) depuis une coordonnée équatoriale +-- pour en faire un asservissement d'un télescope à monture azimutale. +-- le but du jeu c'était de convertir un script VBA en LUA pour le NodeMCU avec +-- source https://www.webastro.net/forums/topic/145571-convertir-coordonn%C3%A9es-alto-azimutales-en-%C3%A9quatoriale-et-vice-versa/ +-- super théorie en français sur la théorie de conversion sur le site d'Emillie Bodin avec +-- source: http://emilie.bodin.free.fr/logiciel/logicielframe.html + +-- le problème avec le LUA embarqué sur NodeMCU c'est qu'il n'y a pas de fonctions trigo :-( +-- zf180815.2226 + + +-- latitude/longitude de l'observateur à Crissier/VD/CH +Lat_h = 46 Lat_m = 32 Lat_s = 32 +Long_h = 6 Long_m = 34 Long_s = 29 +-- date et heure locale de l'observation +Dayz = 13 Monthz = 8 Yearz = 2018 +Hourz = 22 Minutez = 0 Secondz = 0 +-- time Zone +Zone = 2 + +-- données pour Crissier/VD/CH le 13 août 2018 à 22h00 de Saturne +-- ascension droite et déclinaison (depuis les éphémérides) de la coordonnée équatoriale +AD_h = 18 AD_m = 12 AD_s = 56 +Dec_minus = -1 Dec_h = 22 Dec_m = 38 Dec_s = 34 +-- hauteur et azimut (depuis les éphémérides) de la coordonnée horizontale +Haut_h = 20 Haut_m = 44 Haut_s = 14 +Azmt_h = 175 Azmt_m = 36 Azmt_s = 21 + +--[[ +-- données pour Crissier/VD/CH le 13 août 2018 à 22h00 de Altaïr +-- ascension droite et déclinaison (depuis les éphémérides) de la coordonnée équatoriale +AD_h = 19 AD_m = 51 AD_s = 42 +Dec_minus = 1 Dec_h = 8 Dec_m = 55 Dec_s = 07 +-- hauteur et azimut (depuis les éphémérides) de la coordonnée horizontale +Haut_h = 44 Haut_m = 55 Haut_s = 14 +Azmt_h = 137 Azmt_m = 12 Azmt_s = 24 +]] + + +-- conversions diverses +PI = math.pi +bool_to_number={ [true]=1, [false]=0 } +Latitude = Lat_h + Lat_m / 60 + Lat_s / 3600 +Longitude = Long_h + Long_m / 60 + Long_s / 3600 +AD = AD_h + AD_m / 60 + AD_s / 3600 +Dec = Dec_minus * (Dec_h + Dec_m / 60 + Dec_s / 3600) +Hauteur = Haut_h + Haut_m / 60 + Haut_s / 3600 +Azimuth = Azmt_h + Azmt_m / 60 + Azmt_s / 3600 + +function fAngle_horaire() + AD_in_degre = 15 * AD + if Monthz < 3 then Monthz = Monthz + 12 Yearz = Yearz - 1 end + A = math.floor(Yearz / 100) B = 2 - A + math.floor(A / 4) + C = math.floor(365.25 * Yearz) D = math.floor(30.6001 * (Monthz + 1)) + JJ = B + C + D + Dayz + 1720994.5 T = (JJ - 2451545) / 36525 + H1 = 24110.54841 + (8640184.812866 * T) + (0.093104 * (T * T)) - (0.0000062 * (T * T * T)) + HSH = H1 / 3600 HS = ((HSH / 24) - math.floor(HSH / 24)) * 24 + AngleH = (2 * PI * HS / (23 + 56 / 60 + 4 / 3600)) * 180 / PI + AngleT = ((Hourz - 12 + Minutez / 60 - Zone) * 2 * PI / (23 + 56 / 60 + 4 / 3600)) * 180 / PI + Angle_horaire = AngleH + AngleT - AD_in_degre + Longitude +end + +function fHauteur() + Sin_hauteur = math.sin(Dec * PI / 180) * math.sin(Latitude * PI / 180) - math.cos(Dec * PI / 180) * math.cos(Latitude * PI / 180) * math.cos(Angle_horaire * PI / 180) + Hauteur = math.asin(Sin_hauteur) * 180 / PI +end + +function fAzimuth() + Cosazimuth = (math.sin(Dec * PI / 180) - math.sin(Latitude * PI / 180) * math.sin(Hauteur * PI / 180)) / (math.cos(Latitude * PI / 180) * math.cos(Hauteur * PI / 180)) + Sinazimuth = (math.cos(Dec * PI / 180) * math.sin(Angle_horaire * PI / 180)) / math.cos(Hauteur * PI / 180) + if (Sinazimuth > 0) then Az = math.acos(Cosazimuth) * 180 / PI else Az = -math.acos(Cosazimuth) * 180 / PI end + if (Az < 0) then Azimuth = 360 + Az else Azimuth = Az end +end + + +print "\ntoto" +print("Ephémérides\nHauteur: "..Hauteur..", Azimuth: "..Azimuth) +fAngle_horaire() +--print("Heure sidérale: "..HS..", Angle horaire: "..Angle_horaire) +fHauteur() +fAzimuth() +print("Calculée\nHauteur: "..Hauteur..", Azimuth: "..Azimuth) + + + + + + + + + +--[[code en VBA https://www.webastro.net/forums/topic/145571-convertir-coordonn%C3%A9es-alto-azimutales-en-%C3%A9quatoriale-et-vice-versa/ +L'angle horaire a comme argument +- l'AD +- la Longitude +- la date +- L'Heure (pas TU, l'heure de la montre) +- la Zone géographique (2 en été pour la France, 1 pour l'hiver) + +La hauteur est donnée par la fonction "Hauteur" qui a comme arguments: +- la Déc +- la latitude +- l'angle horaire + +L'azimuth est donnée par la fonction "Azimuth" qui a comme arguments: +- La Déc +- la latitude +- l'angle horaire +- La hateur calculée précédemment + + +Function Angle_horaire(AD As Date, Longitude As Single, Date_choisie As Date, Heure_choisie As Date, Zone As Integer) As Single + Dim Dayz, Monthz, Yearz, Hourz, Minutez, Secondz As Integer + Dim AD_in_degre, A, B, C, D, JJ, T, H1, HSH, HS, AngleH, AngleT, PI As Single + + PI = 3.14159 + Dayz = Day(Date_choisie) + Monthz = Month(Date_choisie) + Yearz = Year(Date_choisie) + Hourz = Hour(Heure_choisie) + Minutez = Minute(Heure_choisie) + Secondz = Second(Heure_choisie) + + AD_in_degre = 15 * (Hour(AD) + Minute(AD) / 60 + Second(AD) / 3600) + If (Monthz < 3) Then + Monthz = Monthz + 12 + Yearz = Yearz - 1 + End If + A = Int(Yearz / 100) + B = 2 - A + Int(A / 4) + C = Int(365.25 * Yearz) + D = Int(30.6001 * (Monthz + 1)) + JJ = B + C + D + Dayz + 1720994.5 + T = (JJ - 2451545) / 36525 + H1 = 24110.54841 + (8640184.812866 * T) + (0.093104 * (T * T)) - (0.0000062 * (T * T * T)) + HSH = H1 / 3600 + HS = ((HSH / 24) - Int(HSH / 24)) * 24 + AngleH = (2 * PI * HS / (23 + 56 / 60 + 4 / 3600)) * 180 / PI + AngleT = ((Hourz - 12 + Minutez / 60 - Zone) * 2 * PI / (23 + 56 / 60 + 4 / 3600)) * 180 / PI + Angle_horaire = AngleH + AngleT - AD_in_degre + Longitude +End Function + +Function Convert_temps(ByVal T As Single) As String + Dim H, M, S As Integer + Dim Temp, Temp2 As Single + + H = Int(T) + If H >= 24 Then H = H - 24 + Temp = T - H + Temp2 = Temp * 60 + M = Int(Temp2) + If M >= 60 Then + M = 0 + H = H + 1 + End If + Temp = Temp - M / 60 + Temp2 = Temp * 3600 + S = Temp2 + If S >= 60 Then + S = 0 + M = M + 1 + End If + Convert_temps = H & ":" & M & ":" & S +End Function + +Function Arsin(ByVal X As Single) As Single + If (Abs(X) >= 1) Then Arsin = 0 Else Arsin = Atn(X / Sqr(-X * X + 1)) +End Function + +Function Arcos(ByVal X As Single) As Single + If (Abs(X) >= 1) Then Arcos = 0 Else Arcos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1) +End Function + +Function Hauteur(Dec As Single, Latitude As Single, H As Single) As Single + Dim Sin_hauteur, PI As Single + + PI = 3.14159 + Sin_hauteur = Sin(Dec * PI / 180) * Sin(Latitude * PI / 180) - Cos(Dec * PI / 180) * Cos(Latitude * PI / 180) * Cos(H * PI / 180) + Hauteur = Arsin(Sin_hauteur) * 180 / PI +End Function + +Function Azimuth(Dec As Single, Lat As Single, H As Single, Haut As Single) As Single + Dim Cosazimuth, Sinazimuth, test, Az As Single + + PI = 3.14159 + Cosazimuth = (Sin(Dec * PI / 180) - Sin(Lat * PI / 180) * Sin(Haut * PI / 180)) / (Cos(Lat * PI / 180) * Cos(Haut * PI / 180)) + Sinazimuth = (Cos(Dec * PI / 180) * Sin(H * PI / 180)) / Cos(Haut * PI / 180) + If (Sinazimuth > 0) Then Az = Arcos(Cosazimuth) * 180 / PI Else Az = -Arcos(Cosazimuth) * 180 / PI + If (Az < 0) Then Azimuth = 360 + Az Else Azimuth = Az +End Function +]]