Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## Re: [Algorithms] Texel area

 Re: [Algorithms] Texel area From: Diogo de Andrade - 2011-02-07 10:21:37 ```Hi Olivier, I was already having similar thoughts on how to solve this (use the barycentric coordinates to solve a linear system), so it seems to me that you got the jist of it, I'm going to try implementing... I'm just unclear on a couple of things: > That's a rather usual linear system. Noting the inverse determinant How does this matter? Not questioning it, just trying to understand what follows from here... > You'll notice that all these are linear systems, which means a texel rectangle size is independant of its position. This seems counter-intuitive... I understand your reasoning, and I can't find a mistake in your logic, but it seems to me that the size shouldn't be constant (from an intuitive standpoint)... Best regards, Diogo -----Original Message----- From: Olivier Galibert [mailto:galibert@...] Sent: sexta-feira, 4 de Fevereiro de 2011 19:32 To: gdalgorithms-list@... Subject: Re: [Algorithms] Texel area On Fri, Feb 04, 2011 at 10:50:08AM -0000, Diogo de Andrade wrote: > So, what I want to do is, given > > - triangle T=(V1,V2,V3), in which V1, V2, V3 are vertexes that have > some properties (world space position, normal, diffuse color, texture > coordinates > 0 (in uniform space), texture coordinates 1 (in texture space, > [0..texture size[), etc), > > - texture size > > - position inside the triangle (absolute value in texture space) > > is to find out the rectangle that bounds the texel in world space > (origin+2 vectors)... If that's your real problem, the solution is reasonably simple and has nothing to do with the rasterization. You have three points when space/texture coordinates: (x0, y0, z0, u0, v0) (x1, y1, z1, u1, v1) (x2, y2, z2, u2, v2) Given u, v the position in texture space, you first want to find the barycentric coordinates (t1, t2): | u0 + t1*(u1-u0) + t2*(u2-u0) = u | v0 + t1*(v1-v0) + t2*(v2-v0) = v That's a rather usual linear system. Noting the inverse determinant di: di = 1/((v2-v0)*(u1-u0) - (u2-u0)*(v1-v0)) then: | t1 = di*((v2-v0)*(u-u0) - (u2-u0)*(v-v0)) | t2 = di*((v1-v0)*(u-u0) - (u1-u0)*(v-v0)) >From these, you can easily find the world coordinates: | x = x0 + t1*(x1-x0) + t2*(x2-x0) | y = y0 + t1*(y1-y0) + t2*(y2-y0) | z = z0 + t1*(z1-z0) + t2*(z2-z0) You'll notice that all these are linear systems, which means a texel rectangle size is independant of its position. So you can get your vector once by computing the position differences between (0, 0), (0.5, 0) and (0, 0.5) for instance. You'll notice the equations simplify nicely when computing deltas if you do the math. I suspect it's not your real problem though, so feel free to correct it :-) OG. ---------------------------------------------------------------------------- -- The modern datacenter depends on network connectivity to access resources and provide services. The best practices for maximizing a physical server's connectivity to a physical network are well understood - see how these rules translate into the virtual world? http://p.sf.net/sfu/oracle-sfdevnlfb _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list ```