HW3 · Affine transformations and scene graphs

Lawrence Roberts used homogeneous coordinates for 3D graphics in his 1963 MIT thesis; he later managed the ARPANET program.Roberts, Machine Perception of Three-Dimensional Solids, MIT, 1963
Out Thursday October 22 · due Wednesday October 28, 11:59 PM on Canvas · 25 points · Unity or WebGL · hub · schedule · syllabus · all homework
Read before this homework: Affine Transformations §3, composition and order · §4, the inverse · §8, pivots · Scene Graphs §2 to §5 · §8, local to world and back · Unity for This Course §6 · WebGL and three.js for This Course §6 and §7

What you build

Build the four elementary matrices by hand, see that order is the operation (T · S and S · T differ in their translation column), rotate about a pivot with the sandwich T(p) · R · T(−p), invert a rigid transform with a transpose, and then run the robot arm of the scene-graph demo through Wchild = Wparent · Lchild. The runner places the three boxes with your world matrices only.

JavaScriptC#What it computes
translation, rotationY, rotationZ, scalingTranslation, RotationY, RotationZ, ScalingThe four elementary 4 × 4 matrices (rotations right-handed, degrees).
pivotRotateYPivotRotateYT(p) · Ry(deg) · T(−p).
rigidInverseRigidInverse[R | t]−1 = [RT | −RTt], for a rotation plus translation.
localMatricesLocalMatricesLbase = T(0, 0.2, 0) Ry(baseRy); Larm = T(0, 0.2, 0) T(0, armT, 0) Rz(armBend) T(0, 0.7, 0); Lhand = T(0, 0.7, 0) Ry(handRy).
worldMatricesWorldMatricesWbase = Lbase, Warm = Wbase Larm, Whand = Warm Lhand.
worldToLocalWorldToLocalA world point in the frame of the rigid world matrix W: W−1 p.

The numbers a correct build reproduces

Each row is one check, run on your functions with the published inputs below. The same table appears under the scene in the runner and in the Unity Console.

#CheckExpectedTolerancePoints
1T(3,0,0) · S(2,1,1): translation column(3, 0, 0)0.0000018
2S(2,1,1) · T(3,0,0): translation column(6, 0, 0)0.0000018
3pivotRotateY((1.5, 0, 0), 90): translation column (I − R)p(1.5, 0, 1.5)0.00112
4pivotRotateY: the image of the point one unit past the pivot in x(1.5, 0, -1)0.0016
5rigidInverse of T(0,0,−1) · R_y(90): all 16 entries(0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, -1, 0, 0, 1)0.00114
6worldMatrices at baseRy 30, armBend 40: W_hand, 16 entries(0.6634, 0.6428, -0.383, 0, -0.5567, 0.766, 0.3214, 0, 0.5, 0, 0.866, 0, -0.7793, 1.4725, 0.45, 1)0.00220
7hand origin in world space(-0.7793, 1.4725, 0.45)0.0028
8arm origin in world space(-0.3897, 0.9362, 0.225)0.0028
9worldToLocal: world point (0, 1, 0) in the hand frame(0.3857, -0.9404, 0)0.00216
The published inputs
{
 "order": {
  "s": [ 2, 1, 1 ],
  "t": [ 3, 0, 0 ]
 },
 "pivot": {
  "p": [ 1.5, 0, 0 ],
  "deg": 90
 },
 "rigid": {
  "ry": 90,
  "t": [ 0, 0, -1 ]
 },
 "pose": {
  "baseRy": 30,
  "armBend": 40,
  "handRy": 0,
  "armT": 0
 },
 "worldPoint": [ 0, 1, 0 ]
}

Implement and replace

Build each function from primitives (matrix products, applying a matrix to a point, component access, sin and cos.) and use the engine's own helper, where one exists, only to check your result. These are off limits in your submission:

TrackOff limits
WebGL (JavaScript)makeTRS, axisAngleMatrix, invertTRS from xform.js; THREE.Matrix4.invert, makeTranslation, makeRotationY, makeRotationZ, makeScale, compose; Object3D parenting.
Unity (C#)Matrix4x4.TRS, Translate, Rotate, Scale, .inverse; Transform parenting; TransformPoint, InverseTransformPoint.

Getting started

WebGL track.
  1. Get the homework starter repository (about 2 MB): git clone https://github.com/mgav-uwb/UWB-CSS-551-AU26-homework.git, or Code, then Download ZIP. It gains each homework the day it goes out; git pull fetches it.
  2. In its root folder run python3 -m http.server 8000 and open http://localhost:8000/homework/run.html?hw=hw03.
  3. Edit lib/skeletons/hw03.js, the only file you change, and reload: the Checks table under the scene compares your numbers with the ones below.

The unfilled skeleton runs on this site too, so you can see the page before you start. The setup, the blank page a file opened from disk gives, and how to read the Checks table are in WebGL and three.js for This Course.

Unity track.
  1. In Unity Hub, create a new project with the 3D (Built-In Render Pipeline) template in editor 6000.3.11f1.
  2. From the homework starter repository, copy the files in homework/hw03/unity/ into Assets/HW03/.
  3. Create an empty GameObject, add the Checks component (namespace CSS551.HW03), and press Play: the Console lists every check with your value and the expected one.
  4. Edit HW03.cs; the other files are given.

The Unity files compile against a stand-in for the UnityEngine API and pass their checks with the reference solution, but they are new this quarter and have not yet been opened in the Unity editor. If one does not compile in 6000.3.11f1, post the error on the Canvas board and use the WebGL track meanwhile.

Submitting and grading

Grading runs your functions twice: on the published inputs above and on a second set of inputs that is not published. A check earns its points only when your value is within its tolerance on both, so the numbers have to come from the math. The rubric score is the sum of the points earned, out of 100; it counts as 25 course points (the rubric score divided by 4). A submission that does not load or compile earns no check points. Name any collaborators and tools in the submission comment.

Late tokens. You have two for the quarter. Declare one in the submission comment to extend this homework by 48 hours without penalty. Without a token, late work is not accepted, and nothing is accepted after Friday, December 11.