Calculate size on different distances

    Feb 26 2012 | 9:09 pm
    Hi, I'm working on a patch which uses z-axis information (depth) to calculate the size of an object.
    For instance an object has a width of 300 units (pixels) at 3000 units (mm) distance. The same object has a width of 400 units as 2000 units distance. With these statics I should be able to calculate the size at 2500 units distance (using a formula). I know for many of you this is basic math, but I just can't figure it out without using too many [scale] objects
    And yes, I posted this in MaxMSP on purpose, since this is done without jitter.
    Thank you for any lead.

    • Feb 26 2012 | 10:18 pm
      It may help you to think of your widths as y's and distances as x's, then use
      y = ax + b
      given a pair of points, you should find it straightforward to solve for the slope and intercept.
    • Feb 27 2012 | 8:24 am
      This sure did help me. But sadly it wasn't straightforward but a case of trial and error for me. The following patch after your example gave me an answer (Y=-0.1X+600).
      Thank you for the guideline
    • Feb 27 2012 | 12:59 pm
      This patch should guide you on how to do this programatically (bit scruffy but hey)
      What you have here essentially is the slope being the change in y/change in x, or (y2-y1)/(x2-x1)
      then given that (we'll call that value 'a')
      we can use
      y1 = a*x1 + b b = y1 - a*x1
      and that's all there is to it.