Chapter 2 (Matrix Algebra): Applications to computer graphics (计算机图形学中的应用)

本文为《Linear algebra and its applications》的读书笔记

Linear transformation in computer graphics

  • This section examines some of the basic mathematics used to manipulate and display graphical images such as a wire-frame (线性轮廓) model of an airplane. Such an image (or picture) consists of a number of points, connecting lines or curves, and information about how to fill in closed regions bounded by the lines and curves.
    • Often, curved lines are approximated by short straight-line segments, and a figure is defined mathematically by a list of points.
    • The main reason graphical objects are described by collections of straight-line segments is that the standard transformations in computer graphics map line segments onto other line segments. Once the vertices that describe an object have been transformed, their images can be connected with the appropriate straight lines to produce the complete image of the original object.

  • Among the simplest 2D graphics symbols are letters used for labels on the screen. Some letters are stored as wire-frame objects (线框对象); others that have curved portions are stored with additional mathematical formulas for the curves.

EXAMPLE 1

  • The capital letter N N N in Figure 1 is determined by eight points, or vertices. The coordinates of the points can be stored in a data matrix, D D D.
    在这里插入图片描述In addition to D D D, it is necessary to specify which vertices are connected by lines, but we omit this detail.

EXAMPLE 2

Given A = [ 1 . 25 0 1 ] A =\begin{bmatrix} 1&.25\\0&1 \end{bmatrix} A=[10.251], describe the effect of the shear transformation x ↦ A x \boldsymbol x \mapsto A\boldsymbol x xAx on the letter N N N in Example 1.

SOLUTION

  • By definition of matrix multiplication, the columns of the product A D AD AD contain the images of the vertices of the letter N N N.
    在这里插入图片描述

EXAMPLE 3

Compute the matrix of the transformation that performs a shear transformation, as in Example 2, and then scales all x x x-coordinates by a factor of .75.

SOLUTION

  • The matrix that multiplies the x x x-coordinate of a point by .75 is
    S = [ . 75 0 0 1 ] S =\begin{bmatrix} .75&0\\0&1 \end{bmatrix} S=[.75001]So the matrix of the composite transformation is
    S A = [ . 75 0 0 1 ] [ 1 . 25 0 1 ] = [ . 75 . 1875 0 1 ] SA =\begin{bmatrix} .75&0\\0&1 \end{bmatrix}\begin{bmatrix} 1&.25\\0&1 \end{bmatrix}=\begin{bmatrix} .75&.1875\\0&1 \end{bmatrix} SA=[.75001][10.251]=[.750.18751]

Homogeneous Coordinates

齐次坐标

  • The mathematics of computer graphics is intimately connected with matrix multiplication. Unfortunately, translating (平移) an object on a screen does not correspond directly to matrix multiplication because translation is not a linear transformation.
  • The standard way to avoid this difficulty is to introduce what are called h o m o g e n e o u s homogeneous homogeneous c o o r d i n a t e s coordinates coordinates.

  • Each point ( x , y ) (x, y) (x,y) in R 2 \mathbb R^2 R2 can be identified with the point ( x , y , 1 ) (x, y, 1) (x,y,1) on the plane in R 3 \mathbb R^3 R3 that lies one unit above the x y xy xy-plane. We say that ( x , y ) (x, y) (x,y) has h o m o g e n e o u s homogeneous homogeneous c o o r d i n a t e s coordinates coordinates ( x , y , 1 ) (x, y, 1) (x,y,1).
  • Homogeneous coordinates for points are not added or multiplied by scalars (点的齐次坐标不能相加,也不能与标量相乘), but they can be transformed via multiplication by 3 × 3 3 \times 3 3×3 matrices.

EXAMPLE 4

  • A translation of the form ( x , y ) ↦ ( x + h , y + k ) (x,y)\mapsto (x+h,y+k) (x,y)(x+h,y+k) is written in homogeneous coordinates as ( x , y , 1 ) ↦ ( x + h , y + k , 1 ) (x,y,1)\mapsto (x+h,y+k,1) (x,y,1)(x+h,y+k,1). This transformation can be computed via matrix multiplication:
    在这里插入图片描述

EXAMPLE 5

  • Any linear transformation on R 2 \mathbb R^2 R2 is represented with respect to homogeneous coordinates by a partitioned matrix of the form [ A 0 0 1 ] \begin{bmatrix} A&0\\0&1 \end{bmatrix} [A001], where A A A is a 2 × 2 2 \times 2 2×2 matrix. Typical examples are
    在这里插入图片描述

可以用分块矩阵加以证明:若某个线性变换对应的标准矩阵为 A A A,则在齐次坐标中对应的的标准矩阵为 [ A 0 0 1 ] \begin{bmatrix} A&0\\0&1 \end{bmatrix} [A001]

Composite Transformations

复合变换

EXAMPLE 6

Find the 3 × 3 3 \times 3 3×3 matrix that corresponds to the composite transformation of a scaling by .3, a rotation of 90 ° \degree ° about the origin, and finally a translation that adds ( − . 5 , 2 ) (-.5,2) (.5,2) to each point of a figure.

SOLUTION

  • If ϕ = π / 2 \phi=\pi/2 ϕ=π/2, then s i n ϕ = 1 sin\phi= 1 sinϕ=1 and c o s ϕ = 0 cos \phi= 0 cosϕ=0. From Examples 4 and 5, we have
    在这里插入图片描述

