溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Interpolation, Lines(插值、線性插值)

發(fā)布時間:2020-06-25 18:06:12 來源:網(wǎng)絡 閱讀:521 作者:萌谷王 欄目:游戲開發(fā)

周一到周五,每天一篇,北京時間早上7點準時更新~

Interpolation is a term used to describe the process of finding values that lie between a set of known points(插值的意思是從一群已知的點的集合中找出某一個值的過程). Consider the equation of the line passing through points A and B(想象一下一個連接A點到B點的直線):
Interpolation, Lines(插值、線性插值)
where P is any point on the line and is the vector from A to B(這里P表示的時候AB之間任意一點):

Interpolation, Lines(插值、線性插值)
We can therefore write this equation as(因此我們可以把這個等式寫成:)
Interpolation, Lines(插值、線性插值)
It is easy to see that when t is 0, P is equal to A; and when t is 1, P is equal to A + B ? A, which is simply B. Such a line is shown in Figure 4.13(當t是0的時候,p就相當于A點,當t的值是1的時候,p就相當于B點,如圖4.13所示)

Interpolation, Lines(插值、線性插值)
If t lies between 0.0 and 1.0, then P will end up somewhere between A and B(如果t的值在0到1之間,那么p就落在A與B之間的某處). Values of t outside this range will push P off the ends of the line. You should be able to see that by smoothly varying t, we can move point P from A to B and back. This is known as linear interpolation(如果t的值超出了這個范圍,那么p則也會超出AB的范圍??梢钥吹?,當讓t從0到1慢慢變化時,p會從A移動到B,這叫線性插值). The values of A and B (and therefore P) can have any number of dimensions(A和B的值可以有任意多個維度). For example, they could be scalar values; two-dimensional values such as points on a graph; three-dimensional values such as coordinates in 3D space, colors, and so on(比如這里A和B的值可以是一個標量,可以是二維的點,可以是三位的點、顏色等等); or even higher-dimension quantities such as matrices, arrays, or even whole images(甚至是更高維度的的矩陣、數(shù)組亦或是整個圖像). In many cases, linear interpolation doesn’t make much sense (for example, linearly interpolating between two matrices generally doesn’t produce a meaningful result), but angles, positions, and other coordinates can normally be interpolated safely(在很多情況下,線性插值不怎么好使,但是在角度、位置以及其他坐標方面,一般來說這就夠了). Linear interpolation is such a common operation in graphics that GLSL includes a builtin function specifically for this purpose, mix:(在GLSL里,能用來進行線性插值的內置函數(shù)是mix)

vec4 mix(vec4 A, vec4 B, float t);
The mix function comes in several versions taking different dimensionalities of vectors or scalars as the A and B inputs and taking scalars or matching vectors for t(該函數(shù)接收A、B兩個數(shù)據(jù),然后變量t,來對數(shù)據(jù)進行線性插值).

本日的翻譯就到這里,明天見,拜拜~~

第一時間獲取最新橋段,請關注東漢書院以及圖形之心公眾號

東漢書院,等你來玩哦

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI