如何将平面上的3D点转换为UV坐标? [英] How to convert a 3D point on a plane to UV coordinates?

查看:380
本文介绍了如何将平面上的3D点转换为UV坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3d点,由[x0, y0, z0]定义.

I have a 3d point, defined by [x0, y0, z0].

此点属于由[a, b, c, d]定义的平面.

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

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

如何将3d点转换或映射到一对(u,v)坐标?

How can convert or map the 3d point to a pair of (u,v) coordinates ?

这一定很简单,但我无法弄清楚.

This must be something really simple, but I can't figure it out.

推荐答案

首先,您需要计算uv向量. uv应该与您的平面的法线正交,并且彼此正交.没有定义它们的独特方法,但是一种便捷的方法可能是这样的:

First of all, you need to compute your u and v vectors. u and v shall be orthogonal to the normal of your plane, and orthogonal to each other. There is no unique way to define them, but a convenient and fast way may 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 a simple dot product will do:

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

请注意,这假定u-v坐标的原点是世界原点(0,0,0).

Notice that this assumes that the origin of the u-v coordinates is the world origin (0,0,0).

这将起作用,即使您的矢量[x0 y0 z0]并不完全位于飞机上也是如此.如果是这种情况,它将仅将其投影到飞机上.     

This will work even if your vector [x0 y0 z0] does not lie exactly on the plane. If that is the case, it will just project it to the plane.      

这篇关于如何将平面上的3D点转换为UV坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