of {a,b,c} into the vector of {d,e,f }.The vector defined in terms of {a,b,c} is first transformed into the vectordefined in terms of the standard basis {e1,e2,e3}, and then transformedi
Trang 1of {a,b,c} into the vector of {d,e,f }.
The vector defined in terms of {a,b,c} is first transformed into the vectordefined in terms of the standard basis {e1,e2,e3}, and then transformedinto the vector defined in terms of {d,e,f } The first transform is im-plemented by the following basis-change matrix:
Trang 2When they are combined, we obtain the following:
3 Let us define a matrix for scaling along 3 orthonormal vectors, a, b, and
c, which are not identical to the standard basis vectors e1, e2, and e3.The scaling factors are sa, sb, and sc along a, b, and c, respectively It
is also observed that a × b = c where × denotes the cross product Thescaling matrix is a combination of three 3×3 matrices Compute thethree matrices
Scaling a vector (x, y, z) along the non-standard orthonormal basis {a,b,c}
is implemented by concatenating three transforms: (1) basis change from{e1,e2,e3} to {a,b,c}, (2) scaling, and (3) basis change from {a,b,c} to{e1,e2,e3} The matrices are concatenated as follows:
0 0 0 1
(b) Compute the rotation
EYE is located at −z axis, and looks at AT that is the origin.Therefore, n is (0,0,−1) UP is (0,1,0), and is already orthogonal
to n Applying the right-hand rule to UP and n finds that u is
Trang 3(−1, 0, 0) Applying the right-hand rule to n and u finds that v is(0, 1, 0) The rotation matrix is then as follows:
In OpenGL, the xy-ranges are the same as those in this book, [−1,1].Therefore Equation (2.33) is valid, and we have the following equation:
z0= −m3−m4
zThe difference is that the z -coordinates −f and −n are mapped to −1and 1 (not 0), respectively, by the OpenGL projection transform Inother words, we have two known pairs of (z,z0): (−f ,−1) and (−n,1).Putting them into the above equation, we obtain the following:
Trang 4Chapter 3
1 A viewport’s corners are located at (10,20,1) and (100,200,2)
(a) Compute the reflection matrix for the viewport transform
(b) Compute the scaling matrix
The width of the viewport is 90, the height is 180, and the depth
is 1 Therefore, we have the following scaling matrix:
(c) Compute the translation matrix
The center of the viewport’s front face is (55,110,1) Therefore, wehave the following translation matrix:
Trang 5The vertex processing and fragment processing stages (in rounded boxes) are programmable, and the rasterization and output merging stages (in rectangles) are hard-wired.
Trang 6Transforms and spaces in the vertex processing stage Sections 2.1, 2.2, and 2.4 present the three transforms in order.
Trang 7A vector p is rotated by θ to define a new vector p′.
Trang 8The sphere and teapot are defined in their own object spaces and are assembled into a single space, the world space.
Trang 9The teapot is rotated about the y-axis by 90° and is then translated along the x-axis by seven units The teapot’s mouth is rotated from (0,2,3)
to (3,2,0) and then translated to (10,2,0) The combined matrix of the rotation and the translation instantly transforms (0,2,3) to (10,2,0)
Trang 10The teapot shown in the middle is rotated CCW to define the one on the left If rotated CW, we have the result on the right.
Trang 11The teapot is successively rotated using the Euler angles and acquires an orientation.
Trang 12Vertex transform vs normal transform (modified from [8]) (a) The vertices and normal are transformed by a single matrix M The formed normal is not orthogonal to the transformed triangle (b) Whereas the vertices are transformed by M, the normal is transformed by (M−1)T After the transforms, the normal remains orthogonal to the triangle.
Trang 13trans-Before transforms, n is orthogonal to the triangle 〈 p,q,r〉 Whereas 〈 p,q,r〉 is transformed by M, n is transformed by (M−1)T Then, the
trans-formed normal n′ remains orthogonal to the transtrans-formed triangle 〈 p′,q′,r′〉.
Trang 14Given EYE, AT, and UP, the camera space is defined Its origin is EYE, and the basis is {u,v,n} In terms of the camera space, the camera
is located at the origin and points in the −n direction, i.e., the view direction is −n.
Trang 15The camera space {EYE, u,v,n} is superimposed onto the world space {O,e1,e2,e3} It is done by a translation followed by a rotation The two transforms are combined to produce the view transform, which converts the world-space objects into the camera space.
Trang 16The first is the standard basis for R2 The second is a valid basis for R2, but is neither standard nor orthonormal The third is not the standard but an orthonormal basis.
Trang 17The vertex position and normal are denoted by p and n, respectively Once the light source and camera positions are defined, l, r, and v are
obtained Then, lighting can be computed per vertex
Trang 18The pyramid-like volume is named view frustum The polygons outside the view frustum (illustrated in red) are considered invisible.
Trang 19If a polygon intersects the view frustum’s boundary, the part of the polygon outside the view frustum is discarded.
Trang 20Projection transform (a) The view frustum is deformed into a cuboid The deformation named projection transform is in fact applied to the
objects in the scene Observe how the teapot is deformed (b) Cross-section views show how the perspective projection effect (called
fore-shortening) is achieved through projection transform
Trang 21The z-coordinates are negated for switching from the right-handed clip space to the left-handed clip space Z-negation is equivalent to the
z-axis inversion
Trang 22The last transform in the vertex processing stage, M proj, converts the right-handed camera-space objects into the left-handed clip space This illustrates the combination of Fig 2.16-(a) and Fig 2.17.
Trang 23Computing projection matrix (a) Normalized coordinate y′ is computed (b) The aspect ratio can be defined in terms of fovx and fovy.
Trang 24The projection transform converts the z-range [−f,−n] to [−1,0].
Trang 25The vertex processing and fragment processing stages (in rounded boxes) are programmable, and the rasterization and output merging stages (in rectangles) are hard-wired.
Trang 26Transforms and spaces in the vertex processing stage Sections 2.1, 2.2, and 2.4 present the three transforms in order.
Trang 27A vector p is rotated by θ to define a new vector p′.
Trang 28The sphere and teapot are defined in their own object spaces and are assembled into a single space, the world space.
Trang 29The teapot is rotated about the y-axis by 90° and is then translated along the x-axis by seven units The teapot’s mouth is rotated from (0,2,3)
to (3,2,0) and then translated to (10,2,0) The combined matrix of the rotation and the translation instantly transforms (0,2,3) to (10,2,0)
Trang 30The teapot shown in the middle is rotated CCW to define the one on the left If rotated CW, we have the result on the right.
Trang 31The teapot is successively rotated using the Euler angles and acquires an orientation.
Trang 32Vertex transform vs normal transform (modified from [8]) (a) The vertices and normal are transformed by a single matrix M The formed normal is not orthogonal to the transformed triangle (b) Whereas the vertices are transformed by M, the normal is transformed by (M−1)T After the transforms, the normal remains orthogonal to the triangle.
Trang 33trans-Before transforms, n is orthogonal to the triangle 〈 p,q,r〉 Whereas 〈 p,q,r〉 is transformed by M, n is transformed by (M−1)T Then, the
trans-formed normal n′ remains orthogonal to the transtrans-formed triangle 〈 p′,q′,r′〉.
Trang 34Given EYE, AT, and UP, the camera space is defined Its origin is EYE, and the basis is {u,v,n} In terms of the camera space, the camera
is located at the origin and points in the −n direction, i.e., the view direction is −n.
Trang 35The camera space {EYE, u,v,n} is superimposed onto the world space {O,e1,e2,e3} It is done by a translation followed by a rotation The two transforms are combined to produce the view transform, which converts the world-space objects into the camera space.
Trang 36The first is the standard basis for R2 The second is a valid basis for R2, but is neither standard nor orthonormal The third is not the standard but an orthonormal basis.
Trang 37The vertex position and normal are denoted by p and n, respectively Once the light source and camera positions are defined, l, r, and v are
obtained Then, lighting can be computed per vertex
Trang 38The pyramid-like volume is named view frustum The polygons outside the view frustum (illustrated in red) are considered invisible.
Trang 39If a polygon intersects the view frustum’s boundary, the part of the polygon outside the view frustum is discarded.
Trang 40Projection transform (a) The view frustum is deformed into a cuboid The deformation named projection transform is in fact applied to the
objects in the scene Observe how the teapot is deformed (b) Cross-section views show how the perspective projection effect (called
fore-shortening) is achieved through projection transform
Trang 41The z-coordinates are negated for switching from the right-handed clip space to the left-handed clip space Z-negation is equivalent to the
z-axis inversion
Trang 42The last transform in the vertex processing stage, M proj, converts the right-handed camera-space objects into the left-handed clip space This illustrates the combination of Fig 2.16-(a) and Fig 2.17.
Trang 43Computing projection matrix (a) Normalized coordinate y′ is computed (b) The aspect ratio can be defined in terms of fovx and fovy.
Trang 44The projection transform converts the z-range [−f,−n] to [−1,0].