Giter VIP home page Giter VIP logo

phys241's Introduction

NMT Physics 241 Lab

This tutorial page will describe how to operate VPython scripts on a Linux Desktop. The screenshots used in this example are from Pycharm, the IDE that I am using.

Note: This will only work for Python 2.

Table of Contents

  • Setup
  • Executing Scripts
  • Issues

Setup


There are two primary packages that are needed to operate VPython on Linux. To install them input the following commands into your terminal.

apt-get install python-visual libgtkglextmm-x11-1.2-dev

Executing Scripts


Just like any other Python script, VPython scripts can be run in the terminal from the location of the file. To execute the script, type the following command into your terminal.

python [name of script file].py

Issues


A recurring issue with running VPython via this method is the following warning:

/usr/lib/python2.7/dist-packages/visual/materials.py:70: FutureWarning: 
comparison to `None` will result in an elementwise object comparison in the future.
  self.__setattr__(key, value)

Based on my experience, I have not noticed any consequences of this warning at all. The VPython scripts will still run in the same fashion as in VIDLE.

VPython


Objects

The objects that are pre-defined:

Object attributes

object           =   object_name(make_trail=True) # Creates the object
object.pos       =   vector(x, y, z) # Sets initial position
object.axis      =   vector(x, y, z) # Sets final position
object.radius    =   0.5 # Sets the radius
object.color     =   color.red # Sets the color
object.shininess =   0.6 # Sets the shininess
object.emissive  =   False 
object.opacity   =   0.8 # Sets the transparency 

Colors

Pre-Defined Colors

  • Red
  • Green
  • Blue
  • Magenta
  • Yellow
  • Orange
  • Black
  • White
  • Cyan
  • Purple

Defining a color

Uses RGB color scheme. Ranges from 0 to 1.

purple = vector(0.4, 0.2, 0.6)
object.color = purple

phys241's People

Contributors

pharaohcola13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.