course_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
course_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution [2021/09/02 03:51] – created pwirvingcourse_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution [2022/09/06 13:03] (current) valen176
Line 3: Line 3:
 Your company, Zevo Simulations, tasks you with the completion of a "projected trajectory simulator" for your boat crossing the river. You are not sure why this would be necessary, but you decide to proceed with the project. This simulator must display the motion of the boat crossing the river, with respect to the shore. The previous design team has already done the majority of the work, but they mysteriously disappeared without completing it... The head of the division suggests you complete the project as quickly as possible! Your company, Zevo Simulations, tasks you with the completion of a "projected trajectory simulator" for your boat crossing the river. You are not sure why this would be necessary, but you decide to proceed with the project. This simulator must display the motion of the boat crossing the river, with respect to the shore. The previous design team has already done the majority of the work, but they mysteriously disappeared without completing it... The head of the division suggests you complete the project as quickly as possible!
  
-https://www.glowscript.org/#/user/paul.w.irving/folder/Public/program/RiverCrossing/edit+https://www.glowscript.org/#/user/pcubed/folder/incompleteprograms/program/RiverCrossing
  
 ====== Project 1: Part B: River Boat Crossing Solution ====== ====== Project 1: Part B: River Boat Crossing Solution ======
Line 55: Line 55:
  
 <code Python boat_sol.py> <code Python boat_sol.py>
-from __future__ import division +GlowScript 2.9 VPython 
-from visual import * + 
-from physutil import *+get_library('https://cdn.rawgit.com/PERLMSU/physutil/master/js/physutil.js')
  
 scene.width = 900 scene.width = 900
Line 66: Line 66:
 W = 20 W = 20
 origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red) origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red)
-water = box(pos=vector(-30,0,0), height=W, width=0, length=200, material=materials.wood, color=color.blue, opacity=0.4)+water = box(pos=vector(-30,0,0), height=W, width=0, length=200, color=color.blue, opacity=0.4)
 boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white) boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white)
  
Line 82: Line 82:
  
 vboatshore = vboatwater + vwatershore vboatshore = vboatwater + vwatershore
 +
  
 #Time and time step #Time and time step
Line 95: Line 96:
 #Calculation Loop #Calculation Loop
 while boat.pos.y <= W/2: while boat.pos.y <= W/2:
- rate(100)+    rate(100) 
 +     
 +    water.pos = water.pos + vwatershore*dt 
 +    boat.pos = boat.pos + vboatshore*dt
  
- water.pos = water.pos + vwatershore*dt +     
- boat.pos boat.pos vboatshore*dt+    vboatwaterMotionMap.update(t, vboatwater) 
 +    vboatshoreMotionMap.update(t, vboatshore) 
 +    vwatershoreMotionMap.update(t, vwatershore) 
 +  
 +     
 +    t + dt 
 +</code>
  
- vboatwaterMotionMap.update(t, vboatwater) +https://www.glowscript.org/#/user/pcubed/folder/solutions/program/RiverCrossingSolution
- vboatshoreMotionMap.update(t, vboatshore) +
- vwatershoreMotionMap.update(t, vwatershore) +
- +
- t = t + dt +
-</code>+
  • course_planning/183_projects/f21_week_1_problem_river_crossing_computational_problem_solution.1630554698.txt.gz
  • Last modified: 2021/09/02 03:51
  • by pwirving