EXAMPLE 7

  • Rotation of a figure about a point p \boldsymbol p p in R 2 \mathbb R^2 R2 is accomplished by first translating the figure by − p -\boldsymbol p p, rotating about the origin, and then translating back by p \boldsymbol p p. See Figure 7.
    在这里插入图片描述

EXAMPLE 8

A 2 × 200 2 \times 200 2×200 data matrix D D D contains the coordinates of 200 points. Compute the number of multiplications required to calculate A ( B D ) A(BD) A(BD) and ( A B ) D (AB) D (AB)D.

SOLUTION

  • 可以看出, ( A B ) D (AB) D (AB)D 的计算量几乎只有 A ( B D ) A(BD) A(BD) 的一半。因此在做复合变换时,应该先计算出复合变换对应的变换矩阵,再进行坐标变换

Homogeneous 3D Coordinates

齐次三维坐标

  • By analogy with the 2D case, we say that ( x , y , z , 1 ) (x,y,z, 1) (x,y,z,1) are homogeneous coordinates for the point ( x , y , z ) (x,y,z) (x,y,z) in R 3 \mathbb R^3 R3. In general, ( X , Y , Z , H ) (X,Y,Z, H) (X,Y,Z,H) are homogeneous coordinates for ( x , y , z ) (x,y,z) (x,y,z) if H ≠ 0 H \neq 0 H=0 and
    在这里插入图片描述Each nonzero scalar multiple of ( x , y , z , 1 ) (x,y,z, 1) (x,y,z,1) gives a set of homogeneous coordinates for ( x , y , z ) (x,y,z) (x,y,z).

  • The next example illustrates the transformations used in molecular modeling to move a drug into a protein molecule.

EXAMPLE 9

Give 4 × 4 4 \times 4 4×4 matrices for the following transformations:

  • a. Rotation about the y y y-axis through an angle of 30 ° \degree °. (By convention, a positive angle is the counterclockwise direction when looking toward the origin from the positive half of the axis of rotation—in this case, the y y y-axis.)
  • b. Translation by the vector p = ( − 6 , 4 , 5 ) \boldsymbol p =(-6, 4, 5) p=(6,4,5).

SOLUTION

  • a. First, construct the 3 × 3 3 \times 3 3×3 matrix for the rotation. The vector e 1 \boldsymbol e_1 e1 rotates down toward the negative z z z-axis, stopping at ( c o s 30 ° , 0 , − s i n 30 ° ) = ( 3 / 2 , 0 , − 0.5 ) (cos 30\degree, 0,-sin 30\degree)=(\sqrt3/2, 0,-0.5) (cos30°,0,sin30°)=(3 /2,0,0.5). The vector e 2 \boldsymbol e_2 e2 on the y y y-axis does not move, but e 3 \boldsymbol e_3 e3 on the z z z-axis rotates down toward the positive x x x-axis, stopping at ( s i n 30 ° , 0 , c o s 30 ° ) = ( 0.5 , 0 , 3 / 2 ) (sin 30\degree, 0,cos 30\degree)=(0.5, 0,\sqrt3/2) (sin30°,0,cos30°)=(0.5,0,3 /2). See Figure 5. The standard matrix for z z z this rotation is
    在这里插入图片描述So the rotation matrix for homogeneous coordinates is
    在这里插入图片描述
  • b. We want ( x , y , z , 1 ) (x, y, z, 1) (x,y,z,1) to map to ( x − 6 , y + 4 , z + 5 , 1 ) (x-6, y+4, z+5, 1) (x6,y+4,z+5,1). The matrix that does this is
    在这里插入图片描述

Perspective Projections

透视投影

  • A three-dimensional object is represented on the two-dimensional computer screen by projecting the object onto a v i e w i n g viewing viewing p l a n e plane plane (可视平台). (We ignore other important steps, such as selecting the portion of the viewing plane to display on the screen.)
    • For simplicity, let the x y xy xy-plane represent the computer screen, and imagine that the eye of a viewer is along the positive z z z-axis, at a point ( 0 , 0 , d ) (0, 0, d) (0,0,d). A p e r s p e c t i v e perspective perspective p r o j e c t i o n projection projection maps each point ( x , y , z ) (x, y, z) (x,y,z) onto an image point ( x ∗ , y ∗ , 0 ) (x*, y*, 0) (x,y,0) so that the two points and the eye position, called the c e n t e r center center o f of of p r o j e c t i o n projection projection, are on a line. See Figure 6(a).
      在这里插入图片描述Similar triangles (相似三角形) show that
      在这里插入图片描述Similarly,
      在这里插入图片描述Using homogeneous coordinates, we can represent the perspective projection by a matrix, say, P P P. We want ( x , y , z , 1 ) (x, y,z , 1) (x,y,z,1) to map into ( x 1 − z / d , y 1 − z / d , 0 , 1 ) (\frac{x}{1-z/d},\frac{y}{1-z/d},0,1) (1z/dx,1z/dy,0,1). Scaling these coordinates by 1 − z / d 1-z/d 1z/d, we can also use ( x , y , 0 , 1 − z / d ) (x, y, 0, 1-z/d) (x,y,0,1z/d) as homogeneous coordinates for the image. Now it is easy to display P P P. In fact,
      在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值