## Phineas & Ferb

### Activity Information

#### Learning Goals

• Apply the principles of constant velocity and uniformly accelerated motion in 1D ( HS-PS2-1)
• Create and modify computational models to describe/show a given system

#### Prior Knowledge Required

• 1-Dimensional Kinematics
• The relationship between position, distance, displacement, speed, and velocity
• Position vs. time and velocity vs. time graphs
• Scalar and vector quantities

#### Code Manipulation

• Copying/pasting code
• Creatng/using while loops
• Converting mathematical equations into code
• Creating graphs using code

—-

### Activity

#### Handout

Phineas & Ferb

Phineas and Ferb just invented hovercraft skateboards, and Candace, being Candace, needs to take of picture of them to prove, once and for all to their mom, that Phineas and Ferb are still up to their crazy and dangerous shenanigans. Candace sees Phineas and Ferb riding their hoverboards 20 meters behind her, travelling at a constant velocity. She realizes that this is her opportunity; it takes her 20 seconds to grab her camera, bag, and hop on her electric scooter to chase them. She starts from rest and continues (miraculously) with constant acceleration.

1. Assuming Phineas and Ferb are travelling at 4 meters per second and Candace's scooter is capable of accelerating at 2 meters per second per second, where and when will Candace be able to take a photo of the boys?
2. What will Candace's final velocity be?
3. Use the “print” function to show the following:
1. Phineas, Ferb, and Candace's final position
2. Phineas and Ferb's final velocity
3. Candace's final velocity
4. Candace's acceleration
5. Final time

#### Code

GlowScript 2.7 VPythonget_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js')#Window setupscene.width = 800scene.height = 150scene.center = vec(50,5,0)scene.background = color.white*0.5 #Objects (DO NOT ALTER THESE)floor = box(pos=vector(50,0,0), size=vec(160,1,2))P_F = box(pos=vector(-20,5,0), size=vec(10,9,2), shininess=0, texture="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/35ed113d-7deb-48b6-ae95-3ec3e049e23c/dcnmrib-7cc0dedb-e2d9-471a-8d5e-8f1634228201.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzM1ZWQxMTNkLTdkZWItNDhiNi1hZTk1LTNlYzNlMDQ5ZTIzY1wvZGNubXJpYi03Y2MwZGVkYi1lMmQ5LTQ3MWEtOGQ1ZS04ZjE2MzQyMjgyMDEucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.0YjSs0Ccip92vyd7ngwzW8OhkWw3U8SLSK6O3Y19LT8") #Phineas and Ferb on their hoverboardCandace = box(pos=vector(0,5,0), size=vec(4,9,2.1), shininess=0, texture="https://vignette.wikia.nocookie.net/phineasandferb/images/8/82/Candace_Flynn2.png/revision/latest?cb=20110624122230") #Candace on her scooter #position labelsL_start= label(pos=floor.pos,  text='0', offset=0,   yoffset=-10, space=10,  height=16, border=4,  font='sans')L_P_F = label(pos=L_start.pos + vec(5,0,0),  text='5', offset=0,   yoffset=-10, space=10,  height=16, border=4,  font='sans') #Time for Candace to get her camerat_CandaceDelay = 20 #Parameters and Initial ConditionsP_F_v = vector(4,0,0)P_F_a = vector(0,0,0)Cand_v = vector(0,0,0)Cand_a = vector(2,0,0) #Time and time stept=0dt = 0.01 #MotionMaps for P_F and CandaceP_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False)Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan) #tells scene to wait for a click before while loop runs (DO NOT ALTER)scene.waitfor ('click') #Calculation Loops#Motion of P_F before Candace starts movingwhile t < t_CandaceDelay:   rate(500)     P_F_MotionMap.update(t, P_F.vel) #Update Phineas and Ferb MotionMap  #motion of P_F and Candace once Candace starts movingwhile t >= t_CandaceDelay:     rate(500)      P_F_MotionMap.update(t, P_F.vel)       Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap     if Candace.pos.x >= P_F.pos.x: #Stop the program       print_options(height=120) #Sets the height of our print box           label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False)      scene.pause()     t = t + dt

#### Handout

