重心计算有何用途?

发布于 2024-11-08 13:37:35 字数 76 浏览 0 评论 0原文

我一直在研究 XNA 的重心方法,网上找到的描述对我来说相当不透明。举个例子就好了。只要有英文解释就太好了...目的是什么以及如何使用它?

I've been looking at XNA's Barycentric method and the descriptions I find online are pretty opaque to me. An example would be nice. Just an explanation in English would be great... what is the purpose and how could it be used?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾听心声的旋律 2024-11-15 13:37:35

来自维基百科

在几何中,重心坐标系是一种坐标系,其中点的位置被指定为放置在单纯形(三角形、四面体等)顶点处的质量的质心或重心。

我相信它们用于游戏开发中的光线追踪。

当光线与普通网格中的三角形相交时,您只需将其记录为命中或未命中。但是,如果您想实现一个subsurf修改器(下图),这使得网格更加平滑,您将需要光线到达三角形中心的距离(这更容易在重心坐标)。

Subsurf 修改器并不难想象:

Subsurf modifier

立方体是原始形状,内部的平滑网格是“ subsurfed”立方体,我认为递归深度为三或四。


事实上,这可能不正确。不要相信我的确切说法,但我确实知道它们用于几何形状上的纹理映射。

您可以查看以下几张幻灯片: http ://www8.cs.umu.se/kurser/TDBC07/HT04/handouts/HO-lecture11.pdf

From Wikipedia:

In geometry, the barycentric coordinate system is a coordinate system in which the location of a point is specified as the center of mass, or barycenter, of masses placed at the vertices of a simplex (a triangle, tetrahedron, etc).

They are used, I believe, for raytracing in game development.

When a ray intersects a triangle in a normal mesh, you just record it as either a hit or a miss. But if you want to implement a subsurf modifier (image below), which makes meshes much smoother, you will need the distance the ray hit from the center of the triangle (which is much easier to work with in Barycentric coordinates).

Subsurf modifiers are not that hard to visualize:

Subsurf modifier

The cube is the original shape, and the smooth mesh inside is the "subsurfed" cube, I think with a recursion depth of three or four.


Actually, that might not be correct. Don't take my exact word for it, but I do know that they are used for texture mapping on geometric shapes.

Here's a little set of slides you can look at: http://www8.cs.umu.se/kurser/TDBC07/HT04/handouts/HO-lecture11.pdf

鲜血染红嫁衣 2024-11-15 13:37:35

实际上,点 P 相对于三角形 ABC 的重心坐标就是其根据三角形顶点的权重 (u,v,w),使得 P = u*A + v*B + w*C。如果该点位于三角形内,则在 [0,1] 中得到 u,v,w,并且 u+v+w = 1。

它们可用于涉及了解点相对于三角形顶点的位置的任何任务,例如在三角形上插值属性。例如,在光线追踪中,您在三角形内有一个生命点。当您想知道该点的法线或其他属性时,您可以计算其在三角形内的重心坐标。然后,您可以使用这些权重来总结三角形顶点的属性,并获得插值属性。

要计算三角形 ABC 内点 P 的重心坐标 (u,v,w),您可以使用:

u = [PBC] / [ABC]
v = [APC] / [ABC]
w = [ABP] / [ABC]

其中 [ ABC] 表示三角形 ABC 的面积。

In practice the barycentric coordinates of a point P in respect of a triangle ABC are just its weights (u,v,w) according to the triangle's vertices, such that P = u*A + v*B + w*C. If the point lies within the triangle, you got u,v,w in [0,1] and u+v+w = 1.

They are used for any task involving knowledge of a point's location in respect to the vertices of a triangle, like e.g. interpolation of attributes across a triangle. For example in raytracing you got a hitpoint inside the triangle. When you want to know that point's normal or other attributes, you compute its barycentric coordinates within the triangle. Then you can use these weights to sum up the attributes of the triangle's vertices and you got the interpolated attribute.

To compute a point P's barycentric coordinates (u,v,w) within a triangle ABC you can use:

u = [PBC] / [ABC]
v = [APC] / [ABC]
w = [ABP] / [ABC]

where [ABC] denotes the area of the triangle ABC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文