VPython

From Physics Book
Revision as of 00:02, 26 November 2015 by Lnikolenko3 (talk | contribs)
Jump to navigation Jump to search

Claimed by Liubov Nikolenko VPython is a Python graphics module used for modeling objects in 3-dimensional space. In the field of physics, this is especially useful for calculating and modeling complex relationships between objects and their properties.

Installation

Installation guide goes here (Need to do test installs on Windows, OSX, Linux... BSD?)

Windows

Install VPython |here

OSX

Install VPython | here

Linux

Install VPython | here

Getting started with Python

Introduction to basic Python use

Creating VPython Objects

  1. Sphere

ball = sphere(pos=(x_coordinate,y_coordinate,z_coordinate), radius=radius_of_the_sphere, color = color.color_of_the_sphere))

  1. Arrow

myArrow = arrow(pos=(x0_coordinate,y0_coordinate,z0_coordinate), axis=(x1_coordinate,y1_coordinate,z1_coordinate), color = color.color_of_the_sphere)

  1. Vector

myVector = vector(x_coordinate,y_coordinate,z_coordinate)

  1. Accessing attributes of the object

To access the attribute of a given object just use the syntax object.attribute (e.g. to access the position of the ball object, you should do ball.pos)

  1. Updating values

To update a value (such as time, speed, force or the position of the object) you should do value = value + delta_value

Loops

There are two types of loops that can be use in Python: for loop and while loop. Basically, loops are used to tell the computer to execute the same task multiple times. While loops are more common for modeling physics concepts.

Useful built-in functions

Math

  1. x**y

Raises x to the y-th power.

Vectors

  1. cross(vectorA, vectorB)

Calculates the cross product of two vectors

  1. mag(vector)

Calculates the magnitude of the vector

  1. norm(vector)

Calculates the unit vector of the vector

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.

VPython was originally released in 2000 by David Scherer after he took an introductory physics class at Carnegie Mellon University. At the time, the school used the cT programming language for 2D modeling, and David saw the need for something better. Working with several people including professors Ruth Chabay and Bruce Sherwood, he developed a Python module called Visual. Visual Python or VPython featured 3D modeling, as well as an easier-to-understand object-oriented syntax. VPython is released under an Open Source license, and development continues today.

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

Internet resources on this topic

References

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

1. The cT Programming Language

2. VPython Wiki Site