Skip to content

Instantly share code, notes, and snippets.

@wowjeeez
Last active October 26, 2020 16:13
Show Gist options
  • Save wowjeeez/f5f02c0e904e9ae1ee9d2c29613a7f27 to your computer and use it in GitHub Desktop.
Save wowjeeez/f5f02c0e904e9ae1ee9d2c29613a7f27 to your computer and use it in GitHub Desktop.
LUA snippet to calculate a point between 2 coords
function getPointOnLine(vec1, vec2, point) --the point on the line [point is always smaller then the distance between the 2 coords] (to get the coords on the center, just divide the distance with 2)
distance = #(vec1 - vec2) --distance
vec3 = vec1 + (point/distance) * (vec2 - vec1)
return vec3
end
--p: one-dimensional numner
@wowjeeez
Copy link
Author

wowjeeez commented Oct 3, 2020

illustration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment