Real-Time Rendering——4.Transforms

Chapter 4 Transforms

A transform is an operation that takes entities such as points, vectors, or colors and converts them in some way.
變換是取點(diǎn)逼纸、矢量或顏色等實(shí)體并以某種方式轉(zhuǎn)換它們的操作遏弱。
A linear transform is one that preserves vector addition and scalar multiplication.
線性變換是保留向量加法和標(biāo)量乘法的變換授舟。
Scaling and rotation transforms, in fact all linear transforms for three-element vectors, can be represented using a 3 × 3 matrix.
縮放和旋轉(zhuǎn)變換,實(shí)際上是三元素向量的所有線性變換缀匕,可以用一個(gè)3 × 3矩陣來表示纳决。

image.png

To prove that this is linear, the two conditions (Equations 4.1 and 4.2) need to be fulfilled.
為了證明這是線性的,需要滿足兩個(gè)條件(等式4.1和4.2)弦追。
affine transform:Combining linear transforms and translations can be done using an affine transform, typically stored as a 4 × 4 matrix.
仿射變換:組合線性變換和平移可以使用仿射變換來完成岳链,通常存儲(chǔ)為4 × 4矩陣花竞。

affine matrix:All translation, rotation, scaling, reflection, and shearing matrices are affine. The main characteristic of an affine matrix is that it preserves the parallelism of lines, but not necessarily lengths and angles.
所有平移劲件、旋轉(zhuǎn)、縮放约急、反射和剪切矩陣都是仿射的零远。仿射矩陣的主要特點(diǎn)是它保留了直線的平行性,但不一定保留長(zhǎng)度和角度厌蔽。
This chapter will begin with the most essential, basic affine transforms. This section can be seen as a “reference manual” for simple transforms. More specialized matrices are then described, followed by a discussion and description of quaternions, a powerful transform tool. Then follows vertex blending and morphing, which are two simple but effective ways of expressing animations of meshes. Finally, projection matrices are described. Most of these transforms, their notations, functions, and properties are summarized in Table 4.1, where an orthogonal matrix is one whose inverse is the transpose.
本章將從最基本的仿射變換開始牵辣。這部分可以看作是簡(jiǎn)單轉(zhuǎn)換的“參考手冊(cè)”。然后描述更專業(yè)的矩陣奴饮,接著討論和描述四元數(shù)纬向,一個(gè)強(qiáng)大的變換工具择浊。然后是頂點(diǎn)混合和變形,這是表達(dá)網(wǎng)格動(dòng)畫的兩種簡(jiǎn)單而有效的方法逾条。最后琢岩,描述了投影矩陣。表4.1總結(jié)了這些變換中的大多數(shù)师脂、它們的符號(hào)担孔、函數(shù)和屬性,其中正交矩陣的逆矩陣是轉(zhuǎn)置矩陣吃警。
Knowing what the matrix does after such a function call is a start, but understanding the properties of the matrix itself will take you further.
知道矩陣在這樣的函數(shù)調(diào)用之后會(huì)做什么是一個(gè)開始糕篇,但是了解矩陣本身的屬性會(huì)讓你走得更遠(yuǎn)。


image.png
4.1.1 Translation

A change from one location to another is represented by a translation matrix, T. This matrix translates an entity by a vector t = (tx, ty, tz).


image.png
4.1.2 Rotation

Like a translation matrix, it is a rigid-body transform, i.e., it preserves the distances between points transformed, and preserves handedness (i.e., it never causes left and right to swap sides).
像平移矩陣一樣酌心,它是剛體變換拌消,即它保留變換點(diǎn)之間的距離,并保留慣用手(即它從不導(dǎo)致左右交換邊)谒府。
An orientation matrix is a rotation matrix associated with a camera view or object that defines its orientation in space, i.e., its directions for up and forward.
方向矩陣是與相機(jī)視圖或?qū)ο笙嚓P(guān)聯(lián)的旋轉(zhuǎn)矩陣拼坎,其定義了其在空間中的方向,即其向上和向前的方向完疫。
vector, v = (vx, vy), which we parameterize as v = (vx, vy) = (r cos θ, r sin θ). If we were to rotate that vector by φ radians (counterclockwise), then we would get u = (r cos(θ + φ), r sin(θ + φ)).
向量v = (vx泰鸡,vy),我們將其參數(shù)化為v = (vx壳鹤,vy) = (r cos θ盛龄,r sin θ)。如果我們將向量旋轉(zhuǎn)φ弧度(逆時(shí)針)芳誓,那么我們將得到u = (r cos(θ + φ)余舶,r sin(θ + φ))。


image.png

In three dimensions, commonly used rotation matrices are Rx(φ), Ry(φ), and Rz(φ), which rotate an entity φ radians around the x-, y-, and z-axes, respectively.
在三維空間中锹淌,常用的旋轉(zhuǎn)矩陣是Rx(φ)匿值、Ry(φ)和Rz(φ),它們分別圍繞x軸赂摆、y軸和z軸旋轉(zhuǎn)實(shí)體φ弧度挟憔。


image.png

For every 3×3 rotation matrix, R, that rotates φ radians around any axis, the trace (which is the sum of the diagonal elements in a matrix) is constant independent of the axis, and is computed as [997]: tr(R) = 1 + 2 cos φ.
對(duì)于繞任意軸旋轉(zhuǎn)φ弧度的每3×3旋轉(zhuǎn)矩陣R,跡線(矩陣中對(duì)角元素的和)是不依賴于軸的常數(shù)烟号,計(jì)算公式為[997]: tr(R) = 1 + 2 cos φ绊谭。
All rotation matrices have a determinant of one and are orthogonal. This also holds for concatenations of any number of these transforms. There is another way to obtain the inverse:
image.png

, i.e., rotate in the opposite direction around the same axis.
所有旋轉(zhuǎn)矩陣的行列式都是1,并且是正交的汪拥。這也適用于任何數(shù)量的轉(zhuǎn)換的連接达传。還有一種方法可以得到逆:
image.png

,即繞同一軸反方向旋轉(zhuǎn)。
4.1.3 Scaling

A scaling matrix, S(s) = S(sx, sy, sz), scales an entity with factors sx, sy, and sz along the x-, y-, and z-directions, respectively.
縮放矩陣S(s) = S(sx宪赶,sy宗弯,sz)分別沿x、y和z方向用因子sx搂妻、sy和sz縮放實(shí)體罕伯。
Setting any of the components of s to 1 naturally avoids a change in scaling in that direction.


image.png

The scaling operation is called uniform if sx = sy = sz and nonuniform otherwise. Sometimes the terms isotropic and anisotropic scaling are used instead of uniform and nonuniform. The inverse is
image.png

如果sx = sy = sz,縮放操作稱為均勻叽讳,否則稱為不均勻追他。有時(shí)使用各向同性和各向異性的縮放來代替均勻和不均勻。相反的是
image.png

A negative value on one or three of the components of s gives a type of reflection matrix, also called a mirror matrix.
s的一個(gè)或三個(gè)分量的負(fù)值給出了一種反射矩陣岛蚤,也稱為鏡像矩陣邑狸。
If only two scale factors are ?1, then we will rotate π radians. It should be noted that a rotation matrix concatenated with a reflection matrix is also a reflection matrix.
如果只有兩個(gè)比例因子為-1,那么我們將旋轉(zhuǎn)π弧度涤妒。應(yīng)當(dāng)注意单雾,與反射矩陣連接的旋轉(zhuǎn)矩陣也是反射矩陣。


image.png
4.1.4 Shearing

剪切
These can, for example, be used in games to distort an entire scene to create a psychedelic effect or otherwise warp a model’s appearance.
例如她紫,這些可以在游戲中用來扭曲整個(gè)場(chǎng)景以產(chǎn)生迷幻效果硅堆,或者扭曲模型的外觀。
There are six basic shearing matrices, and they are denoted Hxy(s), Hxz(s), Hyx(s), Hyz(s), Hzx(s), and Hzy(s). The first subscript is used to denote which coordinate is being changed by the shear matrix,while the second subscript indicates the coordinate which does the shearing.
有六個(gè)基本的剪切矩陣贿讹,它們被表示為Hxy渐逃、Hxz、Hyx民褂、Hyz茄菊、Hzx和Hzy。第一個(gè)下標(biāo)用來表示剪切矩陣正在改變哪個(gè)坐標(biāo)赊堪,而第二個(gè)下標(biāo)表示進(jìn)行剪切的坐標(biāo)面殖。
Observe that the subscript can be used to find the position of the parameter s in the matrix below; the x (whose numeric index is 0) identifies row zero, and the z (whose numeric index is 2) identifies column two, and so the s is located there:
觀察下標(biāo)可以用來求參數(shù)s在下面矩陣中的位置;x(其數(shù)值索引為0)標(biāo)識(shí)第0行哭廉,z(其數(shù)值索引為2)標(biāo)識(shí)第2列脊僚,因此s位于此處:


