CS488 PA7
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Rasterizer3D Class Reference

#include <Rasterizer3D.h>

Public Member Functions

 Rasterizer3D (FrameBuffer *fb)
 
 ~Rasterizer3D ()
 
void clear (const Color &color)
 
void draw (list< Triangle *> triangles)
 
void useDimetricView (double phi)
 
void useIsometricView ()
 
void useThreePointPerspectiveView (double d, double tx, double ty, double tz, double phi, double theta)
 
void useTrimetricView (double phi, double theta)
 
void useTwoPointPerspectiveView (double d, double ty, double tz, double theta)
 

Private Member Functions

void drawTriangle (Color color, Matrix< 4, 3 > triangle)
 
void updatePerspectiveMatrix (double d)
 
void updateRotationXMatrix (double sinPhi, double cosPhi)
 
void updateRotationXMatrix (double phi)
 
void updateRotationYMatrix (double sinTheta, double cosTheta)
 
void updateRotationYMatrix (double theta)
 
void updateTranslationMatrix (double tx, double ty, double tz)
 

Private Attributes

double height
 
double width
 
Matrix< 2, 4 > downsize
 
Matrix< 4, 4 > perspective
 
Matrix< 4, 4 > projection
 
Matrix< 4, 4 > rotationX
 
Matrix< 4, 4 > rotationY
 
Matrix< 4, 4 > translation
 
Rasterizer2D * rasterizer2D
 

Detailed Description

A Rasterizer3D object rasterizes three-dimensional objects.

Constructor & Destructor Documentation

◆ Rasterizer3D()

Rasterizer3D::Rasterizer3D ( FrameBuffer *  fb)
explicit

Explicit Value Constructor.

Parameters
fbThe FrameBuffer containing the pixels

◆ ~Rasterizer3D()

Rasterizer3D::~Rasterizer3D ( )

Destructor.

Member Function Documentation

◆ clear()

void Rasterizer3D::clear ( const Color &  color)

Fill the entire FrameBuffer with the given color.

Parameters
colorThe color

◆ draw()

void Rasterizer3D::draw ( list< Triangle *>  triangles)

Draw a list of Triangle objects.

Parameters
trianglesThe Triangle objects

◆ drawTriangle()

void Rasterizer3D::drawTriangle ( Color  color,
Matrix< 4, 3 >  triangle 
)
private

Draw a single triangle.

Parameters
colorThe color to use
triangleThe triangle to draw

◆ updatePerspectiveMatrix()

void Rasterizer3D::updatePerspectiveMatrix ( double  d)
private

Update the perspective matrix.

Parameters
dThe parameter

◆ updateRotationXMatrix() [1/2]

void Rasterizer3D::updateRotationXMatrix ( double  sinPhi,
double  cosPhi 
)
private

Update the matrix for rotating around the x-axis.

Parameters
sinPhiThe sin of the rotation angle
cosPhiThe cos of the rotation angle

◆ updateRotationXMatrix() [2/2]

void Rasterizer3D::updateRotationXMatrix ( double  phi)
private

Update the matrix for rotating around the x-axis.

Parameters
phiThe rotation angle (in radians)

◆ updateRotationYMatrix() [1/2]

void Rasterizer3D::updateRotationYMatrix ( double  sinTheta,
double  cosTheta 
)
private

Update the matrix for rotating around the y-axis.

Parameters
sinThetaThe sin of the rotation angle
cosThetaThe cos of the rotation angle

◆ updateRotationYMatrix() [2/2]

void Rasterizer3D::updateRotationYMatrix ( double  theta)
private

Update the matrix for rotating around the y-axis.

Parameters
thetaThe rotation angle (in radians)

◆ updateTranslationMatrix()

void Rasterizer3D::updateTranslationMatrix ( double  tx,
double  ty,
double  tz 
)
private

Update the translation matrix.

Parameters
txThe size of the translation in the x-direction
tyThe size of the translation in the y-direction
tzThe size of the translation in the z-direction

◆ useDimetricView()

void Rasterizer3D::useDimetricView ( double  phi)

Instructs the rasterizer to use a dimetric view. Specifically, this method updates the two rotation matrices so that they are appropriate for a dimetric view.

Parameters
phiThe rotation around the x-axis (in radians)

◆ useIsometricView()

void Rasterizer3D::useIsometricView ( )

Instructs the rasterizer to use an isometric view. Specifically, this method updates the two rotation matrices so that they are appropriate for an isometric view.

◆ useThreePointPerspectiveView()

void Rasterizer3D::useThreePointPerspectiveView ( double  d,
double  tx,
double  ty,
double  tz,
double  phi,
double  theta 
)

Instructs the rasterizer to use a three-point perspective view. Specifically, this method updates the rotation and translation matrices so that they are appropriate for a three-point perspective view.

Parameters
dThe COP
txTranslation along the x-axis
tyTranslation along the y-axis
tzTranslation along the z-axis
phiRotation around the x-axis (in radians)
thetaRotation around the y-axis (in radians)

◆ useTrimetricView()

void Rasterizer3D::useTrimetricView ( double  phi,
double  theta 
)

Instructs the rasterizer to use a trimetric view. Specifically, this method updates the two rotation matrices so that they are appropriate for a trimetric view.

Parameters
phiRotation around the x-axis (in radians)
thetaRotation around the y-axis (in radians)

◆ useTwoPointPerspectiveView()

void Rasterizer3D::useTwoPointPerspectiveView ( double  d,
double  ty,
double  tz,
double  theta 
)

Instructs the rasterizer to use a two-point perspective view. Specifically, this method updates the rotation and translation matrices so that they are appropriate for a two-point perspective view.

Parameters
dThe COP
tyTranslation along the y-axis
tzTranslation along the z-axis
thetaRotation around the y-axis (in radians)

Member Data Documentation

◆ downsize

Matrix<2, 4> Rasterizer3D::downsize
private

An intermediate variable used to reduce the dimensionality of a triangle.

◆ height

double Rasterizer3D::height
private

The height of the raster (in pixels).

◆ perspective

Matrix<4, 4> Rasterizer3D::perspective
private

The perspective Matrix.

◆ projection

Matrix<4, 4> Rasterizer3D::projection
private

The projection Matrix.

◆ rasterizer2D

Rasterizer2D* Rasterizer3D::rasterizer2D
private

The Rasterizer2D to use.

◆ rotationX

Matrix<4, 4> Rasterizer3D::rotationX
private

The rotation around the x-axis Matrix.

◆ rotationY

Matrix<4, 4> Rasterizer3D::rotationY
private

The rotation around the y-axis Matrix.

◆ translation

Matrix<4, 4> Rasterizer3D::translation
private

The translation Matrix.

◆ width

double Rasterizer3D::width
private

The width of the raster (in pixels).


The documentation for this class was generated from the following files: