lab2.py - GlowScript 2.6 VPython from_future import...

This preview shows page 1 - 2 out of 2 pages.

GlowScript 2.6 VPython from __future__ import division from visual import * ## constants oofpez = 9e9 qproton = -1.6e-19 print (oofpez) scalefactor = 1e-20 ## objects particle = sphere(pos=vector(1e-10,0,0), radius=2e-11, color=color.cyan) ## initial values obslocation = vector(3.1e-10,-2.1e-10,0) r = obslocation-particle.pos print ("relative position vector is", r) ra = arrow(pos=particle.pos, axis=r, color=color.green) rmag = sqrt((r.x**2)+(r.y**2)+(r.z**2)) print ("magnitude of r is",rmag) rhat = r/rmag print ("unit vector rhat is", rhat) E = oofpez*(qproton/(rmag**2))*rhat print ("Electric field vector is", E) ea = arrow(pos=obslocation, axis=E*scalefactor, color=color.orange) label(pos=ra.pos+ra.axis/2, text="r") label(pos=ea.pos+ea.axis/2, text="E") obslocation = vector(-3e-10+1e-10,0,0) r = obslocation-particle.pos ra = arrow(pos=particle.pos, axis=r, color=color.green) rmag = sqrt((r.x**2)+(r.y**2)+(r.z**2)) rhat = r/rmag E = oofpez*(qproton/(rmag**2))*rhat ea = arrow(pos=obslocation, axis=E*scalefactor, color=color.orange) #obslocation = vector(1e-10,3e-10,0) #r = obslocation-particle.pos ##ra = arrow(pos=particle.pos, axis=r, color=color.green) #rmag = sqrt((r.x**2)+(r.y**2)+(r.z**2))
Image of page 1

Subscribe to view the full document.

Image of page 2
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern