VPython: Difference between revisions

From Physics Book
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
==Installation==
==Installation==


Installation guide goes here (Need to do test installs on Windows, OSX, Linux... BSD?)
To install VPython simply follow the instructions in the links given below.  


===Windows===
===Windows===
Install VPython [[http://vpython.org/contents/download_windows.html]] |here]
Install VPython [http://vpython.org/contents/download_windows.html| here]


===OSX===
===OSX===

Revision as of 00:09, 26 November 2015

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

To install VPython simply follow the instructions in the links given below.

Windows

Install VPython here

OSX

Install VPython | here

Linux

Install VPython | here

Getting started with Python

Introduction to basic Python use

Creating VPython Objects

  • Sphere

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

  • Arrow

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

  • Vector

myVector = vector(x_coordinate,y_coordinate,z_coordinate)

Manipulating VPython values

  • 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)

  • 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.

  • While loops

Useful built-in functions

Math

  • x**y

Raises x to the y-th power.

Vectors

  • cross(vectorA, vectorB)

Calculates the cross product of two vectors

  • mag(vector)

Calculates the magnitude of the vector

  • 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