Jump to content

getParabolaPosition


Hyunsu

Recommended Posts

  
function getParabolaPos(x,y,z, x2,y2,z2, h, p) 
    -- p: 0.0 ~ 1.0 
    -- h > k 
    local k = math.abs((z-z2)); 
    if h <= k then 
        h = k + 1; 
    end 
    local d2_c = getDistanceBetweenPoints2D(x,y,x2,y2); 
    local a2 =0; 
    local d2 =0; 
     
    if z > z2 then 
        d2 = d2_c * (1-p); 
        a2 =math.atan2 (( x - x2 ), ( y - y2 )); 
    else 
        d2 = d2_c * p; 
        a2 =math.atan2 (( x2 - x ), ( y2 - y )); 
    end 
     
    local rv = 1-(k/(h+k)); 
    local b = (2*(h+k)*(1+math.pow(rv, 1/2)))/d2_c; 
    local a = (b*b)/(-4*(h+k)); 
     
    if rv < 0 then 
        outputChatBox("erre"); 
    end 
     
    local gz = d2*(a*d2 + b); 
    local gx,gy = d2*math.sin(a2), d2*math.cos(a2); 
    if z > z2 then 
        gx = x2 + gx; 
        gy = y2 + gy; 
        gz = z2 + gz; 
    else 
        gx = x + gx; 
        gy = y + gy; 
        gz = z + gz; 
    end 
    return gx, gy, gz; 
end 
  

this is a test script.

  
  
local index = 0; 
        while true do 
            local gx,gy,gz = getParaPos(sx,sy,sz,ex,ey,ez, 20, 0.02*index); 
            createObject(354, gx,gy,gz); 
            index = index + 1; 
            if index == 50 then 
                --setElementPosition(getLocalPlayer(),gx,gy,gz); 
                break; 
            end 
        end 
  

"h" is a height on a point that has bigger "z" than another point's "z".

mtascreen20130113113313.png

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...