In: Computer Science
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
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 = ( sheet.cell_value(i,13),
-1*sheet.cell_value(i,14), sheet.cell_value(i,15))
Rwrist.pos = ( sheet.cell_value(i,16),
-1*sheet.cell_value(i,17), sheet.cell_value(i,18))
Lank.pos = ( sheet.cell_value(i,19),
-1*sheet.cell_value(i,20), sheet.cell_value(i,21))
Lknee.pos = ( sheet.cell_value(i,22),
-1*sheet.cell_value(i,23), sheet.cell_value(i,24))
Lhip.pos = ( sheet.cell_value(i,25),
-1*sheet.cell_value(i,26),
sheet.cell_value(i,27))
Lshoulder.pos = ( sheet.cell_value(i,28),
-1*sheet.cell_value(i,29), sheet.cell_value(i,30))
Lelbo.pos = ( sheet.cell_value(i,31),
-1*sheet.cell_value(i,32), sheet.cell_value(i,33))
Lwrist.pos = ( sheet.cell_value(i,34),
-1*sheet.cell_value(i,35), sheet.cell_value(i,36))
bone_Rank_Rknee.pos = Rank.pos
bone_Rank_Rknee.axis = Rknee.pos-Rank.pos
bone_Rhip_Rknee.pos = Rhip.pos
bone_Rhip_Rknee.axis = Rknee.pos-Rhip.pos
bone_Rhip_Lhip.pos = Rhip.pos
bone_Rhip_Lhip.axis = Lhip.pos-Rhip.pos
bone_Lhip_Lknee.pos = Lhip.pos
bone_Lhip_Lknee.axis = Lknee.pos-Lhip.pos
bone_Lank_Lknee.pos = Lank.pos
bone_Lank_Lknee.axis = Lknee.pos-Lank.pos
bone_Lhip_Lshoulder.pos = Lhip.pos
bone_Lhip_Lshoulder.axis = Lshoulder.pos-Lhip.pos
bone_Rhip_Rshoulder.pos = Rhip.pos
bone_Rhip_Rshoulder.axis = Rshoulder.pos-Rhip.pos
bone_Rshoulder_Lshoulder.pos = Lshoulder.pos
bone_Rshoulder_Lshoulder.axis =
Rshoulder.pos-Lshoulder.pos
bone_Lelbo_Lshoulder.pos = Lelbo.pos
bone_Lelbo_Lshoulder.axis = Lshoulder.pos-
Lelbo.pos
bone_Lelbo_Lwrist.pos = Lelbo.pos
bone_Lelbo_Lwrist.axis = Lwrist.pos- Lelbo.pos
bone_Relbo_Rshoulder.pos = Relbo.pos
bone_Relbo_Rshoulder.axis = Rshoulder.pos-
Relbo.pos
bone_Relbo_Rwrist.pos = Relbo.pos
bone_Relbo_Rwrist.axis = Rwrist.pos- Relbo.pos
LLeg.pos = Lank.pos RLeg.pos = Rank.pos