image.png

The inverse of Hij(s) (shearing the ith coordinate with respect to the jth coordinate, where i 不等于 j), is generated by shearing in the opposite direction
Hij(s)的倒數(shù)(相對(duì)于jth坐標(biāo)剪切ith坐標(biāo),其中i 不等于 j)是通過沿相反方向剪切產(chǎn)生的


image.png

You can also use a slightly different kind of shear matrix:
您也可以使用稍微不同的剪切矩陣:


image.png

Here, however, both subscripts are used to denote that these coordinates are to be sheared by the third coordinate. The connection between these two different kinds of descriptions is H′ij(s, t) = Hik(s)Hjk(t), where k is used as an index to the third coordinate. The right matrix to use is a matter of taste. Finally, it should be noted that since the determinant of any shear matrix |H| = 1, this is a volume-preserving transformation
然而遵绰,這里兩個(gè)下標(biāo)都用來表示這些坐標(biāo)將被第三個(gè)坐標(biāo)剪切辽幌。這兩種不同類型的描述之間的聯(lián)系是H ' ij(s,t) = Hik(s)Hjk(t)街立,其中k用作第三個(gè)坐標(biāo)的索引舶衬。正確的矩陣使用是一個(gè)品味的問題埠通。最后赎离,需要注意的是,由于任意剪切矩陣的行列式|H| = 1端辱,這是一個(gè)保體積變換
4.1.5 Concatenation of Transforms

65

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末梁剔,一起剝皮案震驚了整個(gè)濱河市虽画,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌荣病,老刑警劉巖码撰,帶你破解...
    沈念sama閱讀 221,820評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異个盆,居然都是意外死亡脖岛,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門颊亮,熙熙樓的掌柜王于貴愁眉苦臉地迎上來柴梆,“玉大人,你說我怎么就攤上這事终惑∩茉冢” “怎么了?”我有些...
    開封第一講書人閱讀 168,324評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵雹有,是天一觀的道長(zhǎng)偿渡。 經(jīng)常有香客問我,道長(zhǎng)霸奕,這世上最難降的妖魔是什么溜宽? 我笑而不...
    開封第一講書人閱讀 59,714評(píng)論 1 297
  • 正文 為了忘掉前任,我火速辦了婚禮质帅,結(jié)果婚禮上坑质,老公的妹妹穿的比我還像新娘。我一直安慰自己临梗,他們只是感情好涡扼,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評(píng)論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著盟庞,像睡著了一般吃沪。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上什猖,一...
    開封第一講書人閱讀 52,328評(píng)論 1 310
  • 那天票彪,我揣著相機(jī)與錄音,去河邊找鬼不狮。 笑死降铸,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的摇零。 我是一名探鬼主播推掸,決...
    沈念sama閱讀 40,897評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了谅畅?” 一聲冷哼從身側(cè)響起登渣,我...
    開封第一講書人閱讀 39,804評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎毡泻,沒想到半個(gè)月后胜茧,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,345評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡仇味,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評(píng)論 3 340
  • 正文 我和宋清朗相戀三年呻顽,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片丹墨。...
    茶點(diǎn)故事閱讀 40,561評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡芬位,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出带到,到底是詐尸還是另有隱情昧碉,我是刑警寧澤,帶...
    沈念sama閱讀 36,238評(píng)論 5 350
  • 正文 年R本政府宣布揽惹,位于F島的核電站被饿,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏搪搏。R本人自食惡果不足惜狭握,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評(píng)論 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望疯溺。 院中可真熱鬧论颅,春花似錦、人聲如沸囱嫩。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)墨闲。三九已至今妄,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間鸳碧,已是汗流浹背盾鳞。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留瞻离,地道東北人腾仅。 一個(gè)月前我還...
    沈念sama閱讀 48,983評(píng)論 3 376
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像套利,于是被迫代替她去往敵國(guó)和親推励。 傳聞我的和親對(duì)象是個(gè)殘疾皇子鹤耍,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容