- bien avancé avec mes fonctions trigo, mais il y a encore les atan négatives qui coincent et du coup les acos aussi
- ajouté un nouvel firmware plus complet pour le robot wifi
This commit is contained in:
BIN
Firmware/nodemcu-master-25-modules-2018-08-20-08-22-23-float.bin
Normal file
BIN
Firmware/nodemcu-master-25-modules-2018-08-20-08-22-23-float.bin
Normal file
Binary file not shown.
BIN
Firmware/nodemcu-master-25-modules-2018-08-20-08-22-23-float.pdf
Normal file
BIN
Firmware/nodemcu-master-25-modules-2018-08-20-08-22-23-float.pdf
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,24 @@
|
||||
-- tests des routines trigonométriques pour NodeMCU
|
||||
print("\ntest_trigo1.lua zf180819.1731 \n")
|
||||
print("\ntest_trigo1.lua zf180820.2209 \n")
|
||||
|
||||
-- chargement des routines trigonométriques
|
||||
dofile("trigo3.lua")
|
||||
|
||||
for i = 0, 2*pi, 2*pi/100 do
|
||||
for i = 0, 2*math.pi, 2*math.pi/32 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))
|
||||
-- b=math.tan(a)
|
||||
-- print("arctangente: "..a..", "..b..", "..math.atan(b)..", "..zatan(b)..", "..math.atan(b)/zatan(b))
|
||||
-- print("sinus: "..a..", "..math.sin(a)..", "..zsin(a)..", "..math.sin(a)/zsin(a))
|
||||
-- print("cosinus: "..a..", "..math.cos(a)..", "..zcos(a)..", "..math.cos(a)/zcos(a))
|
||||
-- print("tangente: "..a..", "..math.tan(a)..", "..ztan(a)..", "..math.tan(a)/ztan(a))
|
||||
-- b=math.sin(a)
|
||||
-- print("arcsinus: "..a..", "..b..", "..math.asin(b)..", "..zasin(b)..", "..math.asin(b)/zasin(b))
|
||||
b=math.cos(a)
|
||||
print("arccosinus: "..a..", "..b..", "..math.acos(b)..", "..zacos(b)..", "..math.acos(b)/zacos(b))
|
||||
end
|
||||
|
||||
print("\n")
|
||||
x=-0.70710678118655
|
||||
print(math.acos(x))
|
||||
print(zatan(math.sqrt(1-x*x)/x))
|
||||
print(math.sqrt(1-x*x)/x)
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
-- 3e Essais de faire des fonctions trigos qui manque dans NodeMCU
|
||||
-- 3e Essais de faire des fonctions trigos qui manquent 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
|
||||
print("\ntrigo3.lua zf180820.2205 \n")
|
||||
|
||||
Gros problème encore avec les atan négatives et du coup avec les acos, zf180820.2252
|
||||
|
||||
|
||||
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
|
||||
local y=1
|
||||
if x>math.pi*2 then x=x%(math.pi*2) end
|
||||
if x>math.pi then y=-1 x=x-math.pi end
|
||||
if x>math.pi/2 then x=math.pi-x end
|
||||
local p=x local f=1 local r=p
|
||||
for j=2,10,2 do p=-p * x * x f=f*j*(j+1) r=r+p/f end
|
||||
return(y*r)
|
||||
end
|
||||
|
||||
function zcos(x)
|
||||
if x>math.pi*2 then x=x%(math.pi*2) end
|
||||
if x>math.pi then x=math.pi-x end
|
||||
return zsin(math.pi/2-x)
|
||||
end
|
||||
|
||||
@@ -22,19 +28,22 @@ function ztan(x)
|
||||
return zsin(x)/zcos(x)
|
||||
end
|
||||
|
||||
function zasin(x)
|
||||
return zatan(x/math.sqrt(1-x*x))
|
||||
end
|
||||
|
||||
function zacos(x)
|
||||
return zatan(math.sqrt(1-x*x)/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
|
||||
if x<0 then y=-1 x=y*x end
|
||||
if x<1 then z=zzatan(x) else z=math.pi/2-zatan(1/x) end
|
||||
return y*z
|
||||
end
|
||||
|
||||
@@ -45,24 +54,6 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user