3D 计算机图形学中的插值

发布于 2024-10-11 06:35:03 字数 51 浏览 4 评论 0原文

我想知道是否有人可以帮助用简单的术语解释什么是插值以及它如何在 3D 计算机图形学中使用

I was wondering if someone could help with explaining in simple terms what interpolation is and how its used in 3d computer graphics

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

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

发布评论

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

评论(4

彡翼 2024-10-18 06:35:03

简单地说:给定两个点A和B,找到它们之间的一个点。

例如,如果我想沿着一条线一步将某物从位置 x=1 移动到 x=4:

1-----------------------4

第一步位于位置 1,第二步位于位置 4,因此该对象会立即从一个位置移动到另一个。但是,如果我希望对象花费一定的时间或帧数来进行过渡,我需要通过查找均匀间隔的中间点来优化它。

如果我希望对象采取两步(或帧)从 1 移动到 4,

1-----------X-----------4

我需要计算新点 (X) 是什么,以便我可以在适当的时间在那里绘制对象。在本例中,点 X 将是

                                  (max-min)
location = min + (current_step) * --------
                                    steps

我们要查找的位置。 min=1,max=4,在本例中,steps=2,因为我们想将跨度分为两个步骤:

step:   location:
0       1
1       2.5
2       4

1------------(2.5)-----------4

如果我们想要采取4个步骤:

step:   location:
0       1
1       1.75
2       2.5
3       3.25
4       4

1---(1.75)---(2.5)---(3.25)---4

依此类推。对于四步,对象移动每帧总距离的 25%。 10 步、10% 等等,令人作呕。

对于多个维度(当对象具有 2 维或 3 维轨迹时),只需将其独立应用于每个 X、Y、Z 轴。

这是线性插值。还有其他种类。一如既往,Google 可以为您提供帮助

其他应用包括纹理映射、抗锯齿、图像平滑和缩放等,当然还有游戏和图形之外的许多其他用途。

注意:很多框架已经提供了这一点。例如,在 XNA 中,它是 Matrix.Lerp< /a>.

Simply put: given two points A and B, find a point between them.

For example, if I want to move something along a line from a position x=1 to x=4 in one step:

1-----------------------4

The first step is at location 1, the second step is at location 4, so the object moves instantly from one location to the other. However, if I want the object to take a certain amount of time or number of frames to make the transition, I'll need to refine that by finding intermediate points that are evenly spaced.

If I want the object to take two steps (or frames) to move from 1 to 4,

1-----------X-----------4

I need to calculate what the new point (X) is so I can draw the object there at the appropriate time. In this case, the point X will be

                                  (max-min)
location = min + (current_step) * --------
                                    steps

location is what we're trying to find. min=1, max=4, and in this example steps=2 since we want to divide the span into two steps:

step:   location:
0       1
1       2.5
2       4

1------------(2.5)-----------4

If we want to take 4 steps:

step:   location:
0       1
1       1.75
2       2.5
3       3.25
4       4

1---(1.75)---(2.5)---(3.25)---4

And so forth. For four steps, the object moves 25% of the total distance per frame. For 10 steps, 10%, etc ad nauseum.

For multiple dimensions (when an object has a 2- or 3-dimensional trajectory), just apply this to each X,Y,Z axis independently.

This is linear interpolation. There are other kinds. As always, Google can help you out.

Other applications include texture mapping, anti-aliasing, image smoothing and scaling, etc., and of course many other uses outside of games and graphics.

Note: a lot of frameworks already provide this. In XNA, for instance, it's Matrix.Lerp.

梦断已成空 2024-10-18 06:35:03

插值是从一件事到另一件事的平滑调整。它用于动画中。

例如,如果一个对象位于位置 1,并且我们希望在六秒内将其移动到位置 2,则需要在两个端点之间缓慢插入其位置。插值还指对该路径上的位置的任何搜索。

Interpolation is the smooth adjustment from one thing to another. It is used in animation.

For example, if an object is at location 1, and we want to move it to location 2 over the course of six seconds, we need to slowly interpolate its location between the two endpoints. Interpolation also refers to any search for a location on that path.

回眸一遍 2024-10-18 06:35:03

插值是根据其他点“猜测”点。

例如,当您有点 (0,0) 和 (2,2) 时,您可能会“猜测”点 (1,1) 也属于该集合。

最简单的应用是从两点推导出一条线。

同样的事情也适用于 3 维或实际上是 n 维。

在 3D 图形中,它将用于

  • 动画、根据开始和结束坐标计算事物的位置、
  • 计算线条
  • 缩放
  • 、图形的梯度
    可能还有更多

Interpolation is the 'guessing' of points based on other points.

for example when you have the points (0,0) and (2,2) you might 'guess' that the point (1,1) also belongs to the set.

The simples application is to deduce a line from two points.

The same thing works in 3 or actually n-dimension.

In 3D graphics it will be used

  • for animations, to calculate the position of things based on start and end coordinations
  • calculating lines
  • gradients
  • scaling of graphics
    and probably many more
戈亓 2024-10-18 06:35:03

一般定义

插值(数学中)可以被视为从一个值到另一个值的过渡。插值通常使用 0 到 1 范围内的值,例如百分比。 0 是起始值,1 是结束值。插值的主要目的是找到给定值之间的值。

插值类型

各种程序中使用的插值类型有很多种,最常见的是线性插值。这种类型的插值是最简单、最直接的;它用于查找两点或数字之间的线段中的值。还有:三次插值二次插值双线性三线性等。有关更多信息,请访问此处: https://en.wikipedia.org/wiki/Interpolation

在 3D 图形中的应用

插值,尤其是线性、双线性和三线性,对于计算几何片段(几何体的纹理和视觉效果)、混合体积纹理、mip 映射(景深效果)非常重要纹理)和光照(如虚幻引擎的体积光照贴图)。插值的结果可能会有所不同,但有可能产生非常现实的结果。这是一个相当大的计算,特别是当插值在 3 维或更高维度(超空间)时。

