Jump to content
Sign in to follow this  
sakura_chan

math...halp!!!

Recommended Posts

I'm terrible at math, but I need to figure this out.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

format: [x,y,z]

getpos'd array 1 = [300, 1200, 50]

getpos'd array 2 = [400, 1600, 40]

find x and z [ x, 1400, z ]

I need to interpolate the equation between the first

two arrays. I have no idea how to do this, math really

is a limit for me. Any equations or math links would be appreciated!

Share this post


Link to post
Share on other sites

923c8752285580253e9de77fca6a3800.png

so in ur case

x = 300+(1400-1200)*((400-300)/(1600-1200)) = 350

and

z = 50+(1400-1200)*((40-50)/(1600-1200)) = 45

Edit: 1550th post nener.gif

Share this post


Link to post
Share on other sites

you can also of course make it abstract:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

array 1 = [300, 1200, 50]

array 2 = [400, 1600, 40]

intkey = 1400

x = array1[0] + (intkey - array1[1])*((array2[0]-array1[0])/(array2[1]-array1[1]))

z = array1[2] + (intkey - array1[1])*((array2[2]-array1[2])/(array2[1]-array1[1]))

this way all u have to do is change the arrays and the intkey and the interpolation will happen automatically. NOTE: This is NOT ArmA sqs or SQF syntax but rather pseudocode. Try looking up getting array values I think its somethig like (array1 select 1).

Share this post


Link to post
Share on other sites

okay I got it all syntaxed and working. I'm using it to interpolate range data from a range table. Thanks again smile_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×