Finding 3D co-ordinates of UV(1,1)?

This topic is 3120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Given 3 vertices in 3D space, each with a texture co-ordinate, how do you find the 3D co-ordinates of UV(1,1)(0,0)(1,0)and (0,1). Assuming the 3 texture co-ordinates are all different, < 1.0 and > 0.0. Sounds really simple until you try to work it out. :( Any help greatly appreciated.

Share on other sites
Form the matrices
 [u1 u2 u3] [v1 v2 v3] = U [ 1  1  1]

and
 [x1 x2 x3] [y1 y2 y3] = X [z1 z2 z3]

Then the point corresponding to a particular UV is given by X * inverse(U) * vec3(u,v,1). For example X * inverse(U) * vec3(1,1,1) is the point corresponding to a UV of (1,1).

[Edited by - Pragma on May 1, 2010 8:52:19 PM]

Share on other sites
Quote:
 Original post by PragmaForm the matrices [u1 u2 u3] [v1 v2 v3] = U [ 1 1 1]and  [x1 x2 x3] [y1 y2 y3] = X [z1 z2 z3]Then the point corresponding to a particular UV is given by X * inverse(U) * vec3(u,v,1). For example X * inverse(U) * vec3(1,1,1) is the point corresponding to a UV of (1,1).

What are u1,v1, u2,v2, u3,v3?
What are x1,y1,z1, x2,y2,z2, x3,y3,z3?

Share on other sites
He said he had 3 vertices in 3d space, each with a texture coordinate. So
(u1, v1) = texture coordinate of first vertex
(x1, y1, z1) = position of first vertex
(u2, v2) = texture coordinate of second vertex
... etc.

Share on other sites
Quote:
 Original post by PragmaHe said he had 3 vertices in 3d space, each with a texture coordinate. So(u1, v1) = texture coordinate of first vertex(x1, y1, z1) = position of first vertex(u2, v2) = texture coordinate of second vertex... etc.

The xyz part is a matrix of a triangle? If you took the inverse of such a matrix, what exactly would that represent?

Share on other sites
Quote:
 Original post by samster581The xyz part is a matrix of a triangle? If you took the inverse of such a matrix, what exactly would that represent?

Yes, it's for a triangle, specifically to find the flat(or planar) projection of a UV textured triangle.

@Pragma 10 years since I did any matrix maths so taking a while to work out the equations, simplify them and test it with real numbers, thanks for the inverse of a matrix btw OMG :-D
Seriously, if this works, your a mega genius, how the hell did you figure out that solution? Guess it's knowing the power of matrices...

Share on other sites
Maybe it's easier just to think about it as a system of linear equations. Every point in the plane of the triangle can be written as a linear combination of the vertices with coefficients a,b,c that sum to one. Suppose this point has UV of (u,v) and coordinates (x,y,z). Then the equations it satisfies are:
u = a u1 + b u2 + c u3v = a v1 + b v2 + c v31 = a + b + cx = a x1 + b x2 + c x3y = a y1 + b y2 + c y3v = a z1 + b z2 + c z3

Now this starts to look like a pair of matrix equations. We can write them as
 [u1 u2 u3] [a]     [a]    [v1 v2 v3]  = U  = [v] [ 1  1  1] [c]     [c]   [1] [x1 x2 x3] [a]     [a]   [x] [y1 y2 y3]  = X  = [y] [z1 z2 z3] [c]     [c]   [z]

This is where the matrices U and X came from. Now we can use the first matrix equation to solve for a, b and c as
 [a]         = U^-1 [v][c]        [1]

and plug this answer in to the second equation to get
[x]     [a]            [y] = X  = X * U^-1 [v][z]     [c]            [1]

[Edited by - Pragma on May 3, 2010 5:37:59 AM]

Share on other sites
Can't get it to work :(
Either i'm doing something fundamentally wrong, screwed up the inverse or it just doesn't work. Using a column vector, that's ok isn't it?

Some real data if you want to try it.
x,y,z -41.3953 -7.9605 -97.3297 uv(0.12500, 0.12500)
x,y,z 34.4961 -45.9345 27.6143 uv(0.81250 0.43750)
x,y,z -20.6976 39.8266 -4.0867 uv(0.31250 0.62500)

Share on other sites
Yes, everything should be a column vector. Maybe check your matrix inversion?

The method works fine for me. Here's some octave code I used to test it:
X = [ -41.3953,  34.4961, -20.6976;       -7.9605, -45.9345,  39.8266;      -97.3297,  27.6143,  -4.0867];U = [ 0.12500, 0.81250, 0.31250,      0.12500, 0.43750, 0.62500,      1.00000, 1.00000, 1.00000];M = X * inverse(U);M * [0.12500; 0.12500; 1]M * [0.81250; 0.43750; 1]M * [0.31250; 0.62500; 1]

And here's the output:
ans =  -41.3953   -7.9605  -97.3297ans =   34.496  -45.934   27.614ans =  -20.6976   39.8266   -4.0867

Share on other sites
Also if you want to compare to your code, the matrix I get is
M =   1.1039e+02   1.0959e-04  -5.5194e+01  -1.1895e+02   1.4018e+02  -1.0614e+01   1.1690e+02   1.4265e+02  -1.2977e+02

1. 1
Rutin
71
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• Forum Statistics

• Total Topics
633428
• Total Posts
3011822
• Who's Online (See full list)

There are no registered users currently online

×