插值示例

一维:

n1 = 1
n2 = 2

i = 0.5

n3 = (n1 - n1 * i) + n2 * i

///////////////////////////////////////

                  n3
├────────┼────────┼────────┼────────┤
1       1.25     1.5      1.75      2

///////////////////////////////////////

二维:

v1 = {1, 1}
v2 = {1.5, 2}

i = 0.5
d = √((v1.x - v2.x)^2 + (v1.y - v2.y)^2)

v3 = {v1.x + -d * i * ((v1.x - v2.x) / d),v1.y + -d * i * ((v1.y - v2.y) / d)} 

///////////////////////////////

  2 ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼ v2
1.5 ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─●
    ┼─┼─┼─┼─┼─┼─┼v3─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─●─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼v1─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ●─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
   1           1.5          2

///////////////////////////////

General Definition

Interpolation (in mathematics) can be regarded as a transition from one value to another. Interpolation usually uses a value in the 0 to 1 range like a percentage. 0 is the starting value and 1 is the end value. The main purpose of interpolation is to find values in between given values.

Types of Interpolation

There are many types of interpolation used in various programs, the most common being linear interpolation. This type of interpolation is the most simple and straight-forward; It is used to find values in a line segment between two points or numbers. There are also: cubic interpolation, quadratic interpolation, bilinear, trilinear, etc. For more information go here: https://en.wikipedia.org/wiki/Interpolation.

Application in 3D Graphics

Interpolation, especially linear, bilinear and trilinear, is important for computing fragments in geometry (the textures and visuals of the geometry), blending volumetric textures, mip-mapping (a depth of field effect on texture), and lighting (like unreal engine's volumetric lightmaps). The results of the interpolation may vary, but it could potentially yield very realistic results. It is a rather large computation, especially when the interpolation is in 3-dimensions or above (hyperspace).

Example of Interpolation

In 1 Dimension:

n1 = 1
n2 = 2

i = 0.5

n3 = (n1 - n1 * i) + n2 * i

///////////////////////////////////////

                  n3
├────────┼────────┼────────┼────────┤
1       1.25     1.5      1.75      2

///////////////////////////////////////

In 2 Dimensions:

v1 = {1, 1}
v2 = {1.5, 2}

i = 0.5
d = √((v1.x - v2.x)^2 + (v1.y - v2.y)^2)

v3 = {v1.x + -d * i * ((v1.x - v2.x) / d),v1.y + -d * i * ((v1.y - v2.y) / d)} 

///////////////////////////////

  2 ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼ v2
1.5 ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─●
    ┼─┼─┼─┼─┼─┼─┼v3─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─●─┼─┼─┼─┼─┼─┼
    ┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ┼v1─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
    ●─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼
   1           1.5          2

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