Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
18 May, 2013, 10:01:54 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: interpolation -  (Read 480 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 00:38:47
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« on: 30 July, 2011, 00:02:02 »
0

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?
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:41:29
Date Registered: 15 August, 2010, 09:18:54
Posts: 3187


Total Post Ratings: +218

View Profile
« Reply #1 on: 30 July, 2011, 00:56:55 »
0

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.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 00:38:47
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« Reply #2 on: 30 July, 2011, 01:08:17 »
0

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: 30 July, 2011, 01:37:58 by ben_g » Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 00:41:29
Date Registered: 15 August, 2010, 09:18:54
Posts: 3187


Total Post Ratings: +218

View Profile
« Reply #3 on: 30 July, 2011, 02:19:04 »
0

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?
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
ben_g
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: Today at 00:38:47
Date Registered: 08 May, 2011, 21:03:27
Location: (ix+$43)
Posts: 645


Topic starter
Total Post Ratings: +74

View Profile
« Reply #4 on: 30 July, 2011, 20:49:09 »
0

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.
Logged

Spoiler for completely unimportant stuff:
My projects
 - A base converter that also supports signed and fixed-point numbers.
 - A first person shooter with a polygon-based 3d engine.
Spoiler for latest screenshot:
- A java MORPG.
Spoiler for screenshot:
- a minecraft game in axe
Spoiler for Only open this spoiler if you want to read what's inside:
What's inside.
From when I saw this image, I never lost the game again!
Spoiler for This is [Edit:
not[/Edit] my contest entry. I hope you like it.]
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.27 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.