Question

VPython Physics 1211k 1. Here is a somewhat more sophisticated program that recreates one of your...

VPython Physics 1211k

1. Here is a somewhat more sophisticated program that recreates one of your experiments – a cart rolling up a ramp and back down. Particularly pay attention to the components of the acceleration.

from visual import *

#control the dimensions of the animation window. Turn off autoscaling. Then set the window to show 20 meters

#in each direction. Then set the actual physical size of the animation window on the screen

scene.autoscale = False

scene.range = 20

#scene.width = 640

#scene.height = 480

#scene.align = 'left'

#set up some constants

g = 9.8

theta = pi*20/180

#create a particle to represent the center of mass. Velocity and acceleration are not properties of spheres

#but you can add them as properties or your sphere by just stating that they exist

cart = sphere(pos=vec(-5,0,0), radius = 0.7, color = color.yellow)

cart.v = vec(10*cos(theta),10*sin(theta),0)

cart.a = vec(-g*sin(theta)*cos(theta), -g*(sin(theta))**2,0)

#time step

dt = 0.05

t =

#animation loop

while cart.pos.x >= -5:

    rate(30)

    #update velocity, position and time

    cart.v = cart.v + cart.a*dt

    cart.pos = cart.pos + cart.v*dt

    t = t + dt

a. First, add velocity and acceleration vectors to the object that change magnitude and direction appropriately.

b. Make graphs of position versus time and velocity versus time. You should create two graphs, one of which plots both the x and y components of position vs. time, and the other plots x and y components of velocity vs. time.

2. The VPython coordinate system is origin at the center of the animation window, x to the left and y up and you can’t change it. But what you really want in problem 1 is a coordinate system like your motion detector with x pointing up the ramp. You’ll have to do a little trig to figure that out from the components you have. Once you do, use that to redo problem one with a single position graph plotting position up the ramp and a single velocity graph plotting velocity along the ramp.

I'm having difficulty making graphs in VPython/ GlowScript 2.7, please help!

Homework Answers

Answer #1

Here is a simple script of making graphs in python 2.7


import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set()
sns.set_style("whitegrid")
sns.set_context("notebook", font_scale=0.75, rc={"lines.linewidth": 1.0})

fileName = 'plot.dat'
data = np.genfromtxt(fileName,skip_header=0,usecols=(0,2))

plt.plot(data[:,0],data[:,1],'-',markersize=5, label='single')
plt.xlim([0,10])
plt.ylim([0,10])
plt.title('plot')
plt.xlabel(r'x axis')
plt.ylabel(r'y axis')
plt.legend()
plt.savefig('plot.pdf')
plt.show()

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question: You stand at the bottom of a long ramp (i.e. one used for wheelchair access)...
Question: You stand at the bottom of a long ramp (i.e. one used for wheelchair access) and throw a tennis ball towards the top of the ramp, as shown in the sketch. Assume that the tennis ball leaves your hands a height h = 1.800 m from the ground and at a speed of v0 = 14.00 m/s and an angle of elevation of 51.03°, as shown in the sketch. Take the origin of a Cartesian coordinate system on the...
Your task will be to derive the equations describing the velocity and acceleration in a polar...
Your task will be to derive the equations describing the velocity and acceleration in a polar coordinate system and a rotating polar vector basis for an object in general 2D motion starting from a general position vector. Then use these expressions to simplify to the case of non-uniform circular motion, and finally uniform circular motion. Here's the time-dependent position vector in a Cartesian coordinate system with a Cartesian vector basis: ⃗r(t)=x (t) ̂ i+y(t) ̂ j where x(t) and y(t)...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated panel) with a circle that moves on the panel and rebounds from the edges. (NOTE: the program is derived from Listing 8.15 and 8.16 in the text. That program uses an image rather than a circle. You may have used it in an earlier lab on animation.) The Circle class is in the file Circle.java. Save the program to your directory and run it...
1. For a stationary ball of mass m = 0.200 kg hanging from a massless string,...
1. For a stationary ball of mass m = 0.200 kg hanging from a massless string, draw arrows (click on the “Shapes” tab) showing the forces acting on the ball (lengths can be arbitrary, but get the relative lengths of each force roughly correct). For this case of zero acceleration, use Newton’s 2nd law to find the magnitude of the tension force in the string, in units of Newtons. Since we will be considering motion in the horizontal xy plane,...
1. Usain Bolt sprints along the track, with his feet pushing down and behind him. Therefore...
1. Usain Bolt sprints along the track, with his feet pushing down and behind him. Therefore the track actually pushes Usain Bolt along the track. Group of answer choices True or False 2.You study two objects in motion, Object J and Object S. Each object has its own velocity graph, with same time and velocity scales. The slope of each graph is positive, upward and to the right  ⁄ but Object J's tilt angle is only 10º and Object S's tilt...
ch 6 1: It is generally a good idea to gain an understanding of the "size"...
ch 6 1: It is generally a good idea to gain an understanding of the "size" of units. Consider the objects and calculate the kinetic energy of each one. A ladybug weighing 37.3 mg flies by your head at 3.83 km/h . ×10 J A 7.15 kg bowling ball slides (not rolls) down an alley at 17.5 km/h . J A car weighing 1260 kg moves at a speed of 49.5 km/h. 5: The graph shows the ?-directed force ??...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...