Author Topic: What is meant by Interpolate?  (Read 2688 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
What is meant by Interpolate?
« on: February 08, 2007 »
I'm going to be making a draw triangle routine. So far I've discovered that you can either have; flat bottom, flat top or a generic triangle ( which is basically 2 triangles, one a flat top the other a flat bottom ). And have been looking at a few examples, and have noticed Interpolate crop up alot and wondered what was meant by it?

Cheers and many thanks,
Clyde.

Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: What is meant by Interpolate?
« Reply #1 on: February 08, 2007 »
To interpolate means to move between two values over a given time / distance.

For example, if you have two sets of co-ordinates;

X1=100
Y1=100

X2=150
Y2=200

You could say;

Inter = (X2 - X1) / (Y2 - Y1)

For a=Y1 to Y2

Xcurrent =Xcurrent + inter

next

That is the sort of thing you will be doing in your triangle routine.
Basically you work out the distance of X and then divide it by the amount of steps you are going to do which will give you a value that you can add or subtract to get you where you want to go.

You need this technique for lots of stuff, it's worth learning.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: What is meant by Interpolate?
« Reply #2 on: February 08, 2007 »
Cheers mate, so I would first need to work out what is biggest and smallest values were for calculating interpolations?
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: What is meant by Interpolate?
« Reply #3 on: February 08, 2007 »
Bresenham's line drawing algorithm is one of the best examples (real fast) and can be easily adapted to triangles and even curves its accurate to one pixel and where the line is +.5 the value will round up

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: What is meant by Interpolate?
« Reply #4 on: February 08, 2007 »
Clyde, what you need to interpolate between two values are;

Value 1
Value 2

Amount of steps

You subtract one value from the other and divide by the number of steps.
Once you have the step to add in the loop it's fairly easy to say for example;

current_number = current_number + step size

at it's most simple, a for next loop uses interpolation.

For A = 0 to 100 step 10
Print A
next A

Interpolation is just a large word which means to go from one number to a target number.

You don't need to swap the numbers around generally. (ie smallest and largest).
This is because if the result of x1-x2 is negative or positive, it won't matter.

If STEP is -1.1 and Current = 0

current=current + STEP

Current would now be -1.1

If STEP is +1.1 and Current = 0

current=current + STEP

Current would now be +1.1

So it all comes out right.
Make sure that you use signed numbers, singles or doubles where you can.
Shockwave ^ Codigos
Challenge Trophies Won: