VPython basics

From Physics Book
Revision as of 21:20, 10 November 2015 by Lnikolenko3 (talk | contribs)
Jump to navigation Jump to search

claimed by Liubov Nikolenko


This is a beginner guide to VPython for people who have no or little coding experience and are concerned about the coding part of the course.

The Main Idea

State, in your own words, the main idea for this topic VPython is a programming language with graphics module that is useful for simulation and animation of physical processes. In other words, it allows to see what would happen to the motion of the Earth if it crashed with the giant asteroid just by writing several lines of code insted of creating a doomsday!

Installation

VPython is available for Windows, Machintosh and Linux.

A Computational Model

How do we visualize or predict using this topic. Consider embedding some vpython code here Teach hands-on with GlowScript

Basics

Befor writing your VPython program be sure to include those lines

from __future__ import division

from visual import *

These lines are needed to invoke the visual module and to make sure that when you calculate 3/4 you get 0.75 and not 0.

Creating vectors

You can create a vector v in Vpython by doing v = vector(x, y, z)

Creating objects

You will be creating several 3D shapes to represent objects and particles in your simulations. You will usually name your objects in order to access or modify their information (e.g. update the position). You can access the attributes of the object you created just by doing object.attribute (e.g. electron.pos). Here is the code sample for the most common ones:

Sphere: ball = sphere(pos=(x,y,z,), radius=r, color = color.your_color)

Arrow: someArrow = arrow(pos=(x1,y1,z1), axis=(x2,y2,z2), color = color.your_color)

Middling

Difficult

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

Internet resources on this topic

References

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