Computing Science CMPT

计算科学CMPT 361 2020秋季
作业#1(8分)
书面部分是练习,没有提交;解决方案将于11月17日逐步发布。
编程部分到期:11月17日,星期二,晚上11:45通过电子提交。
编程(8分):俄罗斯方块!
您将按照以下说明实施俄罗斯方块游戏的简化版本。任何
您希望添加到游戏外观中的视觉眩光将由
平地机,并且可以根据自己的判断记入贷方。游戏窗口包含20´10
适当大小的正方形网格,例如,使窗口舒适地适合屏幕。
如下所示,有七个标准的俄罗斯方块(或砖块),带有旋转轴
黑点表示。建议您分几个步骤完成此问题。
(a)[3分]瓷砖和网格渲染以及瓷砖向下移动
用网格线设置游戏窗口,并使用
一次区分一种颜色,然后将它们从游戏窗口的顶部放下。
磁贴的起始位置和方向是随机选择的。你可以控制
瓷砖运动的速度以适合您的游戏。瓷砖的运动
将与网格对齐并以均匀的速度移动。对于此步骤,磁贴可能会掉落
直接从底部穿过。一个图块消失后,将放下新的图块。
(b)[1分]瓷砖堆积
在此步骤中,图块将相互堆叠,并堆叠到游戏底部
窗口会提供地面支持,就像您熟悉的俄罗斯方块游戏一样。
(c)[3分]按键交互和磁贴移动
四个箭头键将用于移动图块。按下“向上”键
围绕其枢轴逆时针旋转一次瓷砖,一次90°。 “左”和“右”
按键会导致瓷砖横向移动,一次移动一个网格。 “向下”键
加速向下运动。任何时候都不要让瓷砖碎片
与任何现有的俄罗斯方块碎片或游戏窗口的边界碰撞。
(d)[1分]附加游戏逻辑
底部的行完全填满后,将其移除,并将其上方的图块堆栈
将向下移动一排。当新的瓷砖无法容纳时,游戏终止
在游戏窗口中。按“ q”退出,按“ r”重新启动。按任何
箭头键不应减慢瓷砖的向下移动。
请注意,以上步骤是按顺序相互构建的。您不需要提交
各个程序对应于这些步骤。如果可以实施所有必需的
零件,一个完整的程序就足够了。没有提供框架代码。
提交:所有源代码和一个README文件,其中记录了所有未包含的步骤
已完成,其他功能以及有关您的TA的任何其他说明。
练习1:“为什么HD DVD失败?”
所谓的“全高清电视”模式支持1920到1080的屏幕分辨率。
视频内容将以30 Hz的频率显示,我们希望提供24位
颜色(每个R,G,B 8位)。那么,这种类型的视频可以容纳多少秒
单层高清DVD,其存储容量为15 GB?你的答案吗
与常识相矛盾? HD DVD格式是否应针对其消亡
竞争对手蓝光可归因于此吗?提供一个解释。
练习2:画线
比较钻石退出规则和Bresenham的算法。特别地,给定两端
点(x1,y1)和(x2,y2)的整数坐标,将由这两个返回的像素
除两个末端像素外,其他算法通常是相同的吗?解释你的答案。
练习3:刚体转换
让我们回想一下,齐次的3D变换矩阵M的一般形式
坐标是
假设M的高3×3子矩阵R是正交的,即RT = R -1

1. M的逆是什么?请注意,您不应使用蛮力或包装
例如Maple或Matlab来回答这个问题。
2.证明变换M在3D中同时保留了长度和角度。笔记
在这里,当我们谈论两个向量之间的角度时,
给出的两个向量将是无关紧要的。
练习4:gluLookAt()
GL实用程序(GLU)库具有一个名为gluLookAt的函数,该函数具有以下内容:
规格:
gluLookAt(ex,ey,ez,rx,ry,rz,ux,uy,uz)
写出变换矩阵T来变换世界坐标中的点
系统(WCS)到由gluLookAt()指定的视图坐标系(VCS)中。这
VCS的原点位于视点(ex,ey,ez),其正z轴与
向量v =(ex,ey,ez)–(rx,ry,rz)。还要记住,向上向量(ux,uy,uz)不是
必须垂直于向量v。您可以将最终答案留为乘积
两个或更多矩阵。CMPT 361编程实验代写
练习5:裁剪凸多边形
证明将一个凸多边形剪切到另一个凸多边形上最多会产生
一个凸多边形。
练习6:BSP与深度排序
显示从后到前的显示顺序


