Develop a VPython program creating an animation of your group’s object (a person walking up a
flight up stairs) and cause it to move so that the animation simulates the motion of the object
assigned. A .py file
Solution
from visual import *
import xlrd
scene2 = display(title=\'upstairs \', x=0, y=0, width=600, height=600, center=(30,-20,0),
background=(0,1,1))
file_loc = \"D:\\acad\\cct.xlsx\"
workbook = xlrd.open_workbook(file_loc)
sheet = workbook.sheet_by_index(0)
r = 1.0
rb = 0.5
floor_bottom = box(pos=(30, -39, -15), length=60, height=2, width=30)
Rank = sphere(pos=(27,-36,0), radius=r)
Rknee = sphere(pos=(28.3,-29.1,0), radius=r)
Rhip = sphere(pos=(28.6,-22.6,0), radius=r)
Rshoulder = sphere(pos=(28.15,-16.65,0.75), radius=r)
Relbo = sphere(pos=(28.5,-22,0.75), radius=r)
Rwrist = sphere(pos=(29.7,-26.11,0.75), radius=r)
Lank = sphere(pos=(34,-36,-0.5), radius=r)
Lknee = sphere(pos=(33.5,-28.8,-0.5), radius=r)
Lhip = sphere(pos=(32.17,-21.94,-0.5), radius=r)
Lshoulder = sphere(pos=(33.4,-15.9,-0.75), radius=r)
Lelbo = sphere(pos=(33.6,-20.74,0), radius=r)
Lwrist = sphere(pos=(32.03,-24.2,0.6), radius=r)
bone_Rank_Rknee = cylinder(pos= Rank.pos, axis=Rknee.pos-Rank.pos, radius=rb, color =
color.black)
bone_Rhip_Rknee = cylinder(pos= Rknee.pos, axis=Rhip.pos-Rknee.pos, radius=rb, color =
color.black)
bone_Rhip_Lhip = cylinder(pos= Rhip.pos, axis=Lhip.pos-Rhip.pos, radius=rb)
bone_Lhip_Lknee = cylinder(pos= Lhip.pos, axis=Lknee.pos-Lhip.pos, radius=rb, color =
color.black)
bone_Lank_Lknee = cylinder(pos= Lank.pos, axis=Lknee.pos-Lank.pos, radius=rb, color =
color.black)
bone_Lhip_Lshoulder = cylinder(pos= Lhip.pos, axis=Lshoulder.pos-Lhip.pos, radius=rb)
bone_Rhip_Rshoulder = cylinder(pos= Rhip.pos, axis=Rshoulder.pos-Rhip.pos, radius=rb)
bone_Rshoulder_Lshoulder = cylinder(pos= Lshoulder.pos, axis=Rshoulder.pos-Lshoulder.pos,
radius=rb)
bone_Lelbo_Lshoulder = cylinder(pos= Lelbo.pos, axis=Lshoulder.pos-Lelbo.pos, radius=rb)
bone_Lelbo_Lwrist = cylinder(pos= Lelbo.pos, axis=Lwrist.pos-Lelbo.pos, radius=rb)
bone_Relbo_Rshoulder = cylinder(pos= Relbo.pos, axis=Rshoulder.pos-Relbo.pos, radius=rb)
bone_Relbo_Rwrist = cylinder(pos= Relbo.pos, axis=Rwrist.pos-Relbo.pos, radius=rb)
Bat = cylinder(pos= Lwrist.pos, axis=Bat_bottom.pos-Lwrist.pos, radius=0.8, color =
color.yellow)
LLeg = cylinder(pos= Lank.pos, axis=(1,-1,2), radius=0.8, color = color.red)
RLeg = cylinder(pos= Rank.pos, axis=(1,-1,2), radius=0.8, color = color.red)
while True :
for i in range( 3, 17,1):
rate(20)
if i > 6:
boll.pos = (sheet.cell_value(i,40), -1*sheet.cell_value(i,41), sheet.cell_value(i,42))
boll.color = color.green
Rank.pos = ( sheet.cell_value(i,1), -1*sheet.cell_value(i,2), sheet.cell_value(i,3))
Rknee.pos = ( sheet.cell_value(i,4), -1*sheet.cell_value(i,5), sheet.cell_value(i,6))
Rhip.pos = ( sheet.cell_value(i,7), -1*sheet.cell_value(i,8), sheet.cell_value(i,9))
Rshoulder.pos = ( sheet.cell_value(i,10), -1*sheet.cell_value(i,11), sheet.cell_value(i,12))
Relbo.pos.