From: Diogo de Andrade <diogo.andrade@sp...>  20110207 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 counterintuitive... 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: sextafeira, 4 de Fevereiro de 2011 19:32 To: gdalgorithmslist@... 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*(u1u0) + t2*(u2u0) = u  v0 + t1*(v1v0) + t2*(v2v0) = v That's a rather usual linear system. Noting the inverse determinant di: di = 1/((v2v0)*(u1u0)  (u2u0)*(v1v0)) then:  t1 = di*((v2v0)*(uu0)  (u2u0)*(vv0))  t2 = di*((v1v0)*(uu0)  (u1u0)*(vv0)) >From these, you can easily find the world coordinates:  x = x0 + t1*(x1x0) + t2*(x2x0)  y = y0 + t1*(y1y0) + t2*(y2y0)  z = z0 + t1*(z1z0) + t2*(z2z0) 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/oraclesfdevnlfb _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 