UV coordinates for a plane?

Started by
11 comments, last by haegarr 14 years, 5 months ago
Hello, I have a rather noob question, but how do I get UV coordinates of a plane defined by a normal and by an offset? Thanks!
Advertisement
Strictly seen: Not at all. The plane as is given is infinite with no special point or direction.

If you want to have u,v you need an origin and one direction (then the other direction can be computed from the first and the normal). Since the plane doesn't have those features, you need to either pick them more or less randomly or else abstain from u,v.
Wel let's say I've origin O(x, y, z) and direction D(x, y, z). How will I be able to calculate UV?
The (u,v) tuple is nothing more than 2 co-ordinates in the 2D u,v co-ordinate system. A co-ordinate system needs an origin and as many non co-linear directions as dimensions are there. The plane has 2 dimensions but is given in 3D space. So, although the origin and u,v directions are given as 3D vectors, they need to be constrained to lie within the plane:
For the origin o
o . n - D == 0
(dependent on the definition of D you may need to use plus instead of minus above), and for the directions
u . n == 0
v . n == 0
where n denotes the plane's normal, and D the distance.

Usually u and v are choosen to be orthonormal (i.e. orthogonal and of unit length)
u . v == 0
so that
u := v x n can be used to compute u if v is already chosen.

Then any point p on the plane can be expressed by the (u,v) co-ordinate tuple because of
o + u * u + v * v == p
so that for any p the (u,v) tuple can be computed.
Thank you! But I've still a small question, how can I get a good origin? Just by randomly getting a point from the plane?
There is in fact no single definition of "good" in this case, at least not until knowing what the purpose of finding (u,v) on an infinite plane is.

Mathematically simple is the point closest to the world origin, like
o := n * D
(maybe you need to use -D here).

Or do you prefer a point that is within the view frustum of a camera? I don't know.
A small question, does this equation that you gave me results in tiles? So if my image is small does this results in tiles?
The given equations have nothing to do with tiles by itself. If you've implemented it and observe tiling, then you probably see the effect of how you've set-up texturing. By definition the entire texture is mapped in the range [0,1]x[0,1]. Now, the plane you use has infinite extension, so that the above range occurs infinitely often. For example, if you see (u,v) from (-1,-2) up to (3,4) then there are 3--1==4 tilings in u direction and 4--2==6 tilings in v direction.

You can influence this by choosing another scaling in (u,v).
So I have p and I would like for example calculate the v (coordinate).

o (origin coordinates) + u (coordinate) * u + v (coordinate) * v = p

Now I've a problem, I get a vector division? So can you show me how I can express u into p? (I am a little bit confused)

I assume p is the coordinate that I get when a ray from my raytracer hits the plane.
Quote:Original post by Disfunctional
So I have p and I would like for example calculate the v (coordinate).

o (origin coordinates) + u (coordinate) * u + v (coordinate) * v = p

Now I've a problem, I get a vector division? So can you show me how I can express u into p? (I am a little bit confused)
What you have here is a linear equation system with 3 equations:
ox + u * ux + v * vx = px
oy + u * uy + v * vy = py
oz + u * uz + v * vz = pz
where u and v are the unknown variables. So you have to apply a method os solving this system.

Quote:Original post by Disfunctional
I assume p is the coordinate that I get when a ray from my raytracer hits the plane.
p means any point on the plane. So a hit of a ray is absolutely a valid example. I've mentioned the formula to show you the correspondence between (u,v) and the belonging 3D point p due to the co-ordinate system build using o, u, and v. You can use it in the case that you need to compute (u,v) for a given point. Maybe you don't have the need at all.

This topic is closed to new replies.

Advertisement