Computing Science CMPT 361 Fall 2020
Assignment #1 (8 marks)
Written parts are exercises, no submission; solutions posted progressively by Nov. 17.
Programming part due: Tuesday, Nov. 17, 11:45 p.m. via electronic submission.
Programming (8 marks): Tetris!
You are to implement a simplified version of the game Tetris as described below. Any
visual flare that you wish to add to the appearance of your game will be judged by the
grader and may be credited at his discretion. The game window consists of a 20 ´ 10
square grid of appropriate size, e.g., so that the window will fit in the screen comfortably.
There are seven standard Tetris pieces (or tiles), as shown below, with pivot of rotation
indicated by a black dot. You are advised to complete this problem in several steps.
(a) [3 marks] Tile and grid rendering and tile downward movement
Set up the game window with grid lines and randomly select Tetris tiles with
distinguishing colors one at a time and drop them from the top of the game window.
The starting position and orientation of the tile is chosen randomly. You can control
the speed of the tile movement to suit your game playing. Movement of the tiles’
will be aligned with the grids and at uniform speed. For this step, the tiles can drop
straight through the bottom. After one tile disappears, a new tile is dropped.
(b) [1 marks] Tile stack-up
In this step, the tiles will stack up on top of each other and the bottom of the game
window will offer ground support, as in the Tetris game you are familiar with.
(c) [3 marks] Key stroke interaction and tile movements
The four arrow keys will be used to move the tiles. A pressing of the “up” key
rotates a tile counterclockwise about its pivot, 90° at a time. The “left” and “right”
key presses result in lateral movements of a tile, one grid at a time. The “down” key
accelerates the downward movement. At no time should you allow a tile piece to
collide with any existing Tetris pieces or the border of the game window.
(d) [1 marks] Additional game logic
When the bottom row is completely filled, it is removed and the tile stack above it
will be moved one row down. Game terminates when a new tile piece cannot be fit
within the game window. Press ‘q’ to quit and ‘r’ to restart. Pressing any of the
arrow keys should not slow down the downward movement of a tile.
Note that the above steps build on top of each other, in order. You need not submit
individual programs to correspond to these steps. If you can implement all the required
parts, a single, complete program is sufficient. No skeleton code is provided.
Submission: All source codes and a README file that documents any steps not
completed, additional features, and any extra instructions for your TA.
Exercise 1: “Why HD DVD failed?”
The so-called “full HDTV” mode supports a screen resolution of 1920 ´ 1080. Suppose
that the video content is to be displayed at 30 Hz and that we wish to provide 24 bits of
color (8 bits per R, G, B). Then how many seconds of video of this type could fit on a
single-layer HD DVD, which has a storage capacity of 15 Gigabytes? Does your answer
contradict with common-sense? Should the demise of the HD DVD format against its
rival Blue-Ray be attributed to this? Offer an explanation.
Exercise 2: Line drawing
Compare the diamond exit rule and the Bresenham’s algorithm. Specially, given two end
points (x1, y1) and (x2, y2) with integer coordinates, will the pixels returned by the two
algorithms, except for the two end pixels, be the same in general? Explain your answer.
Exercise 3: Rigid-body transformations
Let us recall that the general form of a 3D transformation matrix M in homogeneous
coordinates is
Assume that the upper 3 by 3 submatrix R of M is orthonormal, i.e., RT = R -1
.
1. What is the inverse of M? Note that you should not use brute force or a package
such as Maple or Matlab to answer this question.
2. Prove that the transformation M preserves both lengths and angles in 3D. Note
here that when we talk about the angle between two vectors, the order in which
the two vectors are given would be irrelevant.
Exercise 4: gluLookAt()
The GL utility (GLU) library had a function called gluLookAt which has the following
specification:
gluLookAt(ex, ey, ez, rx, ry, rz, ux, uy, uz)
Write out the transformation matrix T which transforms points in the world coordinate
system (WCS) into the view coordinate system (VCS) specified by gluLookAt(). The
VCS has origin at the eye point (ex, ey, ez), and its positive z-axis is aligned with the
vector v = (ex, ey, ez) – (rx, ry, rz) . Also remember that the up vector (ux, uy, uz) is not
necessarily perpendicular to the vector v. You may leave your final answer as a product
of two or more matrices.
Exercise 5: Clipping with convex polygons
Prove that clipping a convex polygon against another convex polygon will yield at most
one convex polygon.
Exercise 6: BSP vs. depth-sort
Show that the back-to-front display order determined by traversing a BSP tree is not
necessarily the same as the back-to-front order determined by depth-sort, even when no
polygons are split. To receive full mark on this problem, the number of polygons you use
for your example must be the smallest possible and you also need to prove that the
number of polygons you used is the smallest possible. Hint: think about an example.
Exercise 7: Silhouettes
Consider a scene consisting of a set of closed convex objects represented by triangle
meshes and a viewpoint, device a simple method which returns the set of all silhouette
edges of the objects with respect to the viewpoint, assuming perspective projection. Prove
that the set of edges returned will be forming a set of closed loops.
Exercise 8: Radiosity
Explain in what ways the radiosity method covered in class is designed to model global
illumination of a scene composed of perfect diffuse reflectors.
Exercise 9: Ray tracing
Explain why the classical ray tracing algorithm, the one covered in class, it best suited to
render “glossy” scenes, i.e., scenes that are composed mostly of highly reflective and
shinny surfaces? Can you propose a simply modification to that algorithm to also render
dull surfaces, i.e., surfaces that are diffuse rather than reflective?

请加QQ:99515681 或邮箱:99515681@qq.com   WX:codehelp

上一篇:[cf516D]Drazil and Morning Exercise


下一篇:python网络编程--进程线程