週一到週五,天天一篇,北京時間早上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點的直線):
where P is any point on the line and is the vector from A to B(這裏P表示的時候AB之間任意一點):ide
We can therefore write this equation as(所以咱們能夠把這個等式寫成:)
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所示)函數
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(甚至是更高維度的的矩陣、數組亦或是整個圖像). 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裏,能用來進行線性插值的內置函數是mix)ui
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(該函數接收A、B兩個數據,而後變量t,來對數據進行線性插值).this
本日的翻譯就到這裏,明天見,拜拜~~spa
第一時間獲取最新橋段,請關注東漢書院以及圖形之心公衆號scala
東漢書院,等你來玩哦翻譯