Author Topic: interpolation  (Read 3724 times)

0 Members and 1 Guest are viewing this topic.

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
interpolation
« on: July 29, 2011, 06:02:02 pm »
I want to calculate the value of a point, based on the position of the point between 4 other points with each an other value.
an image to illustrate what I'm trying to say:

In this image, there are 4 points with a given value of a and a point between those 4 points which has got an unknown value of a. I now want to know how i can calculate value a of that point, based on the position of that point so that when x=x1 and y=y1, a=a1=1, and when x=x2 and y=y2, a=a2=2, and so on. And when point (x,y) is in the middle of (x1,y1) and (x2,y2), a should be the average of a1 and a2, so a=1.5.

Is there a formula which i can use to interpolate the a value of a point between the a values of the other points?
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: interpolation
« Reply #1 on: July 29, 2011, 06:56:55 pm »
I'm going to guess that for an arbitrary quad, you're not going to find a nice (IE: quick to evaluate) function for that. However, assuming you're using this for your polygon engine, there is a method you could potentially use to cheat, at the cost of some accuracy. Recognize that all planar quads* are simple transformations of square such as moving individual vertices, increasing the width, etc. So, if you compute a lookup table for a reference square (basically the values of a at different points), all that remains is to apply the transformations and then find the nearest point in the lookup table. As long as you use enough points and don't have any massive quads, the approximation will be relatively close.

*non-planar quads are a whole 'nother bucket of pain since you have to work in 3d. This method would work for them to with some extensions.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: interpolation
« Reply #2 on: July 29, 2011, 07:08:17 pm »
Yes, it's for my polygon 3d engine.

I was already planning to use it to calculate the texture coordinates of points every 5 or 10 pixels or so, depending on the size of the quad, and then calculate the rest of them with linear interpolation. But i still don't really get how i should calculate those reference points. (if they are easyer and/or faster to calculate for triangles, then say so. I only use quads becouse I really messed it up with my routines for affine texture mapped triangles) and if you said that in your post, then could you please explain it a bit more? I didn't understood your post very well and google translate just gave me a bunch of random words.

And yea, the quads will all be planar, so no skew quadrilaterals (I hope google translate has translated this correctely)

btw: thanks for your quick reply
« Last Edit: July 29, 2011, 07:37:58 pm by ben_g »
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: interpolation
« Reply #3 on: July 29, 2011, 08:19:04 pm »
Sorry for the reply time. I was just arguing with some tech support...

Anyway, I'm not really sure what your original problem is. Are you trying to calculate what textures need to be applied to the locations?
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: interpolation
« Reply #4 on: July 30, 2011, 02:49:09 pm »
actually i was trying to find a way to do fake texture correction based on the shape of the quad, becouse, with affine texture mapping, a wall looked from an angle looks like this:

When you look at this, it looks like it's textured well, but when you look a bit closer, you see that the texels (pixels of the texture) all have the same width, while the height is mapped correctely. This gives the optical illusion that the texels look longer on the right side than on the left side, becouse the texels on the right side are actually further away, thus they should be smaller.

Now look at this picture:

this looks more realistic: the texels on the far side are smaller than the texels closer to the 'camera'. I want a way to fake this, becouse for texture correction, a lot of complex fixed-point calculations needs to be done, which would make it very slow. I don't really know if what i said in my first post will have the right effect, but actually, I want to calculate what texel should be drawn at a location so the texture is mapped like in the secound image, but this based on the height of the quad, and it's texture coordinates. I think everybody would agree that the secound image looks a lot more 3D than the first image, while they have exactely the same shape.

I hope i explaned it correctly and that you don't find it annoying that i mainly use images to explain it.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated