Lookup table help

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi

    I'm wondering how I could make an array do linear interpolation (ideally a 'cubic spline' or something) between the two closest known values to fill in the gaps from a limited set of data. What I'm trying to make is a torque/rpm lookup table for a car game.

    Cheers!

  • Well, suppose you want to get the value interpolated at X = 4.7. First you want the integer part and float part (4 and 0.7), which are floor(X) and X - floor(X) respectively.

    The expression lerp(a, b, x) does linear interpolation - so we want to interpolate between the two nearest array entries, floor(X) and floor(X) + 1.

    Which is something like:

    lerp(Array(Floor(X)), Array(Floor(X) + 1), X - floor(X))

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, but I couldn't get that to work. I'm not sure it's what i need.

    I have 12 or so known values with 500 unknown between each, all 6000 values need numbers.

    Basically increasing 12 numbers to a resolution of 6000.

    I might need a specific example, I'm pretty dumb.

  • The lerp function linearly interpolates between values, so you'd get an unlimited number of in-between values - if you want the 3000th (half way) value between the 8th and 9th item, you'd use that formula with X = 8.5 (ie. half way between 8 and 9). Does that help?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)