VPython basics: Difference between revisions

From Physics Book
Jump to navigation Jump to search
(Created page with "Short Description of Topic claimed by Liubov Nikolenko ==The Main Idea== State, in your own words, the main idea for this topic Electric Field of Capacitor ===A Mathematica...")
 
No edit summary
Line 1: Line 1:
Short Description of Topic
claimed by Liubov Nikolenko
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==
==The Main Idea==


State, in your own words, the main idea for this topic
State, in your own words, the main idea for this topic
Electric Field of Capacitor
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!
 
===A Mathematical Model===


What are the mathematical equations that allow us to model this topic. For example <math>{\frac{d\vec{p}}{dt}}_{system} = \vec{F}_{net}</math> where '''p''' is the momentum of the system and '''F''' is the net force from the surroundings.
===Installation===
VPython is available for [http://vpython.org/contents/download_windows.html Windows], [http://vpython.org/contents/download_mac.html Machintosh] and [http://vpython.org/contents/download_linux.html Linux].  


===A Computational Model===
===A Computational Model===
Line 15: Line 16:
How do we visualize or predict using this topic. Consider embedding some vpython code here [https://trinket.io/glowscript/31d0f9ad9e Teach hands-on with GlowScript]
How do we visualize or predict using this topic. Consider embedding some vpython code here [https://trinket.io/glowscript/31d0f9ad9e Teach hands-on with GlowScript]


==Examples==
==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:


Be sure to show all steps in your solution and include diagrams whenever possible
Sphere: ball = sphere(pos=(x,y,z,), radius=r, color = color.your_color)


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

Revision as of 20:20, 10 November 2015

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