Computer Graphics Solutions
Computer Graphics Solutions
Exercise 2
Question 2.1
Given two nonparallel, three-dimensional
vectors and , how can we form an
orthogonal coordinate system in which is one
of the basis vectors?
Create basis vectors using and
.
Solution 2.1 (1/9)
We can create orthogonal coordinates easily
by using cross product:
Vector is now orthogonal to both and .
However, and are not necessarily orthogonal.
We need third vector that is orthogonal
to both and .
Now , and form an orthogonal coordinate
system.
Solution 2.1 (2/9)
Calculating cross product using two 3D vectors
Solution 2.1 (3/9)
Calculating cross product using two 3D vectors
Solution 2.1 (4/9)
Calculating cross product using two 3D vectors
Solution 2.1 (5/9)
Calculating cross product using two 3D vectors
Solution 2.1 (6/9)
Calculating cross product using two 3D vectors
Solution 2.1 (7/9)
Calculating cross product using two 3D vectors
Solution 2.1 (8/9)
With and
Solution 2.1 (9/9)
We can also check the results by verifying that
dot product between each result pair is zero:
Question 2.2
We can specify an affine transformation by
considering the location of a small number of
points both before and after these points have
been transformed. In three dimensions, how
many points must we consider to specify the
transformation uniquely? How does the
required number of points change when we
work in two dimensions?
Solution 2.2 (1/3)
There are 12 degrees of freedom in the three-
dimensional affine transformation.
Suppose a point that we are
transforming to point by the
matrix using relationship .
Solution 2.2 (2/3)
We have 12 unknown coefficients in and we
get 3 equations for each pair of and
We need at least 12 / 3 = 4 pairs of matching
points to solve the 12 unknown variables.
Solution 2.2 (3/3)
In two dimensions, there are 6 unknown
variables
In two dimensions we get only two equations
per point (x and y coordinates)
Therefore we need 6 / 2 = 3 matching points.
Question 2.3
Start with a cube centered at the origin and
aligned with the coordinate axes. Find a
rotation matrix that will rotate the cube first
45 around y-axis and then 45 around z-axis.
Solution 2.3 (1/3)
Transformation order is from right to left. So
rotation around y-axis is on the right side of
the rotation matrix.
Solution 2.3 (2/3)
Rotation matrices for y and z axes
Solution 2.3 (3/3)
We are using 45 angles to rotate. That makes
calculations a bit easier
Question 2.4
Not all projections are planar geometric
projections. Give an example of a projection in
which the projection surface is not a plane,
and another in which the projections are not
lines.
Solution 2.4 (1/2)
Eclipses (both solar and lunar) are good
examples of the projection of an object (the
moon or the earth) onto a nonplanar surface.
Moon eclipses, derived from Phases_of_the_Moon.png in Wikimedia Commons by Miljoshi (Creative Commons Attribution 2.5 Generic)
Solution 2.4 (2/2)
All the maps in an atlas are examples of the use
of curved projectors. If the projectors were not
curved we could not project the entire surface of
a spherical object onto a rectangle.
Question 2.5
If we were to use orthogonal projections to
draw the coordinate axes, the x and y axes
would be like in the plane of the paper, but
the z axis would point out of the page.
Instead, we can draw the x and y axes as
meeting at a 90-degree angle, which the z axis
going off at -135 degrees from the x axis. Find
the matrix that projects the original
orthogonal-coordinate axes to this view.
Solution 2.5 (1/3)
Solution 2.5 (2/3)
We need to project where
and .
Z-axis is projected to the same plane with x
and y axes with a -135 degree angle from
positive x axis. is the length of the vector.
Solution 2.5 (3/3)
As was not given, we can choose
to get a simple looking projection matrix
Solution 2.5 (3/3)
As was not given, we can choose
to get a simple looking projection matrix
For 3-D -> 2-D projection,
erase this row
Question 2.6
Find the projection of a point onto the plane
from a light source located at
infinity shining to the direction .
Solution 2.6 (1/6)
Solution 2.6 (2/6)
All the projected points of the point to
the direction of are of form
. Thus, shadow of the
point is found by determining for
which the line intersects the plane
Solution 2.6 (3/6)
After solving the equation, we find
However, what we want is a projection matrix.
We can use the above value to solve
and the same for other dimensions.
Solution 2.6 (4/6)
Solution 2.6 (5/6)
And we can do the same for y and z
Solution 2.6 (6/6)
These results can be computed by multiplying
the homogenous coordinate point by
the projection matrix