mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
put quadBezier method at airutls scope
This commit is contained in:
parent
4879de8892
commit
d9dd972814
1 changed files with 4 additions and 3 deletions
7
init.lua
7
init.lua
|
@ -165,11 +165,11 @@ local function pitchroll2pitchyaw(aoa,roll)
|
||||||
return pitch,yaw
|
return pitch,yaw
|
||||||
end
|
end
|
||||||
|
|
||||||
function lerp(a, b, c)
|
local function lerp(a, b, c)
|
||||||
return a + (b - a) * c
|
return a + (b - a) * c
|
||||||
end
|
end
|
||||||
|
|
||||||
function quadBezier(t, p0, p1, p2)
|
function airutils.quadBezier(t, p0, p1, p2)
|
||||||
local l1 = lerp(p0, p1, t)
|
local l1 = lerp(p0, p1, t)
|
||||||
local l2 = lerp(p1, p2, t)
|
local l2 = lerp(p1, p2, t)
|
||||||
local quad = lerp(l1, l2, t)
|
local quad = lerp(l1, l2, t)
|
||||||
|
@ -198,7 +198,7 @@ function airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
||||||
|
|
||||||
--smooth the curve
|
--smooth the curve
|
||||||
local distance_factor = ((ground_distance) * 1) / (wingspan)
|
local distance_factor = ((ground_distance) * 1) / (wingspan)
|
||||||
local effect_factor = quadBezier(distance_factor, 0, wingspan, 0)
|
local effect_factor = airutils.quadBezier(distance_factor, 0, wingspan, 0)
|
||||||
if effect_factor < 0 then effect_factor = 0 end
|
if effect_factor < 0 then effect_factor = 0 end
|
||||||
if effect_factor > 0 then
|
if effect_factor > 0 then
|
||||||
effect_factor = math.abs( half_wingspan - effect_factor )
|
effect_factor = math.abs( half_wingspan - effect_factor )
|
||||||
|
@ -223,6 +223,7 @@ end
|
||||||
-- max_height: the max ceilling for the airplane
|
-- max_height: the max ceilling for the airplane
|
||||||
-- wingspan: for ground effect calculation
|
-- wingspan: for ground effect calculation
|
||||||
function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_pos, lift, max_height, wingspan)
|
function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_pos, lift, max_height, wingspan)
|
||||||
|
if longit_speed == nil then longit_speed = 0 end
|
||||||
wingspan = wingspan or 10
|
wingspan = wingspan or 10
|
||||||
local ground_effect_extra_lift = airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
local ground_effect_extra_lift = airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)
|
||||||
--minetest.chat_send_all('lift: '.. lift ..' - extra lift: '.. ground_effect_extra_lift)
|
--minetest.chat_send_all('lift: '.. lift ..' - extra lift: '.. ground_effect_extra_lift)
|
||||||
|
|
Loading…
Add table
Reference in a new issue