Quadrilateral Interpolation

BlitzMax Forums/BlitzMax Programming/Quadrilateral Interpolation

JoshK(Posted 2009) [#1]
Given four points, each with a 2D texcoord, how do you find the texcoord of any point within? The quad cannot be split into two triangles and solved separately.

http://www.gamedev.net/community/forums/topic.asp?topic_id=538963




GfK(Posted 2009) [#2]
Don't know the answer but I'm positive there was some Blitz3D sample code (written by Birdie?) that did exactly this.

If his code was based on a mathematical algorithm then it wouldn't be hard to adapt to Blitzmax.


slenkar(Posted 2009) [#3]
is there any way you can use the texture matrix to solve this?


JoshK(Posted 2009) [#4]
That quad does look an awful lot like a frustum matrix, but I am not sure how to turn it into one.


_Skully(Posted 2009) [#5]
I wonder if the poly rendering sites would be helpful here. It's a point in a poly translated into a normal


JoshK(Posted 2009) [#6]
I solved it this way:

Find the point where the top and bottom lines meet. Find the angle of each point from the intersection point. Now find the angle of the point we want to find, from the intersection point. It will be between the other two angles, and its percentage of each tells you how to interpolate between those two values.

Do the same for the left and right side, for the other coordinate.

You have to check for the case where the edges are parallel, but that is easy.


Midimaster(Posted 2009) [#7]
sorry, empty post


beanage(Posted 2009) [#8]
Thanks.


xMicky(Posted 2009) [#9]
I would prefer a simple geometric solution:




BlitzSupport(Posted 2009) [#10]
Nice! I tried for ages a couple of years ago to do this, to no avail. I imagine I'll make use of this at some point -- thanks.