i L A B O V E R V I E W 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 object’s 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
Previous answers to this question
This is a preview of an assignment submitted on our website by a student. If you need help with this question or any assignment help, click on the order button below and get started. We guarantee authentic, quality, 100% plagiarism free work or your money back.
Get The Answer