XY-coordinates from UVW on planes
well, i''m writing a small raytracer (like everyone does nowadays)
and i''m at the point to add textures.
so i''ve coded UVW-vectors for the planes, where the U and the V vectors lying on the plane, and the W vector is the Normal of the Plane.
And now i want to calculate the XY-texture coordinates from the point a ray intersects with the plane as a multiple of the UVW-vectors, but i don''t know how to do this.....i hope you can help me....
thank in advance
hey, life has to go on
So you're looking for the solution to the following equations...
which can be written as a matrix equation:
This 3x3 matrix is the transformation matrix from UVW space into XYZ space. It is given by the inverse of the transformation matrix from XYZ space to UVW space.
So, presumably you have equations for U, V and W given by
(and i,j, and k are aligned with the cartesian axes)
then the following holds
(I is the identity matrix)
There are several methods for working out the inverse of a matrix using numerical schemes. Several of these have been discussed in these forums before and can be found in the archives. Otherwise do a google search or grab an introductory text on linear algebra.
Good luck,
Timkin
[edited by - Timkin on August 11, 2002 10:51:18 PM]
X = x1U + x2V + x3W Y = y1U + y2V + y3W Z = z1U + z2V + z3W
which can be written as a matrix equation:
|X| |x1 x2 x3| |U||Y| = |y1 y2 y3| |V||Z| |z1 z2 z3| |W|
This 3x3 matrix is the transformation matrix from UVW space into XYZ space. It is given by the inverse of the transformation matrix from XYZ space to UVW space.
So, presumably you have equations for U, V and W given by
U = u1i + u2j + u3k V = v1i + v2j + v3k W = w1i + w2j + w3k
(and i,j, and k are aligned with the cartesian axes)
then the following holds
|x1 x2 x3|A = |y1 y2 y3| |z1 z2 z3| |u1 u2 u3|B = |v1 v2 v3| |w1 w2 w3|A = B-1since AB = I
(I is the identity matrix)
There are several methods for working out the inverse of a matrix using numerical schemes. Several of these have been discussed in these forums before and can be found in the archives. Otherwise do a google search or grab an introductory text on linear algebra.
Good luck,
Timkin
[edited by - Timkin on August 11, 2002 10:51:18 PM]
big thx for the hint.....
....i hope it''ll work and i hope i''ll understand all of this matrix-stuff (since i''ve never done this before)
....i hope it''ll work and i hope i''ll understand all of this matrix-stuff (since i''ve never done this before)

hey, life has to go on
The inverse matrix can be found by dividing all the elements in the matrix by the determinent. But first you have to flip the down diagonal elements and negate the up diagonal elements (in a 2x2)... and for a 3x3 it's a lot more complex 
Here's a picture I hijacked from MathWorld:

You should visit that inverse page, because it gives you a lot of cross-reference links to things like the determinant.
[edited by - Zipster on August 24, 2002 2:10:47 PM]

Here's a picture I hijacked from MathWorld:

You should visit that inverse page, because it gives you a lot of cross-reference links to things like the determinant.
[edited by - Zipster on August 24, 2002 2:10:47 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement