mathluagrand-theft-autofivem

Math problem with coordinates, how would I calculate a certain coordinate?


I am building a system for FiveM, by using LUA. For that system I need a specific coordinate.

Vehicle System ingame

The drawing of coordinates

I know coordinates A, B, C, D, E, P. But now I want to know point G.

How would I do that with math, and how would I do that in LUA ?


Solution

  • -- P, E, D - vectors
    local EP = P - E
    local nED = norm(D - E)
    local G = P - (EP.x*nED.x+EP.y*nED.y+EP.z*nED.z)*nED