Matrix
and Vector
classes/templates
from programming assignment 2 in a 2-D rasterizer
(and supporting classes). Specifically, you must write a
Geometry
template and a Rasterizer2D
class.
Matrix
and
Vector
classes/templates. Hence, you should not have to
copy them -- you should just be able to #include
them
from the appropriate directory/folder.
The first is a simple struct
that encapsulates RGB colors.
It should be self-explanatory.
Color ( Header )
The second is a simple (and not robust) encapsulation of a window
that uses SDL. Note that, depending on your envrionment you may need
to change the #include
for SDL. Hopefully, you will not need
to make changes to this class (it has been used with all majors OSs),
but you should feel free to make changes if necessary.
GraphicsWindow ( Header , Implementation )
The third is a simple (and not robust) encapsulation of a frame
buffer that uses SDL. It uses traditional Euclidean coordinates with
the origin of the coordinate system in the middle of the
GraphicsWindow. Most importantly, it provides the ability to set the
color of individual pixels. Because of slight differences between the way
SDL works under different OSs, there are some lines that need to be
commented-out/included for different OSs. This should be apparent
from the source code. Also, depending on your envrionment you may need
to change the #include
for SDL. Hopefully, you will not need
to make major changes to this class (it has been used with all majors OSs),
but you should feel free to make changes if necessary.
FrameBuffer ( Header , Implementation )
Geometry
template and the Rasterizer2D
classes are available on-line:
Be careful about the dimensionality of the functions in the
Geometry
template. Even though this assignment is about
2-D rasterization, some of the functions in this template are
N-dimensional. Also, note that you may not need to use all of the methods
in the Geometry
template in your Rasterizer2D
.
Determining which you need and which you don't should help you
assess your understanding of the material.
FrameBuffer
You must also create "visual" unit tests for all methods that do use the
FrameBuffer
class (i.e., unit tests that you can verify
by looking at the FrameBuffer
). While one could create
an alternative headless (i.e., off-screen) FrameBuffer
class for automated testing, that is beyond the scope of this course.
At a minimum, you must test:
The output from this test must look like the following:
Note that, while this image looks 3-D, it does not involve any 3D rasterization techniques.
Geometry
template could have been designed in a variety
of different ways. You might want to think about the following questions:
Matrix
objects could, instead, have been
Vector
objects? Should they have been?area()
, inside()
, and
toImplict()
are templated so that they are
one-to-one with Matrix
. What would happen if they
weren't?inside()
is passed three "vectors" containing the
vertices rather than a single Matrix
. Would it be
better to pass a Matrix
?Copyright 2014