VPython Reference: Difference between revisions

From Physics Book
Jump to navigation Jump to search
Line 195: Line 195:
|-
|-
| Magnetic Constant
| Magnetic Constant
| <math> \frac{\mu_0}{4\pi}</math>
| km
| <math> 1 \times 10^{-7}</math>
| 1e-7
| <math> T\cdot m/A</math>
| km = 1e-7
|-
|-
| Vacuum Permeability
| Vacuum Permeability
| <math> \mu_0</math>
| mu_0
| <math> 4\pi \times 10^{-7}</math>
| 1.2566370614e-6
| <math> T\cdot m/A </math>
| mu_0 = 1.2566370614e-6
|-
|-
| Proton Charge
| Proton Charge
| <math> e</math>
| e
| <math> 1.6 \times 10^{-19}</math>
| 1.602176565e-19
| <math> C </math>
| e = 1.602176565e-19
|-
|-
| Electron Volt
| Electron Volt
| <math> eV </math>
| eV
| <math> 1.6 \times 10^{-19}</math>
| 1.602176565e-19
| <math> J </math>
| eV = 1.602176565e-19
|-
|-
| Avogadro's Number
| Avogadro's Number
| <math> N_A </math>
| N_A
| <math> 6.02 \times 10^{23}</math>
| 6.0221409e23
| <math> molecules/mole </math>
| N_A = 6.0221409e23
|-
| Atomic Radius (approximate)
| <math> R_a </math>
| <math> 1 \times 10^{-10}</math>
| <math> m </math>
|-
|-
| Proton Radius
| Proton Radius
| <math> R_p </math>
| R_p
| <math> 1 \times 10^{-15}</math>
| 0.8775e-15
| <math> m </math>
| R_p = 0.8775e-15
|-
|-
| ''E'' to ionize air
| ''E'' to ionize air
| <math> E_{ionize} </math>
| E_ionize
| <math> 3 \times 10^{6}</math>
| 3e6
| <math> V/m </math>
| E_ionize = 3e6
|-
|-
| Earth's Magnetic Field
| Earth's Magnetic Field
| <math> B_{Earth} </math>
| B_Earth
| <math> 2 \times 10^{-5}</math>
| 2e-5
| <math> T </math>
| B_Earth = 2e-5
|}
|}



Revision as of 19:09, 5 December 2015

Created by Shuyang Chen

VPython reference page for animation functions and constants. This page assumes and only includes basic usage of VPython.

VPython Template

from __future__ import division
from visual import *

## Constants

## Initialization

## Loop
t = 0
deltat = 1e-10
end = 10

while t < end:
    rate(1000)
    ## Loop Code
    
    t += deltat

VPython Animation Functions

Sphere

Source

Example

ball = sphere(pos=(1,2,3), radius=0.4, color=color.blue)

Parameters

Parameter Type Description
pos vector Position of the object
color color Color of the object
radius number Radius of the sphere
opacity number Opacity of the object
make_trail boolean Whether or not to leave behind a trail

Arrow

Source

Example

arr = arrow(pos=(1,2,3), axis=(4,5,6), color=color.red)

Parameters

Parameter Type Description
pos vector Position of the object
axis vector Direction the arrow is pointing at
color color Color of the object
opacity number Opacity of the object
shaftwidth number Width of the shaft (default: 0.1*(length of arrow))
headwidth number Width of the head (default: 2*shaftwidth)
headlength number Length of the head (default: 3*shaftwidth)
make_trail boolean Whether or not to leave behind a trail

Color

Source

Example

c = color.red

Basic Colors

Name Vector Color
Red (1,0,0) color.red
Yellow (1,1,0) color.yellow
Green (0,1,0) color.green
Orange (1,0.5,0) color.orange
Blue (0,0,1) color.blue
Cyan (0,1,1) color.cyan
Magenta (1,0,1) color.magenta
White (1,1,1) color.white
Black (0,0,0) color.black

VPython Common Constants

Constants

Constant Common Variable Name Approximate Value Code
Speed of light c 299792458.0 c = 299792458.0
Gravitational Constant G 6.67408e-11 G = 6.67408e-11
Electron Mass m_e 9.10938356e-31 m_e = 9.10938356e-31
Proton Mass m_p 1.6726219e-27 m_p = 1.6726219e-27
Neutron Mass m_n 1.674927471e-27 m_n = 1.674927471e-27
Electric Constant oofpez 8.9875517873681764e9 oofpez = 8.9875517873681764e9
Permitivity of Free Space e0 8.854187817e-12 e0 = 8.854187817e-12
Magnetic Constant km 1e-7 km = 1e-7
Vacuum Permeability mu_0 1.2566370614e-6 mu_0 = 1.2566370614e-6
Proton Charge e 1.602176565e-19 e = 1.602176565e-19
Electron Volt eV 1.602176565e-19 eV = 1.602176565e-19
Avogadro's Number N_A 6.0221409e23 N_A = 6.0221409e23
Proton Radius R_p 0.8775e-15 R_p = 0.8775e-15
E to ionize air E_ionize 3e6 E_ionize = 3e6
Earth's Magnetic Field B_Earth 2e-5 B_Earth = 2e-5

Connectedness

  1. How is this topic connected to something that you are interested in?
  2. How is it connected to your major?
  3. Is there an interesting industrial application?

History

Put this idea in historical context. Give the reader the Who, What, When, Where, and Why.

See also

Are there related topics or categories in this wiki resource for the curious reader to explore? How does this topic fit into that context?

Further reading

Books, Articles or other print media on this topic

External links

[1]


References

This section contains the the references you used while writing this page