handmade.network » Forums » How to get the 3D position for the point with (0,0) UV coordinates?
stackmann0
stack mann
1 posts
#17191 How to get the 3D position for the point with (0,0) UV coordinates?
1 week, 1 day ago Edited by stack mann on Jan. 11, 2019, 5:15 p.m. Reason: Initial post

Hello,

I have a 3D triangular mesh(vertices, indices, uv coords) that I'm rendering to the screen. Let's assume that the UV mapping is one-to-one. I'm trying to find a way to find the 3D position of the point with UV coordinates equal to (0,0). I searched the internet but I only find answers that I don't find convincing.
The solution that I found:

- Find, in UV space, the triangle that contains (0,0).. let's call it T
- Calculate barycentric coordinates for (0,0) with respect to T
- interpolate the 3D positions of T's vertices using barycentric coords to get the result.

this seems wrong to me. Here's why:
Let M be the mapping between 3D space and UV space that associates UV coords for every vertex.
Let A,B and C be the vertices of T.
Let P be the origin of UV space ( P = (0,0) ).

We have P = alpha*A + beta*B + gamma*C (alpha,beta and gamma are the barycentric coords of P with respect to T).
We assumed the UV mapping to be one-to-one, so let be the inverse of M.
We have :
M°(P) = M°(alpha*A + beta*B + gamma*C)


The solution in question assumes that is linear.. if that was the case you can have:

M°(P) = alpha*M°(A) + beta*M°(B) + gamma*M°(C)


But that is not the case (correct me if I'm wrong).

So is there a way to find the 3D position of a point with specific UV coords?

Thanks in advance.