<- back
hw0 (100 + 1 pts) upload to glow hw.pdf (math), hw.cpp* (code), and a comment
*your code should build and run as is; i should not have to make any edits to your code to verify it solves the assignment codebase & Github Issues (get homework help, report bugs, ask questions about lecture, etc.)
intended learning outcomes - get familiar with math pre-fundamentals - get acquainted with the external resource and collaboration policies (e.g., it is recommended you check final answers with friends) - get set up building and running the codebase on your computer of choice - get familiar with code pre-fundamentals - get practice submitting an assignment - challenge yourself

math reading - I use regular weight font to denote a scalar, e.g. real number $r$ and integer $N$. - I use bold lowercase to denote a points and vectors, e.g. point $\mathbf{p}$ and vector $\mathbf{v}$. - I use bold uppercase to denote a matrix, e.g. matrix $\mathbf{M}$. - Pythagorean Theorem: $a^2 + o^2 = h^2$. - soh cah toa: $sin(\theta) = o / h$, $cos(\theta) = a / h$, $tan(\theta) = o / a$ - A vector with $n$ entries is called an $n$-vector. - The transpose of vector $\mathbf{v}$ is denoted $\mathbf{v}^T$. - We can write a 3-vector in components as $$\mathbf{v} = \begin{bmatrix}v_x\\v_y\\v_z\end{bmatrix} = (v_x, v_y, v_z)^T,$$ i.e. as "a column vector" or as "the transpose of a row vector." - The cross product of two 3D vectors is $$\mathbf{a}\times \mathbf{b}=(a_y b_z-a_zb_y,a_zb_x-a_xb_z,a_xb_y-a_yb_x)^T,$$ which is a 3D vector. - The dot product of two 3D vectors is $$\mathbf{a}\cdot \mathbf{b}=\mathbf{a}^T\mathbf{b}=a_xb_x + a_yb_y + a_zb_z,$$ which is a scalar. - $\mathbf{M}_{ij}$ denotes the entry in $\mathbf{M}$'s $i$-th row and $j$-th column. In math, we will typically index starting at 1. In code, we will typically index starting at 0. An exception is MATLAB, which must be trying to be some sort of matrix laboratory. - An $R \times C$-matrix ("$R$ by $C$ matrix") has $R$ rows and $C$ columns. - An $R\times 1$ matrix is an $R$-vector. - Multiplying an $R\times K$-matrix by a $K\times C$-matrix yields an $R\times C$-matrix. In (my personal) shorthand, $$[R\times K][K\times C]=[R\times C]$$. - Matrix multuiplication $$(\mathbf{F}\mathbf{G})_{ij} = \sum_{k} \mathbf{F}_{ik} \mathbf{G}_{kj}.$$ It is understood $k\in\{1,...,N\},$ where $N$ is the number of columns in $\mathbf{F}$ (or, equivalently, the number of rows in $\mathbf{G}$).
math hw 1. (5 pts) what is $cos(-\theta)$ in terms of $cos(\theta)$? 2. (5 pts) what is $sin(-\theta)$ in terms of $sin(\theta)$? 3. (5 pts) prove $sin^2(\theta) + cos^2(\theta) = 1$. hint: draw a right triangle with hypotenuse of unit length (length equal to one) 4. (5 pts) what is the result of rotating point $\mathbf{p} = (x, 0)^T$ counter-clockwise by $\theta$ about the origin? 5. (5 pts) what is the result of rotating point $\mathbf{p} = (0, y)^T$ counter-clockwise by $\theta$ about the origin? 6. (5 pts) call $\mathbf{v}$ the vector pointing from point $\mathbf{p}$ to point $\mathbf{q}$. what is $\mathbf{v}$ in terms of $\mathbf{p}$ and $\mathbf{q}$? 7. (5 pts) calculate $\begin{bmatrix} 1 \\ 0 \\ 0\end{bmatrix} \times \begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}$ 8. (5 pts) calculate $\begin{bmatrix} 1 \\ 0\\0\end{bmatrix} \cdot \begin{bmatrix} 0 \\ 1\\0 \end{bmatrix}$ 9. (5 pts) calculate $\begin{bmatrix} 1&2 \\ 3&4 \end{bmatrix}\begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}$ 10. (5 pts) calculate $\begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix}\begin{bmatrix} 5 \\ 7 \end{bmatrix}$

code reading - documentation is in hw.cpp. - the syntax for a basic C++ for loop is: for (int i = 0; i < N; ++i) { // do stuff }
code hw a. (25 pts) hw() currently draws the outline of a white triangle. make it instead draw the outline of a red square, centered at the origin, with side length 3. b. (25 pts) make hw0() also draw the outline of a green circle circumscribing the red square. hint: use another call to gl_begin(LINE_LOOP);. ⭐. (1 pt extra credit) draw a 6th step Sierpiński carpet inside of the red sqaure using exactly one additional call to gl_begin(...); and gl_end(); (plus as many calls to gl_vertex(x, y); as you want).
to fullscreen videos press f after pressing play
🐄