1. The process for determining where and when Candace will be able to take a photo of the boys (i.e. when Candace's position intersects with Phineas and Ferb's) starts by breaking the problem down into two parts: before and after Candace begins moving. If we define Candace as being at the origin ($x=0$), then we must first determine where Phineas and Ferb are once Candace gets on her scooter. To do this, we can use the following kinematic equation (which will helpful for the entire problem): $x=x_0 + vt + at^2$, where $x$ is current position, $x_0$ is initial position, $v$ is velocity, $a$ is acceleration, and $t$ is time. We know Phineas and Ferb start 20 m to the left of Candace, they are travelling at a constant velocity of 4 m/s, and it takes Candace 20 seconds to get on her scooter, therefore we can find where Phineas and Ferb are in relation to Candace: $x=-20 + 4(20) + 0(20)^2 = 60$. Phineas and Ferb are 60 m to the right of Candace when she starts her scooter. Next (similarly to the Head-On Collision and Rear-End Collision activities) we will create a system of equations describing the motion of Phineas and Ferb and Candace and solve for the unknown variables: $$x_{P\text{&}F}=60+4t$$ $$x_C=\dfrac{1}{2}*2*t^2$$ where $x_{P\text{&}F}$ describes Phineas and Ferb's position as a function of time and $x_C$ describes Candace's. If we set these equations equal to each other, we can solve for $t$, the time after Candace hopped on the electric scooter. We find $t=10$ seconds. Plugging this value into either of the two equations above will tell us when Candace reaches the boys. $60+4(10)=\dfrac{1}{2}*2*10^2=100$ meters. In summary, it will take Candace 30 seconds to reach the boys (20 seconds to grab her purse and 10 seconds to accelerate on her scooter) and she will reach Phineas and Ferb after travelling 100 meters.
2. We know that acceleration is the rate at which velocity changes with respect to time; in other words $v=at$. Since we know Candace is accelerating at 2 meters per second per second and it takes her 10 seconds to reach Phineas and Ferb, we can solve for velocity and find that she was travelling 20 meters per second (almost 45 mph!) when she reaches the boys.
3. See highlighted code below

#### Code

GlowScript 2.7 VPythonget_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js')#Window setupscene.width = 800scene.height = 150scene.center = vec(50,5,0)scene.background = color.white*0.5 #Objectsfloor = box(pos=vector(50,0,0), size=vec(160,1,2))P_F = box(pos=vector(-20,5,0), size=vec(10,9,2), shininess=0, texture="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/35ed113d-7deb-48b6-ae95-3ec3e049e23c/dcnmrib-7cc0dedb-e2d9-471a-8d5e-8f1634228201.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzM1ZWQxMTNkLTdkZWItNDhiNi1hZTk1LTNlYzNlMDQ5ZTIzY1wvZGNubXJpYi03Y2MwZGVkYi1lMmQ5LTQ3MWEtOGQ1ZS04ZjE2MzQyMjgyMDEucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.0YjSs0Ccip92vyd7ngwzW8OhkWw3U8SLSK6O3Y19LT8")Candace = box(pos=vector(0,5,0), size=vec(4,9,2.1), shininess=0, texture="https://vignette.wikia.nocookie.net/phineasandferb/images/8/82/Candace_Flynn2.png/revision/latest?cb=20110624122230")  #position labelslabel_PFstart = label(pos=vec(P_F.pos.x,0,0), text='-20', yoffset=-10, border=1, box=False)label_0 = label(pos=vec(0,0,0), text='0', yoffset=-10, border=1, box=False) #Time for Candace to get her camerat_CandaceDelay = 20 #Parameters and initial conditionsP_F.vel = vector(4,0,0)P_F.acc = vector(0,0,0)Candace.vel = vector(0,0,0)Candace.acc = vector(2,0,0) #Time and time stept=0dt = 0.01 #MotionMaps for P_F and CandaceP_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False)Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan) #tells scene to wait for a click before while loop runs (DO NOT ALTER)scene.waitfor ('click') #While loops to run the programwhile t < t_CandaceDelay:    rate(500)     P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position    P_F_MotionMap.update(t, P_F.vel) #Update P_F MotionMap     t = t + dt label_PFpos = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False) while t >= t_CandaceDelay: #Candace starts moving after some time delay    rate(500)     P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position    P_F_MotionMap.update(t, P_F.vel)     Candace.vel = Candace.vel + Candace.acc*dt #Update Candace velocity    Candace.pos = Candace.pos + Candace.vel*dt #Update Candace position    Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap     if Candace.pos.x >= P_F.pos.x: #Stop the program       print_options(height=120) #Sets the height of our print box      print("Final position = ", P_F.pos.x, "m")      print("Phineas and Ferb's final velocity = ", P_F.vel.x, "m/s")      print("Candace's final velocity = ",Candace.vel.x, "m/s")      print("Candace's acceleration = ",Candace.acc.x, "m/s2")      print("Final time = ", t, "s")      label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False)      scene.pause()     t = t + dt