You are on page 1of 6

GSP 221 Week 1 iLab

For more classes visit


www.snaptutorial.com

GSP 221 Week 1 iLab


==================================================
GSP 221 Week 2 Homework Vectors
For more classes visit
www.snaptutorial.com

GSP 221 Week 2 Homework Vectors


==================================================
GSP 221 Week 2 iLab
For more classes visit
www.snaptutorial.com

GSP 221 Week 2 iLab

==================================================
GSP 221 Week 3 iLab
For more classes visit
www.snaptutorial.com

iLABOVERVIEW

Scenario/Summary
The first Lab taught us how to construct, translate, and render an object
as a set of points. In the second Lab, we were introduced to how vector
math is done in C++, with just a general reference to game objects.
In this third Lab, we finally put both concepts together, where we
represent our objects vertices through vectors and then use the vector
math we learned in Lab 2, control the position, velocity, and acceleration
of our game objects. The concepts of position, velocity, and acceleration
are studies under the branch of physics termed kinematics.
You will create a 2D triangle in which the vertices are represented by
vectors that can be translated using vector addition. You will then
simulate the triangle moving under the influence of acceleration and
then stopping when it collides with a vertical wall. You can simulate
gravity with a constant acceleration in the y direction (of -9.8 m/s if
you want to use meters as your units). To detect the moment of collision,
you will implement a parametric ray that intersects with a line.
Using Visual Studio and your code from Week 2, do the following:
Place the attached Triangle2D.h file in the Geometry project (see
below for the Handout link). This creates a Triangle2D class similar to
Triangle3D, except one replaces Point3D with Vector2D for the
representation of the vertices. This includes a constructor that takes three
Vector2D to define a triangle. This also has a Translate( Vector2D T )
method, and implements it using vector addition (it does not access the
individual coordinates).
Implement the .cpp file for Physics.h in the Handout and use it for
this lab. The only method that does anything interesting is dX() method,
which computes the next position of the triangle using the current
acceleration and the effect of gravity.
Implement Linear.cpp for Linear.h. This provides a Ray2D class
and a Line2D. Use these for collision detection between a Triangle2D
and a vertical wall near the right hand board of the window. Use a ray to
provide a geometric representation of the motion of the triangle. In
particular, define the ray.origin as the physics.Position() and
ray.direction as physics.Velocity(). Compute the intersection between
this ray and the line representing the wall. RayIntersect.t should be the
time it will take for the triangle to reach the wall if it were traveling in a
straight line; that is, if there is no gravity. When this t is < threshold,=""
where="" threshold="" is="" a="" constant="" you="" choose,=""
stop="" translating="" the="">
The equation for a ray can be written as P = O+Dt, where O is the origin
of the ray, D is the direction, t is a parameter that can take any value, and
P is the resulting point for a given value of t.
Two components of the object named ray: origin and direction:
Suppose one is given any fixed point P0 on a line and a vector N
perpendicular to the line. The equation of the line can be written as:
N dot ( P P0 ) = 0
P is another point on the line.
Three components of the object named line: point, normal and direction:
Setting the P in each equation equal to each other and solving the
simultaneous equations give the intersection point. With this notation,
the intersection of the ray with the line is:
t = (n dot P0 - N dot O) / ( N dot D )
Use this t in the ray equation O+D*t to produce the actual intersection
point, if needed. In this lab, only the t value is needed, since it represents
the time until impact.
Deliverables
1. See the Week 3 Lecture to understand the physics equations.
2. You will need the Week 2 iLab file. See the Week 2 iLab page if
you do not have it.
3. Download the three header files from the Week 3 iLab Handout zip
folder.
4. Note: Physics.h, Physics.cpp, Linear.h, and Linear.cpp go in the
Math project.
Triangle2D.h goes in the Geometry project.
5. Package your .cpp files in a zip file. Use the following naming
convention for your zip file:
GSP 221_LastnameFirstInitial_ Week3_Lab.zip.
6. Submit the zip file to the Dropbox for the Week 3 Lab Activity.
Submit your lab to the Dropbox located on the silver tab at the top of
this page. For instructions on how to use theDropbox, read these Step-
by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus/"Due Dates for Assignments & Exams" for due dates
==================================================
GSP 221 Week 4 Homework Assignment
For more classes visit
www.snaptutorial.com

GSP 221 Week 4 Homework Assignment


==================================================
GSP 221 Week 5 Homework Assignment
For more classes visit
www.snaptutorial.com

2D Scaling
Symmetric Scaling

(12 pts) Given the square below with the listed vertices, first formulate
a transformation matrix that scales it to make two times larger in both
dimensions. Next apply the transformation matrix to each vertex. Show
the new position of each vertex.

(12 pts) Again, take the square vertices listed below and apply a
formulated transformation matrix to scale it by 0.5 in the x-direction and
by 0.2 in the y-direction. Show the new position of each vertex. Then
apply a simple inverse matrix to undo the scaling that will return the
square back to its original vertices. Show the position of the vertices
after the transformation has been applied as well.

(12 pts) Take a triangle with the below listed vertices and create a
transformation matrix that will rotate it 180 degrees in the counter-
clockwise direction. Next, apply the transformation matrix to each
triangle vertex. List each vertexs new position. Then, apply a simple
inverse that will rotate it back to its original position. Show the position
of the vertices after the transformation has been applied as well.

(14 pts) For a square whose vertices are listed as below, form a
composite matrix that will translate it to the origin, rotate it by 180
degrees counter-clockwise, and then translate it back to its original
position. These transformations should be set up in a composite matrix.
You should consider the translation of the square back to its original
position as the simple inverse of the matrix that moved the square from
its original position to the origin. Apply the composite matrix to each of
the vertices listed below and then finally list each vertexs final (x,y)
coordinate value. Show the position of the vertices after the
transformation has been applied as well, verifying that each vertex has
been rotated by 180 degrees.
==================================================
GSP 221 Week 5 iLab
For more classes visit
www.snaptutorial.com

GSP 221 Week 5 iLab


==================================================
GSP 221 Week 7 iLab
For more classes visit
www.snaptutorial.com

GSP 221 Week 7 iLab

You might also like