在 3D 空间中的点之间进行插值以形成光滑表面的简单方法 [英] Simple way to interpolate between points in 3D space to form a smooth surface

查看:16
本文介绍了在 3D 空间中的点之间进行插值以形成光滑表面的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图想出一种简单而有效的方法来创建一个与多个给定样本"点相交的光滑表面.

I'm trying to come up with a simple and efficient way to create a smooth surface which intersects a number of given "sample" points.

对于表面上的任何 X、Y 点,我在 4 个方向中的每个方向(X 轴上的下一个较高点和较低点,然后是 Y 轴)中识别出最多 4 个采样点.鉴于这一点,我想要一种方法来计算在 4 个样本点之间插值的 Z 值.

For any X,Y point on the surface, I identify up to 4 sample points in each of the 4 directions (the next higher and lower points on the X, and then the Y axes). Given this point, I want a way to compute a Z value that interpolates between the 4 sample points.

当然,在给定 4 个采样点中任何一个的 X、Y 位置的情况下,该算法应该输出该点的 Z 值.另请注意,样本点可能少于 4 个.

Of course the algorithm, given the X, Y position of any of the 4 sample points, should output the Z value for that point. Note also that there may be less than 4 sample points.

我猜想 4 个样本点的 Z 值的某些函数,不知何故与样本点的距离成反比,但我不知道该怎么做.

I guess some function of the Z values for the 4 sample points, somehow inversely biased by the distance to the sample point, but I can't figure out how to do this.

有人对实现此目的的简单方法有任何想法吗?

Anyone got any ideas about a simple way to do this?

推荐答案

您可以通过从 Catmull-Rom 样条线构造补丁来做到这一点.这些样条线将撞击每个控制点,并且它们在一阶导数中是连续的(尽管不是二阶导数).我还发现它们非常容易使用.数学很简单,它们的行为很直观,控制点略有变化.

You can do this by constructing patches from Catmull-Rom splines. These splines will hit each of the control points and they are continuous in the first derivative (though not the second). I also find them to be extremely easy to work with. The math is straightforward and they behave intuitively with slight changes in the control points.

在最高级别,每个补丁需要 16 个点(在数据集的边缘,您可以在同一样条曲线中使用角点和边缘点两次).

At the highest level, you'll need 16 points per patch (at the edge of your dataset, you can use the corner and edge points twice in the same spline).

首先,您需要对 4x4 矩阵中每一行的点 p[i][j] 进行插值,以创建一组四个中间控制点 q[i].这是我的意思的粗略 ASCII 草图.

First, you'll need to interpolate across the points p[i][j] in each row in your 4x4 matrix to create a set of four intermediate control points q[i]. Here's a rough ASCII sketch of what I mean.

p00 p01 q0 p02 p03
p10 p11 q1 p12 p13
p20 p21 q2 p22 p23
p30 p31 q3 p32 p33

现在您可以在这四个中间控制点之间进行插值,以找到曲面上的最终样条点.

Now you can interpolate between each of those four intermediate control points to find a final splined point on your surface.

这里是 Catmull-Rom 样条的构造 跨越四个点.在此示例中,您在点 p[i-1]p[i] 之间进行插值,使用两侧的控制点 p[i-2]p[i+1].u 是从零到一的插值因子.τ 定义为样条上的张力,它会影响样条曲面与控制点的贴合程度.

Here is a construction of the Catmull-Rom spline across four points. In this example, you are interpolating between points p[i-1] and p[i], using control points on either side p[i-2] and p[i+1]. u is the interpolation factor ranging from zero to one. τ is defined as the tension on the spline and will affect how tightly your splined surface conforms to your control points.

                 | 0   1   0    0 | | p[i−2] |
                 |−τ   0   τ    0 | | p[i−1] |
p(u) = 1 u u2 u3 | 2τ τ−3 3−2τ −τ | | p[i]   |
                 |−τ  2−τ τ−2   τ | | p[i+1] |

注意:如何在 Stackoverflow 的 gui 中进行布局并不是很明显,但 u2u3 应该代表 u squaredu 立方,分别.

NOTE: it's not immediately obvious how to lay this out in Stackoverflow's gui but u2 and u3 are supposed to represent u squared and u cubed, respectively.

这篇关于在 3D 空间中的点之间进行插值以形成光滑表面的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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