pyglutis a python module complementary to thepyopengl(The OpenGL implementation for python) module,which will help you on the hard way of the

3D programmation with OpenGLandpython.Which implementing

severals utilities for severals usageslike:

- Differents
datatypesforVertex,Colors,Vectors,MatrixandLocalviewmanagement.- Utilities function for distances and centers computing, rotations, scaling and translation movemenent and some other.
Polygonsandpolyhedronsgenerators functions.- Predefine
3D polyhedronsobjects like thePlato polyhedronsand some others.

note:Some usages examples scripts and an the complete module description documentation of the module is provided in addition to the sources files.

## pyglut datatypes:

Datatype Color

Colormanagement class implementing the <type ‘Color’> datatype.The color can be encoded either as

unsigned bytesor asfloats.And the

Color classimplementconversionandgettersmethods.This datatype is build to interact with

pyopengl colors functions.Datatype Vertex

Verticesmanagement class implementing the <type ‘Vertex’> datatype.Holding the coordinate part x, y and z of an vertice.

With a

gettermethod to interact with thepyopengl vertex functions.Datatype Vector

Vectormanagement class implementing the <type ‘Vector’> datatype.With many vectors operations methods:

addition,substraction,multiplication,divisionandnegation.The Vector class implement

operations sign placeholderfor this operations.And others like:

vector lengthgetting,vector normalizing,vertex adding,cross product.Datatype LocalviewAn

Localviewis an object representing either an

Camera view.Local axes(X, Y, Z) of an3D object.An

locaviewis made from:

- An localview
position vertex, object from <type ‘Vertex'>.which is the position from:

The camera.- The
centerfrom the3D object.referenced as an attribute named:

Localview.pos- 3 axes, objects from <type ‘
Vector'> Representing either:

- The
camera orientation.- The
own axesfrom the3D object.referenced as attributes named:

Localview.right,Localview.up,Localview.sight.Datatype MatrixImplement an

Matrixclass to processmove,scaling,matrix,vectors,localviewsandvertexoperations.The

matrix computingis the heart of the3D programmation.You can configure the

matrix to apply changing to your 3D objectwith the primary operations:

ScalingTranslatingRotationaround the X, Y, Z axes.and others for

matrix,vectors,localviewsandvertexoperations.And finally for replacing or multiply the

OpenGL MODELVIEW matrixwith the matrix containing the desire settings for views implementing per example.And many others usage...

## pyglut utils

Primary Operations

- function
translate(...) Translate an vertice from the given offset in every axes directions from the wanted values.- function
scale(...) Scale an vertex from the wanted scaling factor.- function
rotate_x(...) Rotate an vertice around the X axe and return the result position vertice.- function
rotate_y(...) Rotate an vertice around the Y axe and return the result position vertice.- function
rotate_z(...) Rotate an vertice around the Z axe and return the result position vertice.

note:You can do the same by using an matrix.Center utils

- function
get_middle_from_segment(...) Return the middle point of an segment as an object from type Vertex.- function
get_center_from_polygon(...) Return the center of an polygon as an object from type Vertex.- function
get_center_from_polyhedron(...) Return the center of an polyhedron as an object from type Vertex.Length utils

- function
get_distance_vertices(...) Return the distance between 2 vertices.- function
get_perimeter_from_polygon(...) Return the length of the perimeter an the polygon.- function
get_perimeter_from_polyhedron(...) Return the length of the perimeter from an polyhedron.Rotation utils

- function
rotate_on_xy(...) Function to rotate an vertice around an center in the XY plan from the wanted angle value.- function
rotate_on_xz(...) Function to rotate an vertice around an center in the XZ plan from the wanted angle value.- function
rotate_on_yz(...) Function to rotate an vertice around an center in the YZ plan from the wanted angle value.Miscellaneous utils

- function
div_segment_into_vertices(...) Return an sequence from vertices between 2 vertices.## pyglut generators

## Polygons generators

- function
generate_polygon_on_xy_radius(...) Generate an polygon in the plan XY with the given settings.- function
generate_polygon_on_xz_radius(...) Generate an polygon in the plan XZ with the given settings.- function
generate_polygon_on_yz_radius(...) Generate an polygon in the plan YZ with the given settings.- function
generate_polygon_on_xy_side_length(...) Generate an polygon in the plan XY with the given settings.- function
generate_polygon_on_xz_side_length(...) Generate an polygon in the plan XZ with the given settings.- function
generate_polygon_on_yz_side_length(...) Generate an polygon in the plan YZ with the given settings.

note:This low-level function does not return an polygon object, but only theVertex listto build it.## Polyhedrons generators

- function
generate_tetrahedron(...) Generate an tetrahedron in relationship to the given side length.- function
generate_cube(...) Generate an cube in relationship to the given side length.- function
generate_octahedron(...) Generate an octahedron from the given side length.- function
generate_dodecahedron(...) Generate an dodecahedron in relationship to the argument side_length taken as basis for the dodecahedron generation.- function
generate_icosahedron(...) Generate an icosahedron from the given side length.- function
generate_fulleren(...) Generate an fulleren from the given side length.- function
generate_toros(...) Generate an toros in relationship to the given settings.- function
generate_polyhedron_26_faces(...) Generate an 26 faces polyhedron from the given side length.- function
generate_polyhedron_32_faces(...) Generate an 32 faces polyhedron from the given side length.

note:This low-level function does not return an polyhedron object, but only theVertex listto build it.## Spheres generators

- function
generate_quad_sphere(...) Generate an quads sphere (an sphere with trapeze faces).- function
generate_trigon_sphere(...) Generate an trigon sphere (an sphere with trigon faces).

note:This low-level function does not return an sphere object, but only theVertex listto build it.## Predefine polyhedrons objects

## Plato polyhedrons

Classes:Tetrahedron,Cube,Octahedron,DodecahedronandIcosahedrongenerating objects with the given settings.

Implementing following methods:

update_pos(matrix) Apply the changes contains in the matrix to the object.

note:Because you can perform all the differents operations trough an matrix object you don't need more than this method.display() Display the polyhedron.And

setter methodsfor thelines colors, thefaces color(s), thedisplay mode, theline widthandothers settings.## Other polyhedrons

2 Polyhedrons more available:

- An
26 faces polyhedroncomposed fromtrianglesandquads.- An
32 faces polyhedroncomposed fromtrianglesandpentagons.## Fulleren and toros

Classes:Fulleren(an soccer balll likewise polyhedron) andToros(An tires likewise polyhedron) generating objects with the given settings.

Implementing following methods:

update_pos(matrix) Apply the changes contains in the matrix to the object.

note:Because you can perform all the differents operations trough an matrix object you don't need more than this method.display() Display the polyhedron.And setter methods for the

lines colors, thefaces color(s), thedisplay mode, theline widthandothers settings.## Spheres

Classes:Quad_SphereandTrigon_Spheregenerating objects with the given settings.

Implementing following methods:

update_pos(matrix) Apply the changes contains in the matrix to the object.

note:Because you can perform all the differents operations trough an matrix object you don't need more than this method.display() Display the polyhedron.And setter methods for the

lines colors, thefaces color, thedisplay mode, theline widthandother settings.

You can access to the **documentation** of the project **online** or **download** the documentation:

**Online documentation**:

**ReadTheDoc online documentation**:

**Download documentation**:

**README**:

**Usage examples**:

Folowing files and usefull links of the **pyglut** project are available:

**PyPI repository:**pyglut is hosted on the PyPI (Python Package Index).

*To install pyglut from PyPI simply type:*

`$ sudo pip install pyglut`

*or*`$ sudo python -m pip install pyglut`

**PyPI page from pyglut:**

**github repository:**

Thank's to my beloved mother, my family and to the doctors.

Stay away from drugs: drugs destroy your brain and your life.