{"id":217654,"date":"2018-09-15T23:01:19","date_gmt":"2018-09-15T23:01:19","guid":{"rendered":"http:\/\/localhost\/wordpress\/index.php\/2018\/09\/15\/gsp-221-week-3-ilab\/"},"modified":"2018-10-24T08:51:11","modified_gmt":"2018-10-24T08:51:11","slug":"gsp-221-week-3-ilab","status":"publish","type":"post","link":"https:\/\/www.benedictsol.com\/blogs\/gsp-221-week-3-ilab\/","title":{"rendered":"GSP 221 Week 3 iLab"},"content":{"rendered":"<p>i L A B O V E R V I E W\t\t\t\t\t\t\t\u00a0\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tScenario\/Summary\t\t\t\t\t\t\tThe\u00a0first\u00a0Lab taught us how to construct, translate, and render an object as a set of points. In the\u00a0second\u00a0Lab, we were introduced to how vector math is done in C++, with just a general reference to game objects.\tIn this\u00a0third\u00a0Lab, we finally put both concepts together, where we represent our object&#8217;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\u00a0kinematics.\tYou 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 &#8220;\ufffdy 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.\tUsing Visual Studio and your code from Week 2, do the following:\t\u00b7 \ufffd\u00a0\u00a0\u00a0 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).\t\u00b7 \ufffd\u00a0\u00a0\u00a0 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.\t\u00b7 \ufffd\u00a0\u00a0\u00a0 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=\"\">\tThe 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.\tTwo components of the object named\u00a0ray:\u00a0origin and direction:\tSuppose 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:\tN dot ( P &#8220;\ufffd P0 ) = 0\tP is another point on the line.\tThree components of the object named\u00a0line: point, normal and direction:\tSetting 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:\tt = (n dot P0 &#8211; N dot O) \/ ( N dot D )\tUse 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.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tDeliverables\t\t\t\t\t\t\t1.\u00a0\u00a0\u00a0 See the Week 3 Lecture to understand the physics equations.\t2.\u00a0\u00a0\u00a0 You will need the Week 2 iLab file. See the Week 2 iLab page if you do not have it.\t3.\u00a0\u00a0\u00a0 Download the three header files from the\u00a0Week 3 iLab Handout zip folder.\t4.\u00a0\u00a0\u00a0 Note:\u00a0Physics.h, Physics.cpp, Linear.h, and Linear.cpp go in the Math project.\tTriangle2D.h goes in the Geometry project.\t5.\u00a0\u00a0\u00a0 Package your .cpp files in a zip file. Use the following naming convention for your zip file:\tGSP 221_LastnameFirstInitial_ Week3_Lab.zip.\t6.\u00a0\u00a0\u00a0 Submit the zip file to the Dropbox for the Week 3 Lab Activity.\tSubmit 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\u00a0Step-by-Step Instructions\u00a0or watch this\u00a0Dropbox Tutorial.\tSee Syllabus\/&#8221;Due Dates for Assignments &#038; Exams&#8221; for due dates<\/p>\n","protected":false},"excerpt":{"rendered":"<p>i L A B O V E R V I E W \u00a0 Scenario\/Summary The\u00a0first\u00a0Lab taught us how to construct, translate, and render an object as a set of points. In the\u00a0second\u00a0Lab, we were introduced to how vector math is <a href=\"https:\/\/www.benedictsol.com\/blogs\/gsp-221-week-3-ilab\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-217654","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/217654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/comments?post=217654"}],"version-history":[{"count":0,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/217654\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/media?parent=217654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/categories?post=217654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/tags?post=217654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}