Thursday, September 13, 2012

vPYTHON VECTORS

VPYTHON VECTORS TUTORIAL



REVISED: Sunday, March 3, 2013




In this tutorial, you will learn vPython vectors.

I.  SCALAR VERSUS VECTOR

Mathematics is the language of physics. "Scalar" and "vector" are two terms in mathematics that appear frequently when discussing physics. A scalar is a "real number" that is not associated with a direction. A mathematical quantity that has both a size, called its magnitude and direction, represented by its unit vector is a vector"Distance", "length", or "speed" is synonymous with magnitude.

II.  vPYTHON VECTOR VERSUS ARROW

There are several mathematical representations of vectors. vPython uses vector(x,y,z). By adding “.x”, “.y”, or “.z” to the name of a vector you can refer to the components of a vector. Where "x" is the "x axis", "y" is the "y axis", and "z" is the "z axis".

The vPython arrow object has a straight box-shaped shaft with an arrowhead on one end. The arrow object can be used to represent vectors. Attributes of the arrow object are "axis", "pos", and "color". The location of the tail of the arrow is specified by the "pos" attribute.  A vector that points from the tail to the tip of the arrow is specified by the "axis" attribute. Arrows help to visualize vector quantities like momentum, position, and force in 3D. You can set the color to red, blue, green, cyan, magenta, yellow, orange, black, or white.

III.  vPYTHON EXAMPLE ARROW PROGRAM

Start the vPython interpreter shell by "double left mouse clicking" the vPython icon on your desktop. When the "vPython Shell" window opens type the following code:

from __future__ import division  #For floating point numbers.
from visual import * # Enables the graphics to work.

tonto=arrow(pos=vector(0, 1, 5), axis=vector(3, 1, 4), color=color.green)  #Creates an arrow object named "tonto" with the following three attributes:

# 1. pos is the position vector <0, 1, 5> of the tail of the arrow.

# 2. axis is the components of the arrow vector <3, 1, 4> measured from the tail to the tip of the arrow.

# 3. color is the arrow’s color, which is green.

From the "vPython Shell" window, do a "File Save" and save the above vPython program, using the file name arrowVector.py.

From the "vPython Shell" window, do a "Run" and then a "Run Module F5" and a vPython 3-D graphics scene will open displaying the arrow.

The comments which start with a hash, #, sign explain how this vPython program works.

IV.  vPYTHON 3-D GRAPHICS SCENE

vPython automatically “zooms” the camera in or out so that all objects appear in the window. The coordinate system shows the positive x direction pointing to the right, the positive y direction going up, and the positive z direction moving toward you out of the screen, when you run the program. Rotating the camera view makes these axes point in other directions. Use the following controls when viewing objects in the vPython 3-D graphics scene:

A. TO ZOOM OUT AND IN

Move the mouse down or up and hold down both mouse buttons.

B. TO REVOLVE AROUND THE SCENE

Move the mouse and hold down the right mouse button alone.

In this tutorial, you have learned vPython vectors.

Elcric Otto Circle



-->



-->



-->





 







How to Link to My Home Page

It will appear on your website as:

"Link to: ELCRIC OTTO CIRCLE's Home Page"





Wednesday, September 12, 2012

DOWNLOADING AND INSTALLING vPYTHON

DOWNLOADING AND INSTALLING VPYTHON TUTORIAL



REVISED: Sunday, March 3, 2013




In this tutorial, you will learn how to download  and install vPython.

I.  vPYTHON INTRODUCTION

In 2000 David Scherer created VPython, the Python programming language plus a 3D graphics module called Visual. VPython objects such as spheres and cones could then be created and displayed in a window in 3D spaceVPython is well-documented, free, and powerful. Those who have never programmed find it easy to learn.

II. DOWNLOADING AND INSTALLING vPYTHON

Before you download vPython, check and make sure you already have the most recent stable version of Python supported by vPython. Download Python first, then download vPython.

My computer uses Microsoft Windows; therefore, I downloaded the "VPython-Win-Py2.7-5.74" for Python 2.7.

To download vPython click on the following link:

 vPYTHON.

During the download, select all of the defaults and everything will be saved into the correct folders required by Python.

III. TESTING DOWNLOAD AND INSTALLATION

Start the vPython interpreter shell by "double left mouse clicking" the vPython icon on your desktop.  Select "File" when the "vPython Shell" window opens, then select "Open". You should see a list of demonstration programs. Select a demonstration program, e.g., bounce.py, and the file should automatically be pasted to the "vPython Shell" window. To run the program press F5, or use the Run menu. When the program runs you have validated your vPython download and installation, now you are ready to begin writing vPython programs.

In this tutorial, you have learned how to download and install vPython.

Elcric Otto Circle



-->



-->



-->





 







How to Link to My Home Page

It will appear on your website as:
"Link to: ELCRIC OTTO CIRCLE's Home Page"