Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.

Similar presentations


Presentation on theme: "CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved."— Presentation transcript:

1 CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved. Permission is given to CS122 Summer 2011 staff and students to use and reproduce these notes for their own use.

2 11/06/09 Review of Lab 3 Cycle – cs122 Major Lab 3 concepts to remember Use of “for”, “while” loops and “if” statements to solve a variety of firing angle analyses

3 11/06/09 Review of Lab 2 Cycle – cs122 drawBoxB function syntax: – drawBoxB:=(width, height, xlo, ylo,c)  display([line([xlo,ylo],[xlo+width,ylo],color=c), line([xlo+width,ylo],[xlo+width,ylo+height],color=c), line([xlo,ylo],[xlo,ylo+height],color=c), line([xlo,ylo+height],[xlo+width,ylo+height],color=c)], axes=none, scaling=constrained); Need in Lab 4 for movement of particle in box exercises

4 11/06/09 Review of Lab 3 Cycle – cs122 Blammo trajectory analyses – why we used “for”, “while” and “if” – 1.1 – Compute distance traveled for a variety of firing angles for angle from 30 to 75 do – Simple “for” loop to cover integer range of angles – 1.2 – Find smallest angle that hits target for angle from 10 to 90 while (abs(distance-targetdist) >tol)) do – “for” loop defines overall set of angle to consider – “while” loop will stop the computations the 1 st time an angle produces a distance that hits target – 1.3 – Print all firing angles that produce a target hit for angle from 10 to 89 do if (abs(distance-target) <tol) then printf (…….); end if; a.Must compute for all angles, since multiple angles can produce the desired result b.Will only print out statistics for the angles that produce a hit on target

5 11/06/09 Review of Lab 3 cycle – cs123 Overview of calculus features in Maple – Optimization – finding the min or max of an objective function over a range for the independent variable – eg. minimum surface area of a can – Integration and differentiation – area of an irregularly shaped object Note use of piecewise expressions to define shape of object – Spline curve fitting – for a variety of degrees Power versus time – integrate  total energy generated

6 Administrative Notes Remaining activities for term Quiz 4 – Tuesday through Friday Use Wednesday session to take quiz Practice for Proficiency Exam Quizzes and quizlets from term will be released on Tuesday and will remain open until 8/22 – 2 PM. If you contact the instructor prior to 2 PM on 8/22 with specific quiz and problem numbers, you may complete quiz questions you did not answer on the original quizzes (maximum of 2 questions per student). Proficiency exam – Monday, August 22nd

7 Proficiency Exam Information Summer 2011

8 Proficiency Exam In class exam, during regular class hours (Monday, 8/22)‏ The exam counts for 36% of your final grade

9 Proficiency Exam For the exam, you will do two tests in Maple TA. One quiz will have How did I do? turned on (9 points). One part (6 points) will have it turned off. The part where it is turned off will be the multiple choice or similar questions where getting feedback would make the question useless from an evaluation viewpoint.

10 Proficiency Exam Questions for the exam will be drawn from past quizzes, and from a small set of new questions. This means that everyone will know what the questions could be, ahead of time. They will also be able to prepare a plan for answering them, ahead of time.

11 Practicing All questions will be posted on Maple TA in practice form starting Tuesday, August 16th and running through the exam period (8/22 until 2 PM). For exam security, we will turn off access to the practice quizzes while exams are being run in the labs.

12 Exam Security During the exam You must use the laptop (be it Mac or Windows) provided. You may not use your own computer. You may use Maple Maple TA Browse cs.drexel.edu/complab/cs123/summer2010 cs.drexel.edu/complab/cs122/summer2011B which have copies of the lab directions and lecture notes. No notes or other aids

13 Exam security Computer usage will be monitored, both by visual checks by course staff and by software monitoring built into the computers you use. Unlike the labs, we will be in full “Big Brother” mode during the exam: We will be able to watch what you do, log every key stroke and mouse click, and take movies and screenshots of what you are doing.

14 A reminder about cheating Unauthorized access to information for the exam will be a violation of the Academic Honesty policy. So will accessing unauthorized information non- electronically or any other form of cheating. The minimum penalty will be a reduction in the final grade for the course. We reserve the right to give you a course grade of F with no opportunity to withdraw, or to begin proceedings to expel you from the university. If you have concerns about your grade for the course, talk to your instructor.

15 Proficiency Exam Policy If you have a conflict or are unable to attend the scheduled exam due to a reasonable medical or personal excuse, you should contact your section instructor and arrange an alternative time as soon as possible. If you miss your exam and delay contacting your instructor until after the proficiency exam has passed, our policy will be to give you a zero for the exam.

16 Quiz 4 Activities Quiz 4 will be released on Tuesday (8/16) at 9 AM – Deadline: Friday (8/19) at 5 PM – Attend Wednesday session to try quiz with TA support No Pre-lab quizlet – this is the last lab of the term Proficiency Exam Scheduled for Monday, August 22 nd at 4 PM Practice exams (previous quizzes, quizlets and some extra problems) will be released on Tuesday

17 11/06/09 Lab 4 Overview – cs122 Based on materials from Chapter 15, 16 and 17 readings – Chapter 17 – the purpose of variables used in loops (new) – Chapter 15 – More on repetition and looping (review) “while” loop – conditional looping + relational operators Combining “for” and “while” loops Dealing with runaway (infinite) “while” loops – Chapter 16 – Conditional execution (review) Choosing alternatives – if.. then.. else.. elif constructs

