VPython Functions: Difference between revisions

From Physics Book
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:


from __future__ import division
from __future__ import division
from visual import *
from visual import *


Line 26: Line 27:
vector = vector(x,y,z)
vector = vector(x,y,z)
===Spheres===
===Spheres===
sphere = sphere(pos=*, color=color.**, radius = *** )
sphere = sphere(pos=POS, color=color.COLOR, radius=RADIUS )
*: a vector giving the sphere location
POS: a vector giving the sphere location
**: Options can be found on http://matplotlib.org/examples/color/named_colors.html
COLOR: Options can be found on http://matplotlib.org/examples/color/named_colors.html
***: The radius of the sphere (usually given by the lab instructions)
RADIUS: The radius of the sphere (usually given by the lab instructions)
===Arrows===
===Arrows===
arrow = arrow(pos=*, axis=** color=color.***)
arrow = arrow(pos=POS, axis=AXIS color=color.COLOR)
*: where the head of the arrow is to be placed
POS: where the head of the arrow is to be placed
**: the line that we want the axis to go along (generally some position - * position)
AXIS: the line that we want the axis to go along (generally some position - * position)
***: Options can be found on http://matplotlib.org/examples/color/named_colors.html
COLOR: Options can be found on http://matplotlib.org/examples/color/named_colors.html





Revision as of 14:28, 4 December 2015

VPython Functions

Created by Natalie Standish

Short Description of Topic

The Main Idea

The main idea of this page is to serve as an aid for future physics students in writing python code during lab.


Starting Out

These are the first two lines of code that you should put into every one of the codes we have in this class:

from __future__ import division

from visual import *



Making Basic Objects

Vectors

vector = vector(x,y,z)

Spheres

sphere = sphere(pos=POS, color=color.COLOR, radius=RADIUS ) POS: a vector giving the sphere location COLOR: Options can be found on http://matplotlib.org/examples/color/named_colors.html RADIUS: The radius of the sphere (usually given by the lab instructions)

Arrows

arrow = arrow(pos=POS, axis=AXIS color=color.COLOR) POS: where the head of the arrow is to be placed AXIS: the line that we want the axis to go along (generally some position - * position) COLOR: Options can be found on http://matplotlib.org/examples/color/named_colors.html


Connectedness

VPython is an important tool in PHYS 2211 and PHYS 2212 because it is able to take a very abstract concept and give a visual explanation to the student.


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

Phython colors: http://matplotlib.org/examples/color/named_colors.html


References

This section contains the the references you used while writing this page http://matplotlib.org/examples/color/named_colors.html n?