交互式计算机图形学课后答案2
《计算机图形学》1-4章习题解答

光栅扫描显示器的工作原理:将CRT屏幕分成由像素构成的光栅网格,其中像素的灰度和颜色信息保存在帧缓存中。电子束在水平和垂直偏转磁场的作用下从左向右,从上向下扫描荧光屏,产生一幅幅光栅,并由显示内容来控制所扫描的像素点是否发亮,从而形成具有多种彩色及多种明暗度的图像。
相当于:
9.将梁友栋-Barsky线段裁剪算法推广到三维,写出对下述三维观察体所要满足的不等式:
(a)平行规范化观察体;
(b)透视规范化观察体。
答:设 和 是线段的两个端点。线段的参数方程是:
平行规范化观察体是由平面 组成的单位立方体;
透视规范化观察体是由平面 组成的被截断的部分棱锥。
(a)对于平行规范化观察体,内部点满足:
垂直回扫:电子束到达每次刷新周期末尾,从CRT屏幕右下角回到屏幕左上角的动作。
8.为什么很多彩色打印机使用黑色颜料?
答:彩色颜料(青、品红、黄)相对来说较贵,并且在技术上很难通过多种颜色产生高质量的黑色。
9.简述随机扫描显示器和光栅扫描显示器的简单工作原理和各自的特点。
答:随机扫描显示器的工作原理:要显示的图形定义是一组画线命令,存放在刷新缓存中,由显示控制器控制电子束的偏移,周期性地按画线命令依次画出其组成线条,从而在屏幕上产生图形。
(a)绕原点;
(b)绕点P(-1,-1)。
答:三角形矩阵 ,设旋转之后的三角形矩阵为S’
逆时针旋转矩阵
平移矩阵 反平移矩阵
(a) ,得
(b) ,得
。
2.将三角形A(0,0),B(1,1),C(5,2)放大两倍,保持C(5,2)不变。
答:
(完整word版)计算机图形学阶段练习二答案

计算机图形学阶段练习二答案覆盖范围:(第4、5章)1.欧氏空间中的几何元素包含那些内容?答: 欧氏空间中的几何元素包含:点:点是0维几何分量,包括端点、交点、切点和孤立点等。
线:线是一维几何元素,是两个或多个邻面的交界。
面:面是二维几何元素,是形体上一个有限、非零的区域,由一个外环和若干个内环界定其范围。
环:环是有序、有向边(直线段或曲线段)组成的面的封闭边界。
环中的边不能相交,相邻两条边共享一个端点。
确定面的最大外边界的环称之为外环;确定面中内孔或凸台边界的环称之为内环。
通常,外环的边按逆时针方向排序,而内环的边按顺时针方向排序,这样在面上沿一个环前进,其左侧总是面内,右侧总是面外。
体:体是三维几何元素,由封闭表面围成空间,也是欧氏空间R3中非空、有界的封闭子集,其边界是有限面的并集。
2.利用正则集的概念描述实体的定义?答:根据客观存在的三维形体的性质,三维空间中的物体是一个内部连通的三维点集,也就是由其内部的点集及紧紧包着这些点的表皮组成。
而物体的表皮具有连通性、有界性、非自相交性、可定向性、闭合性等性质。
由内部点构成的点集的闭包就是正则集,三维空间的正则集就是正则形体。
如果正则形体的表面是二维流形,即对于实体表面上的任意一点,都可以找到一个围绕着它的任意小的领域,该领域与平面上的一个圆盘是拓扑等价,那么这个正则形体就是实体。
3.什么是四连通区域?什么是八连通区域?四连通区域与八连通区域有什么区别?答:4-连通区域是指从区域上的一点出发,通过访问已知点的4-邻接点,在不越出区域的前提下,遍历区域内的所有像素点。
8-连通区域是指从区域上的一点出发,通过访问已知点的8-邻接点,在不越出区域的前提下,遍历区域内的所有像素点。
4-连通区域常可以看作是8-连通区域,但对边界条件有要求,边界表示的4-连通区域的外环边界是一个8-连通区域,而边界表示的8-连通区域的外环边界是一个4-连通区域。
内点表示的4-连通区域也是8-连通区域,内点表示的8-连通区域则不一定是4-连通区域。
计算机图形学课后习题答案

计算机图形学课后习题答案计算机图形学课后习题答案计算机图形学是一门研究计算机生成和处理图像的学科,它在现代科技和娱乐领域扮演着重要的角色。
在学习这门课程时,我们通常会遇到一些习题,用以巩固所学知识。
本文将提供一些计算机图形学课后习题的答案,希望能对大家的学习有所帮助。
1. 什么是光栅化?如何实现光栅化?光栅化是将连续的几何图形转换为离散的像素表示的过程。
它是计算机图形学中最基本的操作之一。
实现光栅化的方法有多种,其中最常见的是扫描线算法。
该算法通过扫描图形的每一条扫描线,确定每个像素的颜色值,从而实现光栅化。
2. 什么是反走样?为什么需要反走样?反走样是一种减少图像锯齿状边缘的技术。
在计算机图形学中,由于像素是离散的,当几何图形的边缘与像素格子不完全对齐时,会产生锯齿状边缘。
反走样技术通过在边缘周围使用不同颜色的像素来模拟平滑边缘,从而减少锯齿状边缘的出现。
3. 什么是光照模型?请简要介绍一下常见的光照模型。
光照模型是用来模拟光照对物体表面的影响的数学模型。
常见的光照模型有以下几种:- 环境光照模型:模拟环境中的整体光照效果,通常用来表示物体表面的基本颜色。
- 漫反射光照模型:模拟光线在物体表面上的扩散效果,根据物体表面法线和光线方向计算光照强度。
- 镜面反射光照模型:模拟光线在物体表面上的镜面反射效果,根据光线方向、物体表面法线和观察者方向计算光照强度。
- 高光反射光照模型:模拟光线在物体表面上的高光反射效果,通常用来表示物体表面的亮点。
4. 什么是纹理映射?如何实现纹理映射?纹理映射是将二维图像(纹理)映射到三维物体表面的过程。
它可以为物体表面增加细节和真实感。
实现纹理映射的方法有多种,其中最常见的是将纹理坐标与物体表面的顶点坐标关联起来,然后通过插值等技术将纹理映射到物体表面的每个像素上。
5. 什么是投影变换?请简要介绍一下常见的投影变换方法。
投影变换是将三维物体投影到二维平面上的过程。
常见的投影变换方法有以下几种:- 正交投影:将物体投影到一个平行于观察平面的平面上,保持物体在不同深度上的大小不变。
交互式计算机图形学课后答案2.docx