18 11/06/09 Lab 4 Overview – cs122 Lab 4 outline – Part 0 exercises Practice on “if”, “if-else” and “if-elif-else” constructs – Part 1 – particle movement in box 1.1 – using the drawboxB function from Lab 2 to animate the bouncing of a particle off of the East wall of a box 1.2 - revising script from 1.1 (drawBoxB + East wall bounce) to handle bounce off of West wall 1.3 – adding logic to bounce off of North and South walls 1.4 – simulating diagonal movement and movement within a box of smaller dimensions

19 11/06/09 Lab 4 Overview – cs122 Lab 4 outline – Part 2 – Movement of a bouncing ball 2.1 – modification of a starter script (Blammo trajectory logic) to create an initial trajectory into ground 2.2 – Further modification to produce bounces and rebounds off of ground 2.3 – Plot and movie to show a specified number of bounces

20 11/06/09 Lab 4 Maple Concepts: Discussion – cs122 Choosing among cases – if-then-elif-else-end – if (condition1) then Code to execute if condition1 is true – elif (condition2) then Execute if condition2 is true Note – only can reach here if condition 1 was false – elif (condition3) then if condition 3 true (1 and 2 were false) – else “catch all” bucket – if all case conditions specified above were false – end if; East, West, North and South wall bounces for particle movement will utilize this construct See today’s Part 0 exercises for example and syntax

21 11/06/09 Lab 4 Maple Concepts: Discussion – cs122 Use of the ptpos (list) variable in Part 1 of today’s lab – ptpos is a list that represents a point in the X-Y grid with an x coordinate = x and y coordinate = y – For example, if the value of ptpos is the list [9,1], it indicates that the moving point is at the simulated coordinate (9,1) within the box. – To get the value of the x coordinate in the midst of the simulation, use the expression ptpos[1]. – To get the value of the y coordinate, use the expression ptpos[1].

22 11/06/09 Lab 4 Overview – cs123 Based on materials from Chapters 21 and 22 readings – Chapter 21 – Calculations that return true or false Use of boolean expressions with a programming API – Chapter 22 – Review of course goals and objectives

23 11/06/09 Lab 4 Overview – cs123 Lab 4 outline – 5 parts – Part 0 – introduction to software mechanics and features – Part 1 - move car in a square – Part 2 – bump car back and forth between 2 walls – Part 3 – find gap in a wall and proceed to target – Part 4 – find the nth gap in a wall and proceed to target

24 11/06/09 Lab 4 Maple Concepts Discussion and Demo – cs123 Application Programming Interfaces (APIs) – An industry standard term for a package of procedures that simplifies the process of writing code for a particular purpose – An API usually provides a set of functions (user interfaces) to create applications – Maple provides an API for many common mathematical and computation tasks Plotting, calculus, trigonometric functions – Why they are important Entire courses on software design and reusability Bottom line – give programmers a way of easily writing code for a particular platform Encourages rapid development, saves work

25 11/06/09 Lab 4 Maple Concepts: Discussion and Demo – cs123 Car Simulator API – An API written by the course staff that enables you to animate and simulate car movement in conjunctions with walls, barriers, etc. – This simulator ignores forces of friction, focusing on the logic of controlling the (directional) movement of a car

26 11/06/09 Lab 4 Maple Concepts: Discussion – cs123 Car Simulator API – 4 key functions available – move(x) Moves the car forward (in the direction it is currently pointed) x squares – Turn(d) Turns the car d radians to the left Turn (Pi/2) makes the car turn directly to the left Turn (-Pi/2) makes the car turn directly to the right The turn is always relative to the current direction of the car – isTouching(d,’stateOfCar’) Returns “true” if the car is touching some object in the direction d radians above (PI/2), left(Pi), below(-PI/2) or right (0) Direction d is always absolute in terms of the X-Y axis It is OK to use ‘bt’ for ‘stateOfCar’

27 11/06/09 Lab 4 Maple Concepts: Discussion – cs123 Car Simulator API – 4 key functions available – getCURRENTLOCATION() Get the current state of the car, which is a list with: [x, y, dir, state] [2, 0, 0, CarSimulation:-CARNORMAL]

28 11/06/09 Lab 4 Maple Concepts: Discussion and Demo – cs123 Car Simulator API – flow of lab – There are 4 sections to Part 0 (each contained in it’s own work sheet) and 4 problem work sheets associated with Parts 1, 2, 3 and 4 – You must open and perform the tasks for each of these work sheets in the order presented in the lab description – It is especially critical to 1 st open and run the Part 0 tutorials. It loads the Car Simulator API software that is needed throughout these exercises

29 11/06/09 Lab 4 Maple Concepts: Discussion – cs123 Part 0 exercises – 1 st copy the zipped file from the course site and then unzip (MAC may automatically unzip for you) – Open the Maple worksheets from the unzipped files as per the lab description instructions – Follow the directions in each work sheet - study the logic in each code edit region, run the code and review the output – Note that some regions produce an animation of the car’s movement


Download ppt "CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved."

Similar presentations


Ads by Google