Computer Graphics (CS 4300) 2010S: Example Exam 1 Problems
Exam 1 covers lectures 0 through 14.
- define the terms scalar, vector, and matrix
- in IEEE754 floating point, what is the result of ?
- considered as a matrix, what are the dimensions of the object ?
- draw a 2D Cartesian coordinate frame and plot two points such that
- what conditions must be satisfied by two vectors such that you can add them? multiply them by the dot product? multiply them by the cross product?
- if are two -dimensional vectors, what type of object is the result of ?
- if are two -dimensional vectors, what type of object is the result of ?
- give the result of subtracting the vector from the vector
- give a formula for the magnitude of a vector of arbitrary dimension
- give a formula to convert any given vector into a parallel unit vector (you may assume that is a function that gives the length of )
- given a 2D vector , explain how its direction can be represented as an angle and give a formula for in terms of and
- give a formula for constructing a 2D unit vector such that the counterclockwise angle between and is radians
- give the result of multiplying the vector by the scalar 4
- is it always true that for two vectors , each of dimension , that ?
- give the result of
- give the result of
- assume two three dimensional vectors and are drawn on a flat sheet of paper; what direction in space would the vector have? what would its magnitude be? What about ?
- give a formula for that involves only , , , and , where is the angle in radians from to
- assuming and are two 3-dimensional vectors, give a formula for that involves only , , , and , where is the angle in radians from to
- define the terms point, ray, segment, and line
- what are the coordinates of the standard basis vectors for a 2D Cartesian frame and ?
- explain how a pair of 2D vectors can be used to represent a line segment, a ray, or a line (explain each of the three cases separately; you may call the “start point” and the “direction vector”)
- Working in 2D, let represent an object that is either a segment, a ray, or a line, and let represent another segment, ray, or line. In each case, is a point on object and is a vector along the object. For the case of a segment, the object can be said to “start” at and “end” at . Assume the objects are not parallel. Set up a single vector equation in two scalar unknowns such that the solution can be used to determine if the two objects intersect, and if so, to compute the coordinates of the intersection point. Give the conditions on the values of that determine if the two objects intersect when both are considered to be line segments and, separately, when both are considered to be rays. Assuming the objects intersect, give a formula for the location of the intersection point in terms of .
- given three 2D points that define the vertices of a triangle in counterclockwise order, show how to use the cross product to determine if a given 2D point is inside the triangle
- how many degrees of freedom does a line have in 2D?
- draw a 2D Cartesian coordinate frame and plot the line with unit normal and perpendicular distance 4 from the origin
- given the unit normal of a line in 2D and its perpendicular distance from the origin, show how to use the dot product to form a single vector equation that must hold for all and only points that fall on the line
- given the unit normal of a line in 2D and its perpendicular distance from the origin, show how to use the dot product to form a single vector expression that gives the signed perpendicular Euclidean distance from any point to the line
- explain how the left hand side of the implicit equation for a line in 2D can be used to define the “left” and “right” sides of the line
- given a 2D line segment from point to point ; (1) give an expression for the vector from to ; (2) give an expression for a vector perpendicular to the line (this expression may use the vector from part 1)
- draw a picture of the memory layout of a typical greyscale raster with 2 rows and 3 columns (assume the first memory index is in the upper left corner of the raster, and that one byte is used to represent the gray level of each pixel)
- assuming a one byte-per-pixel greyscale raster with rows and columns stored contiguously in memory starting at the upper left corner, proceeding across the top row, then from left to right across the second row, etc, and ending at the lower right corner, give an expression for the index of the byte corresponding to the pixel at row and column relative to the start of the raster
- What are the inputs to the midpoint algorithm for drawing line segments in 2D? What are the outputs? What is its asymptotic running time as a function of the inputs in “big-O” notation?
- given particular start and end points and of a 2D line segment in pixel coordinates, draw a pixel grid, and draw the pixels that would be turned on by the midpoint algorithm to rasterize the segment (you may assume that the segment is in quadrant 1 with to the left of , and that it has more run than rise)
- what exactly is the “midpoint” used in the midpoint algorithm for rasterizing line segments?
- The midpoint algorithm requires checking if a point is above or below the line through two given points and . Give one mathematical way to determine the answer to this question for any given point (you may assume that all points are given in pixel coordinates, that the segment is in quadrant 1 with to the left of , and that it has more run than rise)
- Zooming in on a line segment in 2D, we might define its “ideal” shape to be a rectangle . The width of is the desired stroke width and the length of is the length of the segment. Given , state a simple algorithm which uses the concept of sampling to determine which pixels should be turned on to approximate the shape. You do not need to show any math, just state in words what the algorithm should do. Do not worry about efficiency. Finally, explain how applying this algorithm to rasterize the segment into a pixel grid with twice the resolution of the screen can be used to draw the line with greyscale antialiasing, by setting each pixel either to 0 (full off), 1 (full on), or grey level , , or .
- The RGB color space can be thought of as an axis-aligned cube in a 3D Cartesian coordinate frame, with one corner at the origin , and the diagonally opposing corner at . Every point inside (or on the surface of) this cube corresponds to a particular composite color. Describe the colors encountered when traversing the line segment through the cube from to . Draw a diagram of this line segment and describe the approximate color at at least four points on it.
- Give one reason why alternative color spaces, such as HSV (Hue, Saturation, and Value) are useful.
- give a formula to compute the color of a pixel that is the result of compositing a foreground color with a background color with transparency linearly interpolated by the parameter from () to ()
- describe the types of images that are best compressed with JPEG vs PNG compression and vice-versa
- label the components in a screenshot of a GUI application showing a top-level window with title bar, border, resize handles, window buttons (minimize, maximize, close), menu bar, toolbar, statusbar, scrollbars, child windows, radio buttons, checkboxes, sliders, combo boxes, and tooltips
- explain why it is usually a bad design choice to do time consuming things (like wait for a large download to complete) inside of a single call to a GUI event handler
- define at least five typical mouse-related events that are delivered to GUI applications
- explain how it is possible to receive a “mouse dragged” (i.e. the mouse moved while one of its buttons was pressed) event without first getting a “mouse pressed” event
- explain how it is possible to receive a “mouse pressed” event with no matching “mouse released”, even though the user has released the mouse button and your program is still running
- explain how it is possible to receive a “mouse released” event with out first receiving a corresponding “mouse pressed” event
- You are writing a simple drawing program which allows the user to translate graphical objects by dragging them. You already have a list called “geoms” with the existing objects. Code already exists so that each object can be asked to move itself by a translation vector relative to its current position. Similarly, code already exists so that each object can be asked if it contains a given point (all coordinates are given in pixels). Write pseudocode for “mouse-pressed”, “mouse-moved”, “mouse-released”, and “mouse-exited” events that implements the drag functionality. You may assume that the mouse only has one button, and that every event receives the current mouse location as parameters . You may define and use global variables as necessary. Make sure to handle the case where the drag ends but no “mouse-released” event is received by your program.
- let and define an axis-aligned rectangle in a 2D Cartesian frame with axis to the right and axis down: is the upper left corner of the rectangle, and is the lower right corner. (1) give the math to check wither a given point is inside (or on the boundary of) the rectangle; (2) assuming all coordinates are given in integer pixels, write pseudocode for an algorithm to rasterize the rectangle.
- if a closed polygon has edges, how many vertices does it have?
- Given a list of vertices for a simple closed convex polygon, give pseudocode to check wither a point is inside (or on the boundary of) the polygon. Does your method also work for non-convex simple closed polygons? If not, suggest a strategy for handling them.
- Let be two points inside a simple closed convex polygon. What can you guarantee about any point on the line segment connecting to ?
- given two drawings of non-simple polygons (i.e. polygons with holes or self intersections), color in the regions on one that would be considered inside under the even-odd rule, and color in regions on the other that would be considered inside under the nonzero rule
- Draw a picture of a triangle fan in 2D with five vertices given in the order The exact coordinates of each vertex don’t matter (you will need to pick some feasible vertex locations, but you don’t need to show their numeric coordinates). Draw all triangle edges. Label the triangles (0, 1, 2, etc) in the order in which they would be produced by using the vertices in the order given. Draw a curved arrow inside each triangle showing the counterclockwise order of the vertices: the arrow should start near the first vertex of the triangle and end near the third vertex.
- Same as above, but for a triangle strip. In this case, the curved arrows may be drawn either all CCW or in CCW or CW order on a per-triangle basis. If you choose to do the latter, you must label each curved arrow as either CCW or CW.
- Given a non-degenerate triangle in 2D with vertices in CCW order, define a barycentric frame by giving its origin and basis vectors , all in terms of the triangle vertices. Any point in the plane can now be expressed with two scalars such that . Draw a triangle, label the vertices in CCW order, label the point and the vectors , draw any point , and estimate the corresponding .
- Given a picture of a triangle with the lines , , and drawn in barycentric coordinates, sketch in the six additional lines , , .
- Given a non-degenerate triangle in 2D with vertices in CCW order, any point in the plane can be expressed by giving two scalars such that . Give an expression for a third scalar (in terms of and ) such that it is also true that . Then give the mathematical constraints that are satisfied on iff is inside (or on the boundary of) the triangle.
- Given a triangle in 2D with vertices in CCW order and corresponding colors assigned to each vertex, give the formula for barycentric interpolation of a color at a point inside the triangle with barycentric coordinates .
- Given a triangle in 2D with vertices in CCW order and corresponding colors assigned to each vertex, write pseudocode for a simple algorithm to rasterize the triangle using barycentric interpolation to determine the color of all pixels inside (or on the boundary of) the triangle. Do not worry about efficiency. You may assume a function already exists that computes the barycentric coordinates of any pixel . What is the asymptotic run time of your algorithm in “big-O” notation?
- Let be the origin and the basis vectors for a 2D child frame defined with respect to a parent frame. Then the equation is a transformation from child frame coordinates to parent frame coordinates . What condition must hold on and for this to be a rigid transformation?
- Given the coordinates of the origin and the basis vectors of a 2D child frame defined with respect to a parent frame, and a simple picture drawn with respect to its own coordinate frame, make a drawing of the parent frame, label and and sketch the picture as it would appear when transformed into the given child frame.
- Show the result of transforming the point by the matrix . Is this a rotation, scale, or reflection transformation? If it is a rotation or scale, give the numeric amount(s) by which the transformation rotates (counterclockwise) or scales points. If it is a reflection, identify the axis about which the reflection is taken.
- Same as above with .
- Same as above with .
- If is a rotation matrix, give a simple operation for computing .
- Show the result of transforming the point by the homogeneous transformation matrix .
- Let , , and be homogeneous transformation matrices. Show the result of transforming the point by .
- Let be a homogeneous transformation matrix. Give .
- Let be a homogeneous transformation matrix. Give .
- Let be a homogeneous transformation matrix. Give .
- Let be a homogeneous transformation matrix. Give .
- If is a homogeneous transformation matrix corresponding to a pure rotation, give a simple operation for computing .
- You are given a diagram of a scene graph as a tree with all vertices and edges labeled. If an edge connects a vertex labeled to another vertex labeled , and is closer to the root of the tree, then the edge will be labeled , and that will also be a homogeneous transformation matrix taking points in coordinate frame to frame . Give the form of the expression for computing the composite transform from any frame to any other frame in the graph.
- Give an informal definition of a “curve.”
- Given the start point and end point of a line segment, give a vector function that defines the segment as a parametric curve with .
- Given the start point and direction vector of a ray, give a vector function that defines the ray as a parametric curve with .
- Give a vector function and domain for which define a circle with center and radius as a parametric curve.
- Give one reason an implicit form for a curve is sometimes preferable to a parametric form.
- Give an implicit form for the line with unit normal and perpendicular distance from the origin.
- If is a vector function for a parametric curve, what related vector function gives the tangent vector to the curve at ? And what related vector function gives the normal vector to the curve at ? Draw any non-straight curve and sketch in and at at least two points on the curve.
- Sketch an open curve and a closed curve.
- Sketch a curve which has continuity and one which does not.
- Same as above for continuity.
- Same as above for continuity.
- Give the general expression for a polynomial parametric curve of degree with coefficients . For the specific case of , give the corresponding expression for the first and second derivatives and .
- How many bends can a polynomial parametric curve of degree 1 have? Degree 2? Degree 3?
- Define the four quantities that must be specified to define a cubic curve in Hermite form. Draw a cubic curve with two bends and sketch in these four quantities.
- Sketch a smooth curve that interpolates five distinct points.
- Give one advantage of using a cardinal cubic spline vs a Hermite spline.
- Give one advantage of using a Bézier spline vs a cardinal spline.
- What is the difference between a general cardinal spline and a Catmull-Rom spline?
- Sketch the control polygon for for a cubic Bézier curve with one bend. Also sketch the curve itself.
- Same as above but with two bends.
- State at least two useful properties of Bézier curves.
- Given the vertices of the control polygon of a cubic Bézier curve, how would you transform the curve by the homogeneous transformation matrix ?
- Explain what is meant by the “convex hull” property of Bézier curves, and suggest how it could be used to quickly check if two Bézier curves do not intersect.
- What is one way to ensure that continuity is maintained at a knot point between two segments of a cubic Bézier spline? What about continuity?
- Given a drawing of a cubic Bézier curve and its control polygon label all six points generated in the de Casteljau algorithm for evaluating the curve at including the evaluated point labeled . Sketch in all these points and the associated line segments. The de Casteljau algorithm also generates the vertices of control polygons for two cubic Bézier curves that subdivide the original curve at . What are the vertices of the control polygon for the subdivided curve from to ? From to ?
- How many degrees of freedom does an asymmetric rigid object moving in 2D have?
- Give one example of a condition in an animation that would call for a keyframe.
- Let define the pose of a moving object in an animation at one keyframe at time and define the pose at the next keyframe at time . Give the math to linearly interpolate the pose of the object at any interframe at time with .