This commit is contained in:
Michael Zhang 2023-05-01 01:05:04 -05:00
parent 6efa4a0075
commit fd36b2aec2
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
2 changed files with 170 additions and 5 deletions

View file

@ -14,6 +14,8 @@ author: |
\newcommand{\now}[1]{\textcolor{blue}{#1}}
\newcommand{\todo}[0]{\textcolor{red}{\textbf{TODO}}}
[ 1 2 3 4 6 7 8 9 10 ]
## Reflection and Refraction
1. \c{Consider a sphere $S$ made of solid glass ($\eta$ = 1.5) that has radius $r =
@ -33,7 +35,7 @@ author: |
b. \c{(1 points) What is the angle of reflection $\theta_r$?}
The angle of reflection always equals the angle of incidence, $\theta_r =
\theta_i = \boxed{cos^{-1}(-\frac{1}{3})}$.
\theta_i = \boxed{\cos^{-1}(-\frac{1}{3})}$.
c. \c{(3 points) What is the direction of the reflected ray?}
@ -62,6 +64,27 @@ author: |
e. \c{(4 points) What is the direction of the transmitted ray?}
We can just add the angle obtained above to the inverse of the normal $n' =
(-1, 2, -2)$ (since that will be transmitted through the material). For the
tangent direction, we can use the vector from the ray's origin to the
incident ray projected onto the normal, which we'll call $v = (0, 6, 6)$.
Now we know that the relationship between the coefficients of $n'$ and $v$ is
$\tan(\theta_t)$. We can add these to obtain a point along the transmitted
ray (it doesn't actually matter where this occurs since we're going to
normalize this anyway, the proportion stays consistent regardless). So using
the unit length for the inverse normal which is $\frac{n'}{||n'||} =
(\frac{1}{3}, -\frac{2}{3}, \frac{2}{3})$ we know that the perpendicular
vector will be $\tan(\theta_t) \times (0, \frac{1}{\sqrt{2}},
\frac{1}{\sqrt{2}})$.
The final step is then adding these vectors together and subtracting the
interersection point: $(\frac{1}{3}, -\frac{2}{3}, \frac{2}{3}) +
\tan(\theta_t) \times (0, \frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}) - (1, 4,
8)$.
\todo all the numbers are wrong
## Geometric Transformations
2. \c{(8 points) Consider the airplane model below, defined in object
@ -72,7 +95,26 @@ author: |
at the location $p = (4, 4, 7)$, with a direction of flight $w = (2, 1, -2)$
and the wings aligned with the direction $d = (-2, 2, -1)$.}
The translation matrix is
The order we want is (1) do all the rotations, and then (2) translate to the
spot we want. The rotation is done in multiple steps:
- First we want to make sure the nose of the plane points in the correct
direction in the $xz$ plane (rotating around the $y$ axis). The desired
resulting direction is $(2, y, -2)$, so that means for a nose currently facing
the $+z$ direction which is $(0, y, 1)$, we want to rotate around by around
$-\frac{3}{4}\pi$. The transformation matrix is:
$$
M_1 = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
\end{bmatrix}
$$
- Then we want to rotate the plane vertically, so it's pointing in the right
direction.
$$
\begin{bmatrix}
@ -93,7 +135,56 @@ author: |
Since the direction of flight was originally $(0, 0, 1)$, we have to
transform it to $(2, 1, -2)$.
3.
3. \c{Consider the earth model shown below, which is defined in object
coordinates with its center at $(0, 0, 0)$, the vertical axis through the
north pole aligned with the direction $(0, 1, 0)$, and a horizontal plane
through the equator that is spanned by the axes $(1, 0, 0)$ and $(0, 0, 1)$.}
a. \c{(3 points) What model transformation matrix could you use to tilt the
vertical axis of the globe by $23.5^\circ$ away from $(0, 1, 0)$, to achieve
the pose shown in the image on the right?}
You could use a 3D rotation matrix. Since the axis of rotation is the
$z$-axis, the rotation matrix would look like:
$$
M =
\begin{bmatrix}
\cos(23.5^\circ) & \sin(23.5^\circ) & 0 & 0 \\
-\sin(23.5^\circ) & \cos(23.5^\circ) & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
\end{bmatrix}
$$
b. \c{(5 points) What series of rotation matrices could you apply to the
globe model to make it spin about its tilted axis of rotation, as suggested
in the image on the right?}
One way would be to rotate it back to its normal orientation, apply the spin
by whatever angle $\theta(t)$ it was spinning at at time $t$, and then put it
back into its $23.5^\circ$ orientation. This rotation is done around the
$y$-axis, so the matrix looks like:
$$
M' =
M^{-1}
\begin{bmatrix}
\cos(\theta(t)) & 0 & \sin(\theta(t)) & 0 \\
0 & 1 & 0 & 0 \\
-\sin(\theta(t)) & 0 & \cos(\theta(t)) & 0 \\
0 & 0 & 0 & 1 \\
\end{bmatrix}
M
$$
c. \c{[5 points extra credit] What series of rotation matrices could you use
to send the tilted, spinning globe model on a circular orbit of radius $r$
around the point $(0, 0, 0)$ within the $xz$ plane, as illustrated below?}
In the image, the globe itself does not rotate, but I'm going to assume it
revolves around the sun at a different angle $\phi(t)$. The solution here
would be to
## The Camera/Viewing Transformation
@ -253,7 +344,39 @@ author: |
## The Projection Transformation
6.
6. \c{Consider a cube of width $2\sqrt{3}$ centered at the point $(0, 0,
-3\sqrt{3})$, whose faces are colored light grey on the top and bottom $(y =
\pm\sqrt{3})$, dark grey on the front and back $(z = -2\sqrt{3} \textrm{and}
z = -4\sqrt{3})$, red on the right $(x = \sqrt{3})$, and green on the left $(x
= -\sqrt{3})$.}
a. \c{Show how you could project the vertices of this cube to the plane $z =
0$ using an orthographic parallel projection:}
i) \c{(2 points) Where will the six vertex locations be after such a
projection, omitting the normalization step?}
ii) \c{(1 points) Sketch the result, being as accurate as possible and
labeling the colors of each of the visible faces.}
iii) \c{(2 points) Show how you could achieve this transformation using one or
more matrix multiplication operations. Specify the matrix entries you would
use, and, if using multiple matrices, the order in which they would be
multiplied.}
b. Show how you could project the vertices of this cube to the plane $z = 0$
using an oblique parallel projection in the direction $d = (1, 0, \sqrt{3})$:
i) (3 points) Where will the six vertex locations be after such a projection,
omitting the normalization step?
ii) (2 points) Sketch the result, being as accurate as possible and labeling
the colors of each of the visible faces.
iii) (4 points) Show how you could achieve this transformation using one or
more matrix multiplication operations. Specify the matrix entries you would
use, and, if using multiple matrices, the order in which they would be
multiplied.
7.
@ -300,6 +423,8 @@ author: |
\end{bmatrix}}
$$
\todo the numbers are wrong lmao
b. \c{(3 points) How should be matrix $P$ be re-defined if the viewing window
is re-sized to be twice as tall as it is wide?}
@ -369,6 +494,36 @@ author: |
but you should not omit any steps that are essential to the process of
generating an image of a provided list of triangles.}
The most essential steps in the scan-conversion process are:
- First, the input is given as a bunch of geometries. This includes
triangles and quads. Spheres aren't really part of the primitives, not
sure why historically but I can imagine it makes operations like
clipping monstrously more complex.
- Then, vertices of the geometries are passed to vertex shaders, which are
custom user-defined scripts that are run in parallel on graphics hardware
that are applied to each individual vertex. This includes things like
transforming it through coordinate systems (world coordinates vs. camera
coordinates vs. normalized coordinates) in order for the rasterizer
to be able to go through and process all of the geometries quickly.
- Clipping is done as an optimization to reduce the amount of things outside
the viewport that needs to be rendered. There are different clipping
algorithms available, but they all typically break down triangles into
smaller pieces that are all contained within the viewport. Culling is also
done to remove faces that aren't visible and thus don't need to be
rendered.
- The rasterizer then goes through and gives pixels colors based on which
geometries contain them. This includes determining which geometries are in
front of others, usually done using a z-buffer. When a z-buffer is used,
the color of the closest object is stored and picked. During this process,
fragment shaders also influence the output. Fragment shaders are also
custom user-defined programs running on graphics hardware, and can modify
things like what color is getting output or the order of the depth buffer
based on various input factors.
12. \c{(6 points) Compare and contrast the process of generating an image of a
scene using ray tracing versus scan conversion. Include a discussion of
outcomes that can be achieved using a ray tracing approach but not using a

View file

@ -33,7 +33,17 @@ def problem_1():
sin_theta_i = np.sin(np.arccos(cos_theta_i))
print("sin theta_i =", sin_theta_i)
print("approx answer for part d", np.arcsin(1.0 / 1.5 * sin_theta_i))
theta_t = np.arcsin(1.0 / 1.5 * sin_theta_i)
print("approx answer for part d", theta_t)
uin = unit(n_norm)
print("unit inv normal", uin)
uperp = unit(v2)
print("uperp", uperp)
answer_1e = uin + math.tan(theta_t) * uperp - p
print("1e answer", unit(answer_1e))
def problem_4():
print("part 4a.")