Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and.

Similar presentations


Presentation on theme: "CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and."— Presentation transcript:

1 CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and staff of CS 123 Spring 2008 to reproduce these notes for their own use.

2 Calendar ActivityDue Date Lab 1Week 2Week 3 Quiz 1Week 3 Lab 2Week 4Week 5 Quiz 2Week 5 Lab 3Week 6Week 7 (16 th May- 5P.M) Quiz 3Start : 10 th MayWeek 7 (16 th May- 5P.M) Lab 4Week 8Week 9 Quiz 4Week 9 Lab exam (in class)Week 10

3 Important Note about Today’s Lab 1)You are required to work in a group 2)You don't get credit for the lab until you show a TA or instructor your results from the end of the lab. You can do this at the end of the lab period, or by dropping into the Cyber Learning Center next week. If you do not get "checked in" by a staff member, then you will receive no credit for this lab even if you attended a Lab session

4 So, What is today’s Lab about? Animating with maple : use “animate” command to create maple simulations We will simulate cannon simulation and the “Blammo” game

5 One dimensional motion Assuming we have 1 dimensional motion: Velocity: v(t) = -gt + v(0) Displacement: y(t) = int(-gt + v(0)) dt = -1/2gt^2+v(0) t + D

6 Let’s look at maple code: > a := -32; # feet/second^2; > v := int(a, t) + v0; > y := int(v, t); > tpeak := solve(v=0, t); # time to reach peak > ymax := eval(y, t=tpeak); # height of peak > soln := solve(y=0, t); # times when on the ground > tmax := max(soln); # select later time > tmax := simplify(tmax, assume=positive); # assume v0 > 0 to simplify > tmax = 2*tpeak; # confirm Animate : animate(pointplot, [[0,y]], t=0..tmax, symbolsize=20); Maple Simulation of one dimensional motion:

7 2 New Maple commands: 1) Animate : -what does it do? > create a 2-D or 3-D animation on one parameter -How to use it? > animate(plotcommand, plotargs, t=a..b, options) Example: : animate(pointplot, [[0,y]], t=0..tmax, symbolsize=20); 2) Evalb : - what does it do ? Evaluates a Boolean Expression -how to use it ? Evalb(x) example : >evalb(evalf(sqrt(5))>2); True Wh\

8 Using Defined Procedures to make a game! Let’s take a closer look at defined procedures and how we can use them: 1)VerticalPosition : checks if the disk hits the bell / derive the equations 1)VerticalPosition:=proc(t,v0,h) 2)MaxTime determines the time when the disk returns to the ground 1)MaxTime := proc(v0, h) 3)PlayGame: Given the initial velocity v0 of the disk and the height h of the bell, procedure PlayGame uses the animate command to simulate the hit- the-bell game. 1)PlayGame:= proc(v0, h)

9 Two Dimensional Motion: h x(t) = V0x * t y(t) = y0 + V0y*t -1/2g*t^2

10 Same approach as 1 dim- Code up procedures on yourself! Procedures you need to write: 1) HitsNet(initial velocity, angle (measured in radians) distance to net, size of net) which returns true if Blammo lands on any part of the net and returns false otherwise. 2) XYPosition(time, initial velocity, angle) which returns a list with two elements, namely expressions for the x and y coordinates of the position of Blammo at time t : USE PREVIOUS EQ! 3) MaxTime(initial velocity, angle) which returns the time when Blammo hits the ground Y = 0, X = X final = R 4) ShootCannon(initial velocity, angle, distance to net, size of net) which creates an animation of Blammo being shot from the cannon towards the net. USE PREVIOUSE FUNCTIONS + ANIMATE

11 Parametric Curves in Maple We can plot curves in Maple using PLOT command: plot([x(t), y(t), t=range of t], h, v, options) [x,y,range] - parametric specifications h - horizontal range v - vertical range Example: >plot([(t^2-1)/(t^2+1), 2*t/(t^2+1), t=-infinity..infinity]);

12 What if we have wind resistance ? Let’s consider the case of having resistance: Basic idea : Acceleration is changed : F=M.A How we use it? -Vx-wind, x-wind -Vy-wind, y-wind

13

14 Use Procedures/function to simulate Blammo with/out resistance!

15 Lab structure This lab is divided into the following sections: Required Reading: Introduction & Overview, Tutorials 1-5, Wrap-Up Required Problems: Problems 1-5 Optional Problems: Problems 6,7 Work in groups as always !! Do not forget to CHECK IN !

16 What to turn in?! Lab 3  Due May 16 th,5 P.M Quiz 3  Due May 16 th,5 P.M -Submit your lab via Bb Vista -We have office hours in UC145 next week, if you had any problem in Quiz 2 feel free to stop by and ask questions! Good Luck!


Download ppt "CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and."

Similar presentations


Ads by Google