Skip to content

Instantly share code, notes, and snippets.

@mcongrove
Created December 30, 2016 20:24
Show Gist options
  • Save mcongrove/78d206c8581a6dd2584bf164144c42b3 to your computer and use it in GitHub Desktop.
Save mcongrove/78d206c8581a6dd2584bf164144c42b3 to your computer and use it in GitHub Desktop.
defineProperty("viewX", globalPropertyf("sim/graphics/view/view_x"))
defineProperty("viewY", globalPropertyf("sim/graphics/view/view_y"))
defineProperty("viewZ", globalPropertyf("sim/graphics/view/view_z"))
defineProperty("acfX", globalPropertyf("sim/flightmodel/position/local_x"))
defineProperty("acfY", globalPropertyf("sim/flightmodel/position/local_y"))
defineProperty("acfZ", globalPropertyf("sim/flightmodel/position/local_z"))
function cameraDistance()
local cX = (math.abs(get(viewX)) - math.abs(get(acfX)))
local cY = (math.abs(get(viewY)) - math.abs(get(acfY)))
local cZ = (math.abs(get(viewZ)) - math.abs(get(acfZ)))
local cDist = math.sqrt((cX)^2 + (cY)^2 + (cZ)^2)
return cDist
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment