CG Homework 5, due Mon 2017-10-16 2359

  1. (2 pts) What is the angle (in degrees) between these two vectors: (1,2,0), (1,2,3)?

  2. (2 pts) (Reverse engineering rotations) In 2D, if the point (4,2) rotates about the origin to (2,-4), what's the angle?

  3. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \begin{pmatrix}2\\4\\5\end{pmatrix} \times p\).

  4. (2 pts) Give the matrix M that has this property: for all vectors p, \(Mp = \left( \begin{pmatrix}2\\4\\5\end{pmatrix} \cdot p \right) \begin{pmatrix}2\\4\\5\end{pmatrix}\).

  5. (2 pts) Why can the following not possibly be a 3D Cartesian rotation matrix?

    \(\begin{pmatrix} 3& 0 &0\\1 & 0 &0\\0& 0 &1\end{pmatrix}\)

  6. (2 pts) Use any method (not involving soliciting answers on the internet) to rotate the point (4,4,6) by 120 degrees about the axis (2,2,3). Explain your method. (E.g., if you saw the answer in a vision, are your visions generally accurate?)

  7. (2 pts) Can the volume of a small cube change when its vertices are rotated? (yes or no). Why (not)?

  8. (2 pts) What is the ''event loop''?

  9. (2 pts) Why does putting all your vertices into an array and telling OpenGL about it make a big graphics program faster?

  10. (2 pts) Since the Z (aka depth) buffer looks so useful, why is it not enabled by default?

  11. (2 pts) What's the quaternion representing a rotation of 180 degrees about the axis (0,1,0)?

  12. (2 pts) Use the quaternion formulation to rotate the point (0,1,0) by 180 degrees about the axis (0,1,0).

  13. (2 pts) Use the vector formulation to rotate the point (0,1,0) by 180 degrees about the axis (0,1,0).

  14. (14) Extend your program from last week that displays the Starship Enterprise as follows:

    1. Do the rotation in the vertex shader instead of in the javascript program.
    2. Make the color of each pixel depend on its z-value.

(Total: 40 points.)

CG Class 14, Thurs 2017-10-05

1   Quaternions

another example.

3   Angel programs

Chapter 4

  1. color interpolation
  2. element arrays
  3. etc

4   3D interpolation

My note on 3D Interpolation, which is better than the textbook section on animating with Euler angles.

The problem with stepping the 3 Euler angles together is that the combo rotation might not be smooth.

5   Possible VIVE Virtual Reality System

I might be able to buy a VIVE Virtual Reality System for class. Anyone who might be interested, please tell me.

Disclaimers: It might not arrive in time. It wants a PC with an excellent Nvidia card and space for the user to walk around. I don't yet know how where that would be and how we'd share it out if many people are interested. Etc. Etc.

6   Homework 5 online

Homework 5 is online; due in a week and a half.

7   Chapter 5 Slides

We'll continue with the textbook powerpoint slides.

The big topic for Chapter 5 is homogeneous coordinates. They allow all the common transformations - translation, rotation, scaling, projection - to be expressed as a multiplication by a 4x4 matrix.

  1. 5_1 Representation - I'll skip this one.
  2. My take on homogeneous coordinates.

8   Next week

Tues: regular class
Wed: review for midterm
Thurs: midterm exam in class

CG Class 12, Mon 2017-10-02

1   Quaternions

My note on quaternions. This is an alternative method to rotate in 3D. Its advantages are:

  1. It starts from the intuitive axis-angle API.
  2. Animating a large rotation in small steps (by varying the angle slowly) is easy. In contrast, stepping the 3 Euler angles does not work well, and there's no obvious way to gradually apply a \(3\times3\) rotation matrix, \(M\). (You could compute \(M^{1/100}\) and apply it 100 times, but that computation is messy. Eigenvectors are useful here.)
  3. When combining multiple rotations, the axis and angle of the combo is easy to find.
  4. Having only 4 parameters to represent the 3 degrees of freedom of a 3D rotation is the right number. Using only 3 parameters, as Euler angles do, causes gimbal lock. That is, you cannot always represent a smooth rotation by smooth changes of the 3 parameters. OTOH, using 9 parameters, as with a matrix, gives too much opportunity for roundoff errors causing the matrix not to be exactly a rotation. (You can snap the matrix back to a rotation matrix, but that's messy.)

3   Shadertoy

Here is the link to Shadertoy.com. The co-creator of the website has an account named "iq", searching for that account brings up some renders that really push Webgl to its limits in really pretty ways (he used to work for Pixar and Siggraph) - Seretsi Khabane Lekena '17.

You'll have to run these yourself. The old laptop that I bring to class has only integrated graphics.

5   Handwritten notes from class

System Message: WARNING/2 (<string>, line 38); backlink

Duplicate explicit target name: "here".

Here.

CG Class 9, Mon 2017-09-25

1   SIGGRAPH 2017 videos

SIGGRAPH is the world's leading CG conference. I'll show various videos from it.

  1. New tech.

2   Text chapter 3 programs

Now, we'll see in more detail how some programs in http://www.cs.unm.edu/~angel/WebGL/7E/03/ work.

  1. squarem

3   Slides

We'll continue with the textbook powerpoint slides.

  1. 4_1 Input and Interaction
  2. 4_2 Animation
  3. 4_3 Working with Callbacks

4   3D rotation

  1. Now we're starting a module on 3D rotations.
  2. My note on 3D rotation.
    1. All rigid transformations in 3D that don't move the origin have a line of fixed points, i.e., an axis, that they rotate around.
    2. deriving the vector formula for a rotation given the axis and angle
    3. computing the matrix from a rotation axis and angle
    4. testing whether a matrix is a rotation
    5. if it is, then finding the axis and angle.

5   Euler and angles and Gimbal lock

  1. http://www.youtube.com/watch?v=rrUCBOlJdt4&feature=related Gimble Lock - Explained.

    One problem with Euler angles is that multiple sets of Euler angles can degenerate to the same orientation. Conversely, making a small rotation from certain sets of Euler angles can require a jump in those angles. This is not just a math phenomenon; real gyroscopes experience it.

  2. http://en.wikipedia.org/wiki/Gimbal_lock

  3. What is Gimbal Lock and why does it occur? - an animator's view.

6   Homework 4 online

  1. Homework 4 is online; due next Mon 2359. Changed to next Thurs.

CG Homework 4, due Thu 2017-10-05 2359

(No programming this week).

  1. (2 pts) Put the following in the correct order for the graphics pipeline.

    fragment-shader primitive-assembly rasterizer vertex-shader

  2. (2) If you wanted to read some user input and then change all the vertex positions by multiplying each x-coordinate by some amount, the most efficient (in machine time) place to do it (pick one):

    1. with a javascript function
    2. in the vertex shader
    3. in the fragment shader
    4. in the html file
    5. it can't be done.
  3. (2) Why does OpenGL have the triangle-strip object type, in addition to the triangle type?

    1. It leads to smaller, faster, graphics objects.
    2. It leads to bigger, faster, graphics objects.
    3. It's not possible to split some complicated polygons into lots of simple triangles, but you can split them into triangle-strips.
    4. The standards writers were being paid by the word.
  4. (2) Standards (select all that are true)

    1. allow programmers to move between projects
    2. allow different types of hardward to be substituted in.
    3. ..... operating systems ......
    4. allow vendors to lock in customers.
    5. can prevent the latest HW from being used to its fullest.
  5. (2) What is the physical principle underlying LCD?

    1. Fire an energetic electron at a rare earth atom and a photon of light is emitted.
    2. A solution of corkscrew shaped molecules can rotate polarized light.
    3. Putting your finger close to a capacitor can change its capacitance.
    4. If two coils of wire are close, then an alternating current in one can induce a current in the other.
  6. (2) What is the physical principle underlying the CRT?

    1. Fire an energetic electron at a rare earth atom and a photon of light is emitted.
    2. A solution of corkscrew shaped molecules can rotate polarized light.
    3. Putting your finger close to a capacitor can change its capacitance.
    4. If two coils of wire are close, then an alternating current in one can induce a current in the other.
  7. (2) Which of Philo T Farnsworth's chores as a kid gave him an idea for electronic television?

  8. (2) Color printing on a sheet of paper exemplifies

    1. additive color
    2. subtractive color
    3. multiplicative color
    4. divisive color
    5. exponential color
  9. (4) Major components of the OpenGl model as discussed in class are:

    1. Objects, viewer, light sources, planets, material attributes.
    2. Still cameras, video cameras, objects, light sources.
    3. Objects, viewer, light sources, material attributes.
    4. Colored objects, black and white objects, white lights, colored lights
    5. Flat objects, curved objects, near lights, distant lights.
  10. (2) How do you draw a pentagon in WebGL?

    1. Split it into triangles.
    2. Split it into triangles if it is concave, otherwise draw it directly.
    3. Split it into triangles if it is convex, otherwise draw it directly.
    4. Draw it directly.
    5. Split it into hexagons.
  11. (2) If you want your javascript program to send a color for each vertex to the vertex shader, what type of variable would the color be?

    1. uniform
    2. varying
    3. attribute
    4. dynamic
    5. static
  12. (2) The carpet is an example of

    1. diffuse reflection
    2. specular reflection
    3. environment mapping
    4. bump mapping
    5. how RPI saves money
  13. (2) In the OpenGL pipeline, the Primitive Assembler does what?

    1. fits together pieces of ancient Sumerian pottery.
    2. rotates vertices as their coordinate systems change.
    3. creates lines and polygons from vertices.
    4. finds the pixels for each polygon.
    5. reports whether the keyboard and mouse are plugged in correctly.
  14. (2) If you do not tell WebGL to do hidden surface removal, and two objects overlap the same pixel, then what color is that pixel?

    1. WebGL throws an error.
    2. the closer object
    3. the farther object
    4. the first object to be drawn there
    5. the last object to be drawn there
  15. (2) gasket2 has this code: var points=[ ]; ... points.push(a,b,c); What does push do here?

    1. Appends new entries to the end of points.
    2. Inserts new entries at the start of points.
    3. Overwrites the first entries of points.
    4. Overwrites the last entries of points.
    5. Throws an error because we didn't specify a size for points.
  16. (2) Look at this CIE chromaticity diagram. If you wanted to make white by mixing one spectrally pure color with the pure color with wavelength 600 nm, what wavelength would that other color be?

    1. 400
    2. 485
    3. 535
    4. 580
    5. It's not possible, because purple is not a spectrally pure color.
  17. (2) Sometimes you want to send a variable to a vertex shader that has the same value for every vertex. Pick the following item for which this would be useful.

    1. the vertex's coordinates
    2. the vertex's color
    3. the object's global orientation
    4. the location of the global light source
  18. (2) You call gl.BufferSubData to do what?

    1. to add or replace part of the buffer in the GPU.
    2. to define a submarine object.
    3. to subtract some data in the buffer.
    4. to tell the GPU to look for a pattern and substitute any occurrences,
    5. to tell the GPU to use a subroutine instead of the main program.

(Total: 38 points.)

CG Class 8, Thu 2017-09-21

1   SIGGRAPH 2017 videos

SIGGRAPH is the world's leading CG conference. I'll show various videos from it.

  1. Computer Animation Festival Trailer.
  2. SIGGRAPH 2017 VR Village Trailer.

2   Today's demo program

For today's demo program, I'll modify triangle to add a slider that skews a vertex. Then we can maybe rotate.

3   Euler and angles and Gimbal lock

  1. http://www.youtube.com/watch?v=rrUCBOlJdt4&feature=related Gimble Lock - Explained.

    One problem with Euler angles is that multiple sets of Euler angles can degenerate to the same orientation. Conversely, making a small rotation from certain sets of Euler angles can require a jump in those angles. This is not just a math phenomenon; real gyroscopes experience it.

  2. http://en.wikipedia.org/wiki/Gimbal_lock

  3. What is Gimbal Lock and why does it occur? - an animator's view.

5   Slides

We'll continue with the textbook powerpoint slides.

  1. 3_3, Programming with WebGL Part 4: Color and Attributes
  2. 3_4, Programming with WebGL Part 5: More GLSL
  3. 3_5, Programming with WebGL Part 6: Three Dimensions

6   Next few lectures will be mostly mathematics

I'm replacing the Angel lecture at Incremental and Quaternion Rotation, with my own material. Feel free to read ahead.

7   Homework 3 online

  1. Homework 3 is online; due next Mon 2359.

CG Class 7, Mon 2017-09-18

2   This Wed

  1. No prepared lectures.
  2. The TAs will be present to help, e.g., with the homework.

3   SIGGRAPH 2017 videos

SIGGRAPH is the world's leading CG conference. I'll show various videos from it.

  1. BendSketch: Modeling Freeform Surfaces Through 2D Sketching.

4   How to print info from inside your javascript program

  1. There are several ways; here is the easiest.

  2. Reference: http://www.w3schools.com/js/js_output.asp

  3. Examples to do inside square.js:

    1. window.alert('this is an alert');
    2. window.alert('vertices length: ' + vertices.length + ' 1: ' + vertices[1]);
  4. Note that you can write variable values as well as strings.

  5. Another way is to write to the console log thus:

    console.log('this is a log message');

  6. In firefox, you can display the log window with F12.

  7. An advantage of the log is that you see all the messages together.

  8. I'll demo these methods.

5   Today's demo program

For today's demo program, I'll modify triangle to add a slider that controls the amount of green to add to the triangle color.

  1. The amount of green will be read from a slider.
  2. Scrounge your slider code from gasket5.
  3. The value will be transmitted to the fragment shader in a uniform variable.
  4. Scrounge around in Angel's examples to see how to use a uniform variable. (I grepped for 'uniform').

6   Slides

We'll continue with the textbook powerpoint slides.

  1. 3_3, Programming with WebGL Part 4: Color and Attributes
  2. 3_4, Programming with WebGL Part 5: More GLSL
  3. 3_5, Programming with WebGL Part 6: Three Dimensions

7   Next few lectures will be mostly mathematics

I'm replacing the Angel lecture at Incremental and Quaternion Rotation, with my own material. Feel free to read ahead.

8   Homework 3 online

  1. Homework 3 is online; due next Mon 2359.