• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

How do I convert my excel formula to a Lua function? (2 Viewers)

luabro

Newcomer
Joined
Dec 26, 2021
Messages
2
Reaction score
0
Lua:
-- Usage example:
-- WCA(TrueCourse,PredictedWindDirection,PredictedWindSpeed,TrueAirspeed)

-- WCA(90,15,10,60)
-- Result: -3

function WCA(TrueCourse,PredictedWindDirection,PredictedWindSpeed,TrueAirspeed)
print IF(OR(math.abs(TrueCourse-PredictedWindDirection)=180,PredictedWindDirection-TrueCourse=0),0,math.deg(math.asin((PredictedWindSpeed*(math.sin(math.rad(180-(PredictedWindDirection-TrueCourse)))))/TrueAirspeed)))
end


WCA(90,15,10,60)
 

luabro

Newcomer
Joined
Dec 26, 2021
Messages
2
Reaction score
0
Correction result using those numbers should be -9. Sorry for second post unable to edit first post.
 
Top