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.
变换是取点、矢量或颜色等实体并以某种方式转换它们的操作。
A linear transform is one that preserves vector addition and scalar multiplication.
线性变换是保留向量加法和标量乘法的变换。
Scaling and rotation transforms, in fact all linear transforms for three-element vectors, can be represented using a 3 × 3 matrix.
缩放和旋转变换,实际上是三元素向量的所有线性变换,可以用一个3 × 3矩阵来表示。

image.png

To prove that this is linear, the two conditions (Equations 4.1 and 4.2) need to be fulfilled.
为了证明这是线性的,需要满足两个条件(等式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.
仿射变换:组合线性变换和平移可以使用仿射变换来完成,通常存储为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.
所有平移、旋转、缩放、反射和剪切矩阵都是仿射的。仿射矩阵的主要特点是它保留了直线的平行性,但不一定保留长度和角度。
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.
本章将从最基本的仿射变换开始。这部分可以看作是简单转换的“参考手册”。然后描述更专业的矩阵,接着讨论和描述四元数,一个强大的变换工具。然后是顶点混合和变形,这是表达网格动画的两种简单而有效的方法。最后,描述了投影矩阵。表4.1总结了这些变换中的大多数、它们的符号、函数和属性,其中正交矩阵的逆矩阵是转置矩阵。
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.
知道矩阵在这样的函数调用之后会做什么是一个开始,但是了解矩阵本身的属性会让你走得更远。


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).
像平移矩阵一样,它是刚体变换,即它保留变换点之间的距离,并保留惯用手(即它从不导致左右交换边)。
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.
方向矩阵是与相机视图或对象相关联的旋转矩阵,其定义了其在空间中的方向,即其向上和向前的方向。
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),我们将其参数化为v = (vx,vy) = (r cos θ,r sin θ)。如果我们将向量旋转φ弧度(逆时针),那么我们将得到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.
在三维空间中,常用的旋转矩阵是Rx(φ)、Ry(φ)和Rz(φ),它们分别围绕x轴、y轴和z轴旋转实体φ弧度。


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 φ.
对于绕任意轴旋转φ弧度的每3×3旋转矩阵R,迹线(矩阵中对角元素的和)是不依赖于轴的常数,计算公式为[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.
所有旋转矩阵的行列式都是1,并且是正交的。这也适用于任何数量的转换的连接。还有一种方法可以得到逆:
image.png

,即绕同一轴反方向旋转。
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缩放实体。
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,缩放操作称为均匀,否则称为不均匀。有时使用各向同性和各向异性的缩放来代替均匀和不均匀。相反的是
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的一个或三个分量的负值给出了一种反射矩阵,也称为镜像矩阵。
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.
如果只有两个比例因子为-1,那么我们将旋转π弧度。应当注意,与反射矩阵连接的旋转矩阵也是反射矩阵。


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.
例如,这些可以在游戏中用来扭曲整个场景以产生迷幻效果,或者扭曲模型的外观。
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.
有六个基本的剪切矩阵,它们被表示为Hxy、Hxz、Hyx、Hyz、Hzx和Hzy。第一个下标用来表示剪切矩阵正在改变哪个坐标,而第二个下标表示进行剪切的坐标。
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:
观察下标可以用来求参数s在下面矩阵中的位置;x(其数值索引为0)标识第0行,z(其数值索引为2)标识第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)的倒数(相对于jth坐标剪切ith坐标,其中i 不等于 j)是通过沿相反方向剪切产生的


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
然而,这里两个下标都用来表示这些坐标将被第三个坐标剪切。这两种不同类型的描述之间的联系是H ' ij(s,t) = Hik(s)Hjk(t),其中k用作第三个坐标的索引。正确的矩阵使用是一个品味的问题。最后,需要注意的是,由于任意剪切矩阵的行列式|H| = 1,这是一个保体积变换
4.1.5 Concatenation of Transforms

65

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,033评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,725评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,473评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,846评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,848评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,691评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,053评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,700评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,856评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,676评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,787评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,430评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,034评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,990评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,218评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,174评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,526评论 2 343

推荐阅读更多精彩内容