CG Assignment 5 (Paper Homework 2 Chapters 5-8)Deadline June 20 2010請將答案寫在Word檔(亦可寫在紙本上用掃描器或像機取像成影像檔・jpg)中上傳至portal.1.Exercise 5.2(p. 286 in textbook)5.2 Suppose that the axis of the plane is its z direction and up is the y direction.In the airplane*s coordinate system, the roll・ pitch and yaw correspond to rotations about the z, x and y axes respectively. Thus we can control theorientation relative the origin by a rotation of the form(vol I) R j (pi tch) (yaw). We must also do a translation to move the airplane to its desired location.2.Exercise 5.7 (p. 286)5.7 The result follows from the transformation being affine. We can also take adirect approach. Consider the line determined by the points (忑1,2/1,21) and Z/2,^2)- Any point along can be written parametrically as (ctxy + (1 — a)龙2, ay、+ (1 — a)?/2, otZ\ + (1 —Consider the simple projection of this point —小2)(曲】+(】一 &)爼2,虫/1 + (1 — Q)92) which is of the form + (1 — 0)^2, + (1 一a)92)・ This form describes a line because the slope is constant. Note that the function /(a) implies that we trace out the line at a nonlinear rate as a increases from 0 to 1.3.Exercise 5.15 (p. 286)5.15 If we use 0 = 0 = 45, we obtain the projection matrix10-10 0 1-10 0 0 0 00 0 0 14. Exercise5.17 (p. 287)5.17 All the points on the projection of the point {x.y^z} in the direction (1工、d 和 d z ) are of the form (x + ad 巧 y + ad y ^z + adz). Thus the shadow of the point (a;, z) is found by determining the a for which the line intersects the plane, that isax s + by s + cz s = dSubstituting and solving, we findd — ax — by — cz(id x + bdy + cd zHowever, what we want is a projection matrix, Using this value of a we x(bd y + cd x ) — d x {d -by - cz) with similar equations for y s and z$. These results can be computed bymultiplying the homogeneous coordinate point 1) by the projection matrix5. Exercise6.7 (p. 327)6.7 Let 0 be the angle between the normal and the halfway vector, 0 be the angle between the viewer and the reflection angle, and 9 be the angle between the normal and the light source. If all the vectors lie in the same plane, theangle between the light source and the viewer can be computer either as 0 + 20 or as 2(0 + 0). Setting the two equal, we find © = 20. If the vectors are not coplanar then 0 V 20・6. Exercise 6.19 (p. 328)6.19 Shading requires that when we transform normals and points, we maintain t he angle between them or ecjuivalently have the dot product p • v = p‘ •v‘ when p z = Mp and n f = Mp. If is an identity matrixangles are preserved. Such a matrix (M _1 = ) is called orthogonal.Rotations and translations are orthogonal but scaling and shear are not.7. Exercise 6.24 (p. 328)6.24 The normal at each point on the sphere points from the origin to that point. Given this normal n and the location of the viewer p, we can compute thereflection vector r = 2(p • n)n — p as in Section 6.5. The viewer would see thefind x s = z + ad 工= (idx + bdy + cd zbdy + cd z —Cldy —adz 0 ad/工 + cdz —bdz 0 Tdy ad x + bdy 0 —dd x_ddy -dd z adx + bdy + cd zcolor of the first opaque object along this reflected vector from the sphere.8.Exercise 7J (p. 379)7.1 First, consider the problem in two dimensions. We are looking for an a and(3 such that both parametric equations yield the same point, that isx(a) = (1 - a)xi + ax2 = (1 - 0)©3 + 0©4,9(a) = (1 - Q)S +QV2 = (1 - 0)1/3 + 0V4・These are two equations in the two unknowns a and 0 and, as long as the line segments are not parallel (a condition that will lead to a division by zero), we can solve for a 0. If both these values are between 0 and 1, the segmentsintersect.If the equations arc in 3D, we can solve two of them for the a and (3 where x and y meet. If when we use these values of the parameters in the two equations for z,the segments intersect if we get the same z from both equations.9.Exercise 7.6 (p- 380)7.6 First we want to move the window to the center with the translationT(-(x max + x m i n)/2, -(y m ai + "诚n)/2,0). Next we want to scale the sides to be the size of the viewport by S(Urnax~Umln, rmQJ~rmtn, 1). Finally 'ymax~ymin 7 7 we move the origin to the center of the viewport bymax10.Exercise 7.18 (p. 381)7.18 Suppose that the equation of the edge is y = mx + h where m and h aredetermined from and (©2,92)・ For any changein y、thecorresponding change in x must be Thus if (勺./) is theintersection of the edge with a scan line, the intersection with the next scanline must be at @ + 令皿 + 1) because we move one unit in y and must still be on the edge・ Thus, once we have the first intersection, the calculation of successive int er sect ion requires only one addition per intersection.11.Exercise 8.1. (p. 448)8.1Suppose that we move across a scanline left to right starting on the outsideof a polygon. Assume that 0 corresponds to the background color and 1 is the edge and fill color. As we move across the scanline we replace each point by the exclusive or of its value with the value of the point on the left (which has already been processed). If we start on the outside of any polygon, vve can assume the first point is a 0. Thus as long as we remain outside the firstpolygon we generate 0 ㊉0 = 0. When we encounter the first edge, a L we compute 1 ㊉0 = 1 (that is we have a 0 from the last point XORed with the edge). As we proceed inside the polygon we compute 1 ㊉0 = 1 because we have a 1 from the last XOR and a 0 from the unfilled point. When weencounter the second edge, we compute 1 ㊉1 =0, thus returning to our initial situation12.Exercise 8.2 (p. 448)8.2The problem is that if the area under the cursor is not all Vs or all 0's, someof the points will be complemented and some will be unchanged・ Thus, the cursor region, may not look like the original cursor, although a second XOR will return us to the original display and we should be able to notice where the cursor is located by the bits that do change.13.Exercise &10 (p. 449)8.10 There are two issues. First, if we use a and 1 — ci we avoid problems ofhaving colors and opacities exceeding 1 and being clipped. However, by using this choice, the order in which we composite multiple surfaces matters which would not make a difference if we used Q and 1.。
计算机图形学基础课后部分习题答案

计算机图形学基础第一章1.名词解释:图形:从客观世界物体中抽象出来的带有颜色信息及形状信息的图和形。
图像:点阵法:是用具有灰度或颜色信息的点阵来表示的一种方法。
参数法:是以计算机中所记录图形的形状参数与属性参数来表示图像的一种方法。
2.图形包括那两方面的要素,在计算机中如何表示他们?构成图形的要素可以分为两类:一类是刻画形状的点、线、面、体等几何要素;另一类是反映物体本身固有属性,如表面属性或材质的明暗、灰度、色彩等非几何要素。
3.什么叫计算机图形学?分析计算机图形学,数字图像处理和计算机视觉学科间的关系。
计算机图形学是研究怎样利用计算机来显示、生成和处理图形的原理、方法和技术的一门学科。
【关系图在课本第一页】4,有关计算机图形学的软件标准有哪些?计算机图形核心系统(GKS)及其语言联编、计算机图形元文件(CGM),计算机图形接口(CGI),基本图形转换规范(IGES)、产品数据转换(STEP)6.试发挥你的想象力,举例说明计算机图形学有哪些应用范围,解决的问题是什么?【具体参照课本第5页】第二章1.名词解释LCD: 就是Liquid Crystal Display,它是利用液晶的光电效应,通过施加电压改变液晶的光学特性,从而造成对入射光的调剂,使通过液晶的透射光或反射光受所加电压的控制,达到显示的目的。
LED: 即Liquid-Emitting Diode, 采用二极管激发的光来显示图像。
随机扫描:采用随机定位的方式控制电子束运动光栅扫描:示器显示图形时,电子束依照固定的扫描线和规定的扫描顺序进行扫描。
电子束先从荧光屏左上角开始,向右扫一条水平线,然后迅速地回扫到左边偏下一点的位置,再扫第二条水平线,照此固定的路径及顺序扫下去,直到最后一条水平线,即完成了整个屏幕的扫描。
刷新:刷新是经过一段时间后,信息可能丢失,需要重写,为了使信息储存更长的时间,必须不断的刷新每个储存单元中储存的信息,也就是将各储存单元中的数据读出之后,再写回到元单元中,对各储存单元中的电容器进行充电.刷新频率:刷新率是指电子束对屏幕上的图像重复扫描的次数。
计算机图形学习题答案

1. 计算机中由图形的形状参数(方程或分析表达式的系数,线段的端点坐标等)加属性参数(颜色、线型等)来表示图形称图形的参数表示;枚举出图形中所有的点称图形的点阵表示,简称为图像(数字图像)2. 什么是计算机图形学?计算机图形学有哪些研究内容?计算机图形学研究利用计算机产生图形和显示图形,它包括对要产生图形的物体的描述(建模或几何描述),对图形数据的管理和操作(数据结构和图形变换),图形的生成,显示和输出。
在交互式的图形系统中,还包括研究图形的输入和图形操作的人机接口。
几何模型构造技术 图形生成技术图形的操作与处理方法图形信息的存储,检索与交换技术 人机交互与用户接口技术 动画技术图形硬件与输出技术图形标准与图形软件包的研究开发 可视化技术 虚拟现实技术 3. 计算机图形学有哪些应用领域?计算机辅助设计、图示图形学、计算机艺术、娱乐、教育与培训、可视化、图形用户接口GUI 、数据表绘制、图像处理4. 计算机图形学有哪些相关学科分支?它们的相互关系是怎样的?图形生成(计算机图形学) 图像变换 模型变换(图像处理)(计算几何)模型(特征)提取(计算机视觉,模式识别) 发展特点:交叉、界线模糊、相互渗透 5. 图形系统的软件系统由哪些软件组成?举例说明。
通用软件包和专用软件包通用图形编程软件包提供一个可用于C 、C++、java 或Fortran 等高级程序设计语言的图形函数库。
例如:GL 、OpenGL 、VRML 、Java2D 、Java3D 等。
专用软件包的例子包括艺术家绘画程序和各种建筑、商务、医学及工程CAD 系统。
6. 了解计算机图形系统的硬件。
视频显示设备、光栅扫描设备、图形工作站和观察系统、输入设备、硬拷贝设备数据模型数字图像7. 什么是显示器的分辨率、纵横比、刷新率?分辨率:在水平和垂直方向上每厘米可绘制的点数,无重复的最多点数。
纵横比:系统能显示的像素列数和行数的比值。
刷新频率:在屏幕上重复画图的频率。
计算机图形学教程课后习题参考答案

计算机图形学教程课后习题参考答案(总26页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--第一章1、试述计算机图形学研究的基本内容答:见课本P5-6页的节。
2、计算机图形学、图形处理与模式识别本质区别是什么请各举一例说明。
答:计算机图形学是研究根据给定的描述,用计算机生成相应的图形、图像,且所生成的图形、图像可以显示屏幕上、硬拷贝输出或作为数据集存在计算机中的学科。
计算机图形学研究的是从数据描述到图形生成的过程。
例如计算机动画制作。
图形处理是利用计算机对原来存在物体的映像进行分析处理,然后再现图像。
例如工业中的射线探伤。
模式识别是指计算机对图形信息进行识别和分析描述,是从图形(图像)到描述的表达过程。
例如邮件分捡设备扫描信件上手写的邮政编码,并将编码用图像复原成数字。
3、计算机图形学与CAD、CAM技术关系如何答:见课本P4-5页的节。
4、举3个例子说明计算机图形学的应用。
答:①事务管理中的交互绘图应用图形学最多的领域之一是绘制事务管理中的各种图形。
通过从简明的形式呈现出数据的模型和趋势以增加对复杂现象的理解,并促使决策的制定。
②地理信息系统地理信息系统是建立在地理图形基础上的信息管理系统。
利用计算机图形生成技术可以绘制地理的、地质的以及其它自然现象的高精度勘探、测量图形。
③计算机动画用图形学的方法产生动画片,其形象逼真、生动,轻而易举地解决了人工绘图时难以解决的问题,大大提高了工作效率。
5、计算机绘图有哪些特点答:见课本P8页的节。
6、计算机生成图形的方法有哪些答:计算机生成图形的方法有两种:矢量法和描点法。
①矢量法:在显示屏上先给定一系列坐标点,然后控制电子束在屏幕上按一定的顺序扫描,逐个“点亮”临近两点间的短矢量,从而得到一条近似的曲线。
尽管显示器产生的只是一些短直线的线段,但当直线段很短时,连成的曲线看起来还是光滑的。
②描点法:把显示屏幕分成有限个可发亮的离散点,每个离散点叫做一个像素,屏幕上由像素点组成的阵列称为光栅,曲线的绘制过程就是将该曲线在光栅上经过的那些像素点串接起来,使它们发亮,所显示的每一曲线都是由一定大小的像素点组成的。
交互式计算机图形学1-7章课后题答案

交互式计算机图形学(第五版)1-7章课后题答案(总13页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--Angel: Interactive Computer Graphics, Fifth Edition Chapter 1 SolutionsThe main advantage of the pipeline is that each primitive can be processed independently. Not only does this architecture lead to fast performance, it reduces memory requirements because we need not keep all objects available. The main disadvantage is that we cannot handle most global effects such as shadows, reflections, and blending in a physically correct manner.We derive this algorithm later in Chapter 6. First, we can form the tetrahedron by finding four equally spaced points on a unit sphere centered at the origin. One approach is to start with one point on the z axis(0, 0, 1). We then can place the other three points in a plane of constant z. One of these three points can be placed on the y axis. To satisfy the requirement that the points be equidistant, the point must be at(0, 2p2/3,−1/3). The other two can be found by symmetry to be at(−p6/3,−p2/3,−1/3) and (p6/3,−p2/3,−1/3).We can subdivide each face of the tetrahedron into four equilateral triangles by bisecting the sides and connecting the bisectors. However, the bisectors of the sides are not on the unit circle so we must push these points out to the unit circle by scaling the values. We can continue this process recursively on each of the triangles created by the bisection process. In Exercise , we saw that we could intersect the line of which theline segment is part independently against each of the sides of the window. We could do this process iteratively, each time shortening the line segment if it intersects one side of the window.In a one–point perspective, two faces of the cube is parallel to the projection plane, while in a two–point perspective only the edges of the cube in one direction are parallel to the projection. In the general case of a three–point perspective there are three vanishing points and none of the edges of the cube are parallel to the projection plane.Each frame for a 480 x 640 pixel video display contains only about300k pixels whereas the 2000 x 3000 pixel movie frame has 6M pixels, or about 18 times as many as the video display. Thus, it can take 18 times asmuch time to render each frame if there is a lot of pixel-level calculations. There are single beam CRTs. One scheme is to arrange the phosphorsin vertical stripes (red, green, blue, red, green, ....). The major difficulty is that the beam must change very rapidly, approximately three times as fast a each beam in a three beam system. The electronics in such a system the electronic components must also be much faster (and more expensive). Chapter 2 SolutionsWe can solve this problem separately in the x and y directions. The transformation is linear, that is xs = ax + b, ys = cy + d. We must maintain proportions, so that xs in the same relative position in the viewport as x is in the window, hencex − xminxmax − xmin=xs − uw,xs = u + wx − xminxmax − xmin.Likewiseys = v + hx − xminymax − ymin.Most practical tests work on a line by line basis. Usually we use scanlines, each of which corresponds to a row of pixels in the frame buffer. If we compute the intersections of the edges of the polygon with a line passing through it, these intersections can be ordered. The first intersection begins a set of points inside the polygon. The second intersection leaves the polygon, the third reenters and so on.There are two fundamental approaches: vertex lists and edge lists.With vertex lists we store the vertex locations in an array. The mesh is represented as a list of interior polygons (those polygons with no otherpolygons inside them). Each interior polygon is represented as an array of pointers into the vertex array. To draw the mesh, we traverse the list of interior polygons, drawing each polygon.One disadvantage of the vertex list is that if we wish to draw the edges in the mesh, by rendering each polygon shared edges are drawn twice. We can avoid this problem by forming an edge list or edge array, each element is a pair of pointers to vertices in the vertex array. Thus, we can draw each edge once by simply traversing the edge list. However, the simple edge list has no information on polygons and thus if we want to render the mesh in some other way such as by filling interior polygons we must add something to this data structure that gives information as to which edges form each polygon.A flexible mesh representation would consist of an edge list, a vertex list and a polygon list with pointers so we could know which edges belong to which polygons and which polygons share a given vertex.The Maxwell triangle corresponds to the triangle that connects thered, green, and blue vertices in the color cube.Consider the lines defined by the sides of the polygon. We can assigna direction for each of these lines by traversing the vertices in acounter-clockwise order. One very simple test is obtained by noting that any point inside the object is on the left of each of these lines. Thus, if we substitute the point into the equation for each of the lines (ax+by+c), we should always get the same sign.There are eight vertices and thus 256 = 28 possible black/white colorings. If we remove symmetries (black/white and rotational) there are 14 unique cases. See Angel, Interactive Computer Graphics (Third Edition) or the paper by Lorensen and Kline in the references.Chapter 3 SolutionsThe general problem is how to describe a set of characters that might have thickness, curvature, and holes (such as in the letters a and q). Suppose that we consider a simple example where each character can be approximated by a sequence of line segments. One possibility is to use a move/line system where 0 is a move and 1 a line. Then a character can be described by a sequence of the form (x0, y0, b0), (x1, y1, b1), (x2, y2, b2), .....where bi is a 0 or 1. This approach is used in the example in the OpenGL Programming Guide. A more elaborate font can be developed by using polygons instead of line segments.There are a couple of potential problems. One is that the application program can map different points in object coordinates to the same point in screen coordinates. Second, a given position on the screen when transformed back into object coordinates may lie outside the user’s window.Each scan is allocated 1/60 second. For a given scan we have to take 10% of the time for the vertical retrace which means that we start to draw scan line n at .9n/(60*1024) seconds from the beginning of the refresh. But allocating 10% of this time for the horizontal retrace we are at pixel m on this line at time .81nm/(60*1024).When the display is changing, primitives that move or are removedfrom the display will leave a trace or motion blur on the display as the phosphors persist. Long persistence phosphors have been used in text only displays where motion blur is less of a problem and the long persistence gives a very stable flicker-free image.Chapter 4 SolutionsIf the scaling matrix is uniform thenRS = RS(α, α, α) = αR = SRConsider R x(θ), if we multiply and use the standard trigonometric identities for the sine and cosine of the sum of two angles, we findR x(θ)R x(φ) = R x(θ + φ)By simply multiplying the matrices we findT(x1, y1, z1)T(x2, y2, z2) = T(x1 + x2, y1 + y2, z1 + z2)There are 12 degrees of freedom in the three–dimensional affine transformation. Consider a point p = [x, y, z, 1]T that is transformed top_ = [x_y_, z_, 1]T by the matrix M. Hence we have the relationshipp_ = Mp where M has 12 unknown coefficients but p and p_ are known. Thus we have 3 equations in 12 unknowns (the fourth equation is simply the identity 1=1). If we have 4 such pairs of points we will have 12 equations in 12 unknowns which could be solved for the elements of M.Thus if we know how a quadrilateral is transformed we can determine theaffine transformation.In two dimensions, there are 6 degrees of freedom in M but p and p_ haveonly x and y components. Hence if we know 3 points both before and after transformation, we will have 6 equations in 6 unknowns and thus in two dimensions if we know how a triangle is transformed we can determine theaffine transformation.It is easy to show by simply multiplying the matrices that theconcatenation of two rotations yields a rotation and that the concatenationof two translations yields a translation. If we look at the product of arotation and a translation, we find that the left three columns of RT arethe left three columns of R and the right column of RT is the rightcolumn of the translation matrix. If we now consider RTR_ where R_ is arotation matrix, the left three columns are exactly the same as the leftthree columns of RR_ and the and right column still has 1 as its bottom element. Thus, the form is the same as RT with an altered rotation (whichis the concatenation of the two rotations) and an altered translation. Inductively, we can see that any further concatenations with rotations and translations do not alter this form.If we do a translation by -h we convert the problem to reflection abouta line passing through the origin. From m we can find an angle by whichwe can rotate so the line is aligned with either the x or y axis. Now reflectabout the x or y axis. Finally we undo the rotation and translation so the sequence is of the form T−1R−1SRT.The most sensible place to put the shear is second so that the instance transformation becomes I = TRHS. We can see that this order makessense if we consider a cube centered at the origin whose sides are alignedwith the axes. The scale gives us the desired size and proportions. Theshear then converts the right parallelepiped to a general parallelepiped.Finally we can orient this parallelepiped with a rotation and place it wheredesired with a translation. Note that the order I = TRSH will work too.R = R z(θz)R y(θy)R x(θx) =⎡⎢⎢⎢⎣cos θy cos θz cos θz sin θx sin θy − cos θx sin θz cos θx cos θz sin θy + sin θx sin θz 0 cos θy sin θz cos θx cos θz + sin θx sin θy sin θz −cos θz sin θx + cos θx sin θy sin θz 0−sin θy cos θy sin θx cos θx cos θy 00 0 0 1⎤⎥⎥⎥⎦One test is to use the first three vertices to find the equation of the plane ax + by + cz + d = 0. Although there are four coefficients in the equation only three are independent so we can select one arbitrarily or normalize so that a2 + b2 + c2 = 1. Then we can successively evaluateax + bc + cz + d for the other vertices. A vertex will be on the plane if we evaluate to zero. An equivalent test is to form the matrix⎡⎢⎢⎢⎣1 1 1 1x1 x2 x3 x4y1 y2 y3 y4z1 z2 z3 z4⎤⎥⎥⎥⎦for each i = 4, ... If the determinant of this matrix is zero the ith vertex isin the plane determined by the first three.Although we will have the same number of degrees of freedom in the objects we produce, the class of objects will be very different. For example if we rotate a square before we apply a nonuniform scale, we will shear the square, something we cannot do if we scale then rotate.The vector a = u × v is orthogonal to u and v. The vector b = u × a is orthogonal to u and a. Hence, u, a and b form an orthogonal coordinate system.Using r = cos θ2+ sin θ2v, with θ = 90 and v = (1, 0, 0), we find forrotation about the x-axisr =√22(1, 1, 0, 0).Likewise, for rotation about the y axisr =√22(1, 0, 1, 0).Possible reasons include (1) object-oriented systems are slower, (2) users are often comfortable working in world coordinates with higher-level objects and do not need the flexibility offered by a coordinate-free approach, (3) even a system that provides scalars, vectors, and points would have to have an underlying frame to use for the implementation.Chapter 5 SolutionsEclipses (both solar and lunar) are good examples of the projection ofan object (the moon or the earth) onto a nonplanar surface. Any time a shadow is created on curved surface, there is a nonplanar projection. All the maps in an atlas are examples of the use of curved projectors. If the projectors were not curved we could not project the entire surface of a spherical object (the Earth) onto a rectangle.Suppose that we want the view of the Earth rotating about the sun. Before we draw the earth, we must rotate the Earth which is a rotation about the y axis. Next we translate the Earth away from the origin. Finally we do another rotation about the y axis to position the Earth in its desired location along its orbit. There are a number of interesting variants of this problem such as the view from the Earth of the rest of the solar system.Yes. Any sequence of rotations is equivalent to a single rotation abouta suitably chosen axis. One way to compute this rotation matrix is to form the matrix by sequence of simple rotations, such asR = RxRyRz.The desired axis is an eigenvector of this matrix.The result follows from the transformation being affine. We can also take a direct approach. Consider the line determined by the points(x1, y1, z1) and (x2, y2, z2). Any point along can be written parametrically as (_x1 + (1 − _)x2, _y1 + (1 − _)y2, _z1 + (1 − _)z2). Consider the simple projection of this point 1d(_z1+(1−_)z2) (_x1 + (1 − _)x2, _y1 + (1 − _)y2)w hich is of the form f(_)(_x1 + (1 − _)x2, _y1 + (1 − _)y2). This form describes a line because the slope is constant. Note that the function f(_) implies that we trace out the line at a nonlinear rate as _ increases from 0 to 1.The specification used in many graphics text is of the angles the projector makes with x,z and y, z planes, the angles defined by the projection of a projector by a top view and a side view.Another approach is to specify the foreshortening of one or two sides of acube aligned with the axes.The CORE system used this approach. Retained objects were kept in distorted form. Any transformation to any object that was defined with other than an orthographic view transformed the distorted object and the orthographic projection of the transformed distorted object was incorrect. If we use _ = _ = 45, we obtain the projection matrixP =266641 0 −1 00 1 −1 00 0 0 00 0 0 137775All the points on the projection of the point , z) in the directiondx, dy, dz) are of the form (x + _dx, y + _dy, z + _dz). Thus the shadow of the point (x, y, z) is found by determining the _ for which the line intersects the plane, that isaxs + bys + czs = dSubstituting and solving, we find_ =d − ax − by − czadx + bdy + cdz.However, what we want is a projection matrix, Using this value of _ we findxs = z + _dx =x(bdy + cdx) − dx(d − by − cz)adx + bdy + cdzwith similar equations for ys and zs. These results can be computed by multiplying the homogeneous coordinate point (x, y, z, 1) by the projection matrixM =26664bdy + cdz −bdx −cdx −ddx−ady adx + cdz −cdy −ddy−adz −bdz adx + bdy −ddz0 0 0 adx + bdy + cdz37775.Suppose that the average of the two eye positions is at (x, y, z) andthe viewer is looking at the origin. We could form the images using the LookAt function twice, that isgluLookAt(x-dx/2, y, z, 0, 0, 0, 0, 1, 0);/* draw scene here *//* swap buffers and clear */gluLookAt(x+dx/2, y, z, 0, 0, 0, 0, 1, 0);/* draw scene again *//* swap buffers and clear */Chapter 6 SolutionsPoint sources produce a very harsh lighting. Such images are characterized by abrupt transitions between light and dark. The ambient light in a real scene is dependent on both the lights on the scene and the reflectivity properties of the objects in the scene, something that cannot be computed correctly with OpenGL. The Phong reflection term is not physically correct; the reflection term in the modified Phong model is even further from being physically correct.If we were to take into account a light source being obscured by an object, we would have to have all polygons available so as to test for this condition. Such a global calculation is incompatible with the pipeline model that assumes we can shade each polygon independently of all other polygons as it flows through the pipeline.Materials absorb light from sources. Thus, a surface that appears red under white light appears so because the surface absorbs all wavelengths of light except in the red range—a subtractive process. To be compatible with such a model, we should use surface absorbtion constants that define the materials for cyan, magenta and yellow, rather than red, green and blue.Let ψ be the angle between the normal and the halfway vector, φ bethe angle between the viewer and the reflection angle, and θ be the angle between the normal and the light source. If all the vectors lie in the same plane, the angle between the light source and the viewer can be computer either as φ + 2θ or as 2(θ + ψ). Setting the two equal, we find φ = 2ψ. Ifthe vectors are not coplanar then φ < 2ψ.Without loss of generality, we can consider the problem in twodimensions. Suppose that the first material has a velocity of light of v1 and the second material has a light velocity of v2. Furthermore, assume that the axis y = 0 separates the two materials.Place a point light source at (0, h) where h > 0 and a viewer at (x, y) where y < 0. Light will travel in a straight line from the source to a point (t, 0) where it will leave the first material and enter the second. It will then travel from this point in a straight line to (x, y). We must find the t that minimizes the time travelled.Using some simple trigonometry, we find the line from the source to (t, 0) has length l1 = √h2 + t2 and the line from there to the viewer has length 1l2 = _y2 + (x − t)2. The total time light travels is thus l1v1 + l2v2 .Minimizing over t gives desired result when we note the two desired sines are sin θ1 = h√h2+t2 and sin θ2 = −y √(y2+(x−t)2 .Shading requires that when we transform normals and points, we maintain the angle between them or equivalently have the dot productp ·v = p_ ·v_ when p_ = Mp and n_ = Mp. If M T M is an identity matrix angles are preserved. Such a matrix (M−1 = M T ) is called orthogonal. Rotations and translations are orthogonal but scaling and shear are not.Probably the easiest approach to this problem is to rotate the given plane to plane z = 0 and rotate the light source and objects in the same way. Now we have the same problem we have solved and can rotate everything back at the end.A global rendering approach would generate all shadows correctly. Ina global renderer, as each point is shaded, a calculation is done to see which light sources shine on it. The projection approach assumes that we can project each polygon onto all other polygons. If the shadow of a given polygon projects onto multiple polygons, we could not compute these shadow polygons very easily. In addition, we have not accounted for the different shades we might see if there were intersecting shadows from multiple light sources.Chapter 7 SolutionsFirst, consider the problem in two dimensions. We are looking for an _ and _ such that both parametric equations yield the same point, that isx(_) = (1 − _)x1 + _x2 = (1 − _)x3 + _x4,y(_) = (1 − _)y1 + _y2 = (1 − _)y3 + _y4.These are two equations in the two unknowns _ and _ and, as long as the line segments are not parallel (a condition that will lead to a division by zero), we can solve for _ _. If both these values are between 0 and 1, the segments intersect.If the equations are in 3D, we can solve two of them for the _ and _ where x and y meet. If when we use these values of the parameters in the two equations for z, the segments intersect if we get the same z from both equations.If we clip a convex region against a convex region, we produce the intersection of the two regions, that is the set of all points in both regions, which is a convex set and describes a convex region. To see this, consider any two points in the intersection. The line segment connecting them must be in both sets and therefore the intersection is convex.See Problem . Nonuniform scaling will not preserve the anglebetween the normal and other vectors.Note that we could use OpenGL to, produce a hidden line removed image by using the z buffer and drawing polygons with edges and interiors the same color as the background. But of course, this method was not used in pre–raster systems.Hidden–line removal algorithms work in object space, usually with either polygons or polyhedra. Back–facing polygons can be eliminated. In general, edges are intersected with polygons to determine any visible parts. Good algorithms (see Foley or Rogers) use various coherence strategies to minimize the number of intersections.The O(k) was based upon computing the intersection of rays with the planes containing the k polygons. We did not consider the cost of filling the polygons, which can be a large part of the rendering time. If we consider a scene which is viewed from a given point there will be some percentage of 1the area of the screen that is filled with polygons. As we move the viewer closer to the objects, fewer polygons will appear on the screen but each will occupy a larger area on the screen, thus leaving the area of the screenthat is filled approximately the same. Thus the rendering time will be about the same even though there are fewer polygons displayed.There are a number of ways we can attempt to get O(k log k) performance. One is to use a better sorting algorithm for the depth sort. Other strategies are based on divide and conquer such a binary spatial partitioning.If we consider a ray tracer that only casts rays to the first intersectionand does not compute shadow rays, reflected or transmitted rays, then the image produced using a Phong model at the point of intersection will be the same image as produced by our pipeline renderer. This approach is sometimes called ray casting and is used in volume rendering and CSG. However, the data are processed in a different order from the pipeline renderer. The ray tracer works ray by ray while the pipeline renderer works object by object.Consider a circle centered at the origin: x2 + y2 = r2. If we know thata point (x, y) is on the curve than, we also know (−x, y), (x,−y),(−x,−y), (y, x), (−y, x), (y,−x), and (−y,−x) are also on the curve. This observation is known as the eight–fold symmetry of the circle. Consequently, we need only generate 1/8 of the circle, a 45 degree wedge, and can obtain the rest by copying this part using the symmetries. If we consider the 45 degree wedge starting at the bottom, the slope of this curve starts at 0 and goes to 1, precisely the conditions used for Bresenham’s line algorithm. The tests are a bit more complex and we have to account for the possibility the slope will be one but the approach is the same as for line generation.Flood fill should work with arbitrary closed areas. In practice, we canget into trouble at corners if the edges are not clearly defined. Such can be the case with scanned images.Note that if we fill by scan lines vertical edges are not a problem. Probably the best way to handle the problem is to avoid it completely by never allowing vertices to be on scan lines. OpenGL does this by having vertices placed halfway between scan lines. Other systems jitter the y value of any vertex where it is an integer.Although each pixel uses five rays, the total number of rays has only doubled, . consider a second grid that is offset one half pixel in both thex and y directions.A mathematical answer can be investigated using the notion ofreconstruction of a function from its samples (see Chapter 8). However, a very easy to see by simply drawing bitmap characters that small pixels lead to very unreadable characters. A readable character should have some overlap of the pixels.We want k levels between Imin and Imax that are distributed exponentially. Then I0 = Imin, I1 = Iminr,I2 = Iminr2, ..., Ik−1 = Imax = Iminrk−1. We can solve the last equation for the desired r = ( ImaxImin)1k−1If there are very few levels, we cannot display a gradual change in brightness. Instead the viewer will see steps of intensity. A simple rule of thumb is that we need enough gray levels so that a change of one step is not visible. We can mitigate the problem by adding one bit of random noise to the least significant bit of a pixel. Thus if we have 3 bits (8 levels), the third bit will be noise. The effect of the noise will be to break up regions of almost constant intensity so the user will not be able to see a step because it will be masked by the noise. In a statistical sense the jittered image is a noisy (degraded) version of the original but in a visual sense it appears better.。