QUICKSTART
Overview
PyGeo is most fundamentally a framework for the creation of dynamic geometric constructions - i.e. constructions which embody defined geometric relationships while at the same time allowing for real time interactivity.
PyGeo is, further, an implementation of the underlying abstract framework - providing a range of pre-built geometric objects useful for the exploration of Euclidian geometry, projective geometry of the plane and of space, as well as the geometry of complex numbers on the complex plane and on the unit sphere.
PyGeo is implemented in the Python http://www.python.org/ programming language, and PyGeo constructions themselves are Python scripts processed directly by the Python interpreter.
Dependencies
In addition to the Python interpreter itself, PyGeo is dependant on the VPython http://vpython.org/ 3d rendering environment, as well as either Numeric or NumArray (included with the VPython binary distributions) for fast array processing and linear algebra operations
PyGeo is capable of outputting PovRay http://www.povray.org/ scene files to allow for high quality rendering of a construction's static state.
Editing Environment
While it is possible to create constructions from the Python command shell, for more involved efforts it is desirable to create scripts in a text editor and run them as (Python) *.py files.
PyGeo at this time is distributed without an IDE environment. Most Python friendly programmers editor will serve as an appropriate environment for creating and running PyGeo scripts, though certain Python editors (e.g. PythonWin) have been found to have difficulties working with the VPython event loop.
Python friendly cross platform recommendations include:
- the IDLE environment distributed with the Python interpreter and libraries.
- SciTE http://www.scintilla.org/SciTE.html
- SPE http://www.stani.be/python/spe/blog/
Windows:
A good deal of the development of PyGeo was done using TextPad. a shareware Windows editor http://www.textpad.com/
The utilities folder of the PyGeo distribution include a pygeo.syn that can be used for PyGeo syntax highlighting in TextPad.
A more complete list of Python compatible editors can be found at http://wiki.python.org/moin/PythonEditors
Hello Point, Hello Line
A PyGeo construction is created by:
- importing the PyGeo classes and constants
- initialize a display
- creating instances of geometric objects rendered in immediate mode on the display
- for interactivity, entering a loop in which the display screen will respond to mouse events.
A simple interactive session from the Python command shell (say in IDLE at the Python Shell window)
Hello Point :
>>> from pygeo import * >>> display=display() >>> FreePoint(1,4,5) vector(1, 4, 5) >>> display.pickloop()
Hello Line :
>>> from pygeo import * >>> display=display() >>> p1 = FreePoint(1,4,5) vector(1, 4, 5) >>> p2 = FreePoint(5,11,9)
>>> Line(p1,p2) >>> display.pickloop()
Mouse Interaction
Once a display has entered into a event loop by a call to the pickloop() method, it will respond to mouse events, allowing interactivity with the construction:
Left click:
- if a pickable point is hit, the point hit will identify itself by enlarging and displaying as in Green
- if no pickable point is hit, all pickable points will respond by flashing larger and displaying in Blue
Left drag:
- a picked point is moved in reaction to a drag with the left mouse button down.
Right drag:
- the scene will rotate around the camera center in reaction to movement with the right mouse button down
Middle drag, 2 button drag:
- the scene will zoom closer or further in reaction to movement with the middle button, or the left and right buttons simultaneously down.
Panel Menu
By default, a creation of a display also creates a separate panel that contains option box and menu options. The creation of the panel can be suppressed by including the expression "panel = False" as a keyword parameter when initializing the display:
Information output
The lower level boxes of the panel display state information, as follows, following the display boxes from left to right:
- the "name" of the currently picked point, if a label has been assigned to the point.
- the x,y,z coordinates of the currently selected point
- the current on/off state of the Trace option (see menu options, below)
- the current on/off state of the Drag option (see menu options, below)
Check buttons and radio buttons:
Detail Level:
when creating a geometric object (i.e. class instance) there is the option to specify a display level using the keyword argument "level=<integer value>", with the level defaulting to "1" in the absence of an argument. e.g.:
p1= Point(1,17,-3,level=3)
sets the point p1 to be visible only when Level 3 is checked in the Detail Level check box group
Multiple and non-consecutive levels of display can be selected and deselected.
Assigning an object "level = -1" will assure it to be visible at all display levels
Drag Constraints:
to allow control movement, pickable points designed to be freely movable in space (FreePoint, zFreePoint) are at any one time constrained to a particular plane or direction relative to the display coordinate scheme. The Drag Constraints radio button option sets the constraints on the movement on points picked and dragged.
Menu - Options
Reset to initial:
returns all picked and moved points to their position at initialization, and resets all dependant objects to their position based on the points' initial positions.
Remove tracings
remove all loci of points and/or lines created via the "tracing" mechanism.
Toggle trace on/off
toggle the state of tracing from its current on/off state as displayed in the information text box.
Toggle axis visibility
toggle the visibility of the representation of the 3d coordinates axes.
Toggle drag effect
the drag effect determines whether the construction attempts to update at each update cycle during the movement of pickable point ("Drag On") or updates only upon release of the dragged point ("Drag Off").
the menu option toggles the state of the drag option form its current state as displayed in the information text box.
Animate
invoke periodic rendering loops, inducing "animation" of objects (and their dependents) designed to re-position at each rendering loop cycle.
Export to Povray
enter file browser dialogue for export of the visible elements in the scene to Povray scene definition format *.pov
Menu - Help
PyGeo help
calls PyGeo main help index in html browser
Diagram Instructions
displays triple quoted (""") text in construction script referenced to the "instructions" keyword in the initialization of the display
Diagram Explanation
displays triple quoted (""") text in construction script referenced to the "explanation" keyword in the initialization of the display