mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
UTILS - corrected open door check MI-8
This commit is contained in:
parent
edd6594953
commit
77e6088114
@ -6,7 +6,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
--
|
--
|
||||||
-- * FlightControl : Rework to OO framework
|
-- * FlightControl : Rework to OO framework.
|
||||||
--
|
--
|
||||||
-- @module Utils
|
-- @module Utils
|
||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
@ -339,18 +339,34 @@ UTILS.MetersToNM = function(meters)
|
|||||||
return meters/1852
|
return meters/1852
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UTILS.KiloMetersToNM = function(kilometers)
|
||||||
|
return kilometers/1852*1000
|
||||||
|
end
|
||||||
|
|
||||||
UTILS.MetersToSM = function(meters)
|
UTILS.MetersToSM = function(meters)
|
||||||
return meters/1609.34
|
return meters/1609.34
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UTILS.KiloMetersToSM = function(kilometers)
|
||||||
|
return kilometers/1609.34*1000
|
||||||
|
end
|
||||||
|
|
||||||
UTILS.MetersToFeet = function(meters)
|
UTILS.MetersToFeet = function(meters)
|
||||||
return meters/0.3048
|
return meters/0.3048
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UTILS.KiloMetersToFeet = function(kilometers)
|
||||||
|
return kilometers/0.3048*1000
|
||||||
|
end
|
||||||
|
|
||||||
UTILS.NMToMeters = function(NM)
|
UTILS.NMToMeters = function(NM)
|
||||||
return NM*1852
|
return NM*1852
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UTILS.NMToKiloMeters = function(NM)
|
||||||
|
return NM*1852/1000
|
||||||
|
end
|
||||||
|
|
||||||
UTILS.FeetToMeters = function(feet)
|
UTILS.FeetToMeters = function(feet)
|
||||||
return feet*0.3048
|
return feet*0.3048
|
||||||
end
|
end
|
||||||
@ -907,7 +923,7 @@ function UTILS.RandomGaussian(x0, sigma, xmin, xmax, imax)
|
|||||||
local x1=math.random()
|
local x1=math.random()
|
||||||
local x2=math.random()
|
local x2=math.random()
|
||||||
|
|
||||||
-- Transform to Gaussian exp(-(x-x0)²/(2*sigma²).
|
-- Transform to Gaussian exp(-(x-x0)°/(2*sigma°).
|
||||||
r = math.sqrt(-2*sigma*sigma * math.log(x1)) * math.cos(2*math.pi * x2) + x0
|
r = math.sqrt(-2*sigma*sigma * math.log(x1)) * math.cos(2*math.pi * x2) + x0
|
||||||
|
|
||||||
i=i+1
|
i=i+1
|
||||||
@ -961,6 +977,33 @@ function UTILS.VecNorm(a)
|
|||||||
return math.sqrt(UTILS.VecDot(a, a))
|
return math.sqrt(UTILS.VecDot(a, a))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the distance between two 2D vectors.
|
||||||
|
-- @param DCS#Vec2 a Vector in 3D with x, y components.
|
||||||
|
-- @param DCS#Vec2 b Vector in 3D with x, y components.
|
||||||
|
-- @return #number Distance between the vectors.
|
||||||
|
function UTILS.VecDist2D(a, b)
|
||||||
|
|
||||||
|
local c={x=b.x-a.x, y=b.y-a.y}
|
||||||
|
|
||||||
|
local d=math.sqrt(c.x*c.x+c.y*c.y)
|
||||||
|
|
||||||
|
return d
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Calculate the distance between two 3D vectors.
|
||||||
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
|
-- @return #number Distance between the vectors.
|
||||||
|
function UTILS.VecDist3D(a, b)
|
||||||
|
|
||||||
|
local c={x=b.x-a.x, y=b.y-a.y, z=b.z-a.z}
|
||||||
|
|
||||||
|
local d=math.sqrt(UTILS.VecDot(c, c))
|
||||||
|
|
||||||
|
return d
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the [cross product](https://en.wikipedia.org/wiki/Cross_product) of two 3D vectors. The result is a 3D vector.
|
--- Calculate the [cross product](https://en.wikipedia.org/wiki/Cross_product) of two 3D vectors. The result is a 3D vector.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
@ -1535,8 +1578,8 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
if unit ~= nil then
|
if unit ~= nil then
|
||||||
local type_name = unit:getTypeName()
|
local type_name = unit:getTypeName()
|
||||||
|
|
||||||
if type_name == "Mi-8MT" and unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(86) == 1 or unit:getDrawArgumentValue(250) == 1 then
|
if type_name == "Mi-8MT" and unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(86) == 1 or unit:getDrawArgumentValue(250) < 0 then
|
||||||
BASE:T(unit_name .. " Cargo doors are open or cargo door not present")
|
BASE:T(unit_name .. " Cargo doors are open or cargo door not present")
|
||||||
ret_val = true
|
ret_val = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1588,10 +1631,10 @@ function UTILS.GenerateVHFrequencies()
|
|||||||
local _skipFrequencies = {
|
local _skipFrequencies = {
|
||||||
214,274,291.5,295,297.5,
|
214,274,291.5,295,297.5,
|
||||||
300.5,304,307,309.5,311,312,312.5,316,
|
300.5,304,307,309.5,311,312,312.5,316,
|
||||||
320,324,328,329,330,336,337,
|
320,324,328,329,330,332,336,337,
|
||||||
342,343,348,351,352,353,358,
|
342,343,348,351,352,353,358,
|
||||||
363,365,368,372.5,374,
|
363,365,368,372.5,374,
|
||||||
380,381,384,389,395,396,
|
380,381,384,385,389,395,396,
|
||||||
414,420,430,432,435,440,450,455,462,470,485,
|
414,420,430,432,435,440,450,455,462,470,485,
|
||||||
507,515,520,525,528,540,550,560,570,577,580,
|
507,515,520,525,528,540,550,560,570,577,580,
|
||||||
602,625,641,662,670,680,682,690,
|
602,625,641,662,670,680,682,690,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user