How to convert a three-dimensional point on a plane to UV coordinates?

I have a three-dimensional point defined by [x0, y0, z0] .

This point belongs to the plane defined by [a, b, c, d] .

normal = [a, b, c] and ax + by + cz + d = 0

How to convert or display a three-dimensional point into a pair of coordinates (u,v) ?

It should be something very simple, but I cannot understand.

+6
source share
2 answers

First of all, you need to compute your vectors u and v . u and v must be orthogonal to the normals of your plane and orthogonal to each other. There is no unique way to define them, but a convenient and quick way might be something like this:

 n = [a, b, c] u = normalize([b, -a, 0]) // Assuming that a != 0 and b != 0, otherwise use c. v = cross(n, u) // If n was normalized, v is already normalized. Otherwise normalize it. 

Now the simplest point product will do:

 u_coord = dot(u,[x0 y0 z0]) v_coord = dot(v,[x0 y0 z0]) 

Note that this assumes that the origin uv is of world origin (0,0,0).

This will work even if your vector [x0 y0 z0] does not lie exactly on the plane. If so, he simply projects it onto the plane.

+8
source

Assuming you want to find the coordinates of any point in the plane, in terms of the coordinates (u, v) ...

If the point [x0, y0, z0] lies in the plane, then we know that

 dot([a,b,c],[x0,y0,z0]) = -d 

Where point is the point product between two vectors. It just rewrites the equation of the plane.

The trick is to find two vectors that span the flat subspace. To do this, choose a random vector of length 3. Name it V0. I will call the flat normal vector

 N = [a,b,c] 

Next, use the transverse product of the normal vector N with V0.

 V1 = cross(N,V0) 

This vector will be orthogonal to the normal vector if we were not extremely unsuccessful, and N and V0 were collinear. In this case, just select another random vector V0. We can say whether these two vectors were collinear, because then V1 will be the vector [0 0 0].

So, if V1 is not a zero vector, then we divide each element by the norm of V1. The norm of the vector is simply the square root of the sum of the squares of the elements.

 V1 = V1/norm(V1) 

Next, we choose the second vector V2, orthogonal to both N and V1. Again, a cross-product vector makes this trivial. Normalize this vector to have a unit length. (Since we now know that V1 is a unit norm vector, we could simply divide by the norm (N).)

 V2 = cross(N,V1) V2 = V2/norm(V2) 

ANY point in the plane can now be described trivially as a function of (u, v), since:

 [x0,y0,z0] + u*V1 + v*V2 

For example, when (u, v) = (0,0), we obviously get [x0, y0, z0] back, so we can think of this point as β€œorigin” in the coordinates (u, v).

Similarly, we can do things like restore u and v from any point [x, y, z], which, as you know, lies in a plane, or we can find a normal projection for a point that is not in a plane, projected into this plane.

+3
source

Source: https://habr.com/ru/post/953346/