pyglut generators

pyglut – python opengl utilities

platform:Linux, Windows
synopsis:pyopengl programming helper classes and functions set.

Module author: Eddie Brüggemann <mrcyberfighter@gmail.com>

pyglut generators

Polygons generators

pyglut.generate_polygon_on_xy_radius(edges, radius, center, offset=0)

Return an polygon on plan XY:

  • From edges sides.
  • From radius radius.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • radius – The radius from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, radius with even an offset.

In the plan XY.

Returns:An list of objects from type Vertex composing the polygon.
pyglut.generate_polygon_on_xz_radius(edges, radius, center, offset=0)

Return an polygon on plan XZ:

  • From edges sides.
  • From radius radius.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • radius – The radius from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, radius with even an offset.

In the plan XZ.

Returns:An list of objects from type Vertex composing the polygon.
pyglut.generate_polygon_on_yz_radius(edges, radius, center, offset=0)

Return an polygon on plan YZ:

  • From edges sides.
  • From radius radius.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • radius – The radius from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, radius with even an offset.

In the plan YZ.

Returns:An list of objects from type Vertex composing the polygon.
pyglut.generate_polygon_on_xy_side_length(edges, side_length, offset=0)

Return an polygon on plan XY:

  • With edges edges.
  • From side length side_length.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • side_length – The side length from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, side length with even an offset.

Returns:An list of objects from type Vertex composing the polygon.
pyglut.generate_polygon_on_xz_side_length(edges, side_length, offset=0)

Return an polygon on plan XZ:

  • With edges edges.
  • From side length side_length.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • side_length – The side length from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, side length with even an offset.

Returns:An list of objects from type Vertex composing the polygon.
pyglut.generate_polygon_on_yz_side_length(edges, side_length, offset=0)

Return an polygon on plan YZ:

  • With edges edges.
  • From side length side_length.
  • With offset offset.
Parameters:
  • edges – The number of edges from the polygon to generate.
  • side_length – The side length from the polygon to generate.
  • offset – The offset in degrees to orientate the polygon.

Generate an polygon with the given edges number, side length with even an offset.

Returns:An list of objects from type Vertex composing the polygon.
The plans:

    |                      /               | /
    |                     /                |/
----+----            ----+----             +
    |                   /                 /|
    |    XY plan.      /      XZ plan.   / |   YZ plan.

Polyhedrons generators

pyglut.generate_tetrahedron(side_length)

Generate an tetrahedron in relationship to the given side length.

And return an sequence from triangles composing the tetrahedron.

Parameters:side_length – The side length of the tetrahedron’s sides.

This low-level function does not generate an tetrahedron object but return an sequence of 4 triangles composing the tetrahedron.

Returns:An list of triangles, within each triangles is an sequence of 3 objects from type Vertex.
pyglut.generate_cube(side_length)

Generate an cube in relationship to the given side length.

And return an sequence from quads composing the cube.

Parameters:side_length – The side length of the cube’s sides.

This low-level function does not generate an cube object but return an sequence of 6 quads composing the cube.

Returns:An list of quads, within each quad is an sequence of 4 objects from type Vertex.
pyglut.generate_octahedron(side_length)

Generate an octahedron from the given side length.

And return an sequence from triangles composing the octahedron.

Parameters:side_length – The side length of the octahedron’s sides.

This low-level function does not generate an octahedron object but return an sequence of 8 triangles composing the octahedron.

Returns:An list of triangles, within each triangles is an sequence of 3 objects from type Vertex.
pyglut.generate_dodecahedron(side_length)

Generate an dodecahedron in relationship to the argument side_length taken as basis for the dodecahedron generation.

And return an sequence of pentagons composing the dodecahedron.

Parameters:side_length – The side length of the icosahedron’s sides using for generate the dodecahedron.

This low-level function does not generate an dodecahedron object but return an sequence of 12 pentagons composing the dodecahedron.

Returns:An list of pentagons, within each pentagons is an sequence of 5 objects from type Vertex.

Note

BUGFIX

This function does not return an exact dodecahedron.

It is based on an icosahedron construction but all issues pentagons have one side which is not equal to the others from the same pentagon.

But the illusion of an dodecahedron is maintain.

If you have an solution thank’s to inform me about at: <mrcyberfighter@gmail.com>.

pyglut.generate_icosahedron(side_length)

Generate an icosahedron from the given side length.

And return an array of 20 triangles component from the icosahedron and

his construction base quad set.

Parameters:side_length – The side length of the icosahedron’s sides.

This low-level function does not generate an icosahedron object but return an sequence of 20 triangles composing the icosahedron and an array of the 3 base quads (build with the golden number).

Returns:An list of the 3 basis quads and An list of triangles, within each triangle is an sequence of 3 objects from type Vertex.
pyglut.generate_fulleren(side_length)

Generate an fulleren from the given side length and return 2 arrays:

  • an sequence containing hexagons,
  • an sequence containing pentagons,

composing the fulleren.

an fulleren is an 3D polyhedron likewise an soccer ball.

Parameters:side_length – The side length of the fulleren’s sides.

This low-level function does not generate an fulleren object but return an 2-items array (hexagons,pentagons) composing the fulleren.

Returns:An list of hexagons and an list of pentagons within each is composed of objects from type Vertex.
pyglut.generate_toros(base, base_radius, toros_radius)

Generate an toros in relationship to the given settings:

  • base: the toros basis polygon.
  • base_radius: the toros basis polygon radius.
  • toros_radius: the torod radius (without the base polygon radius.).

and return an sequence of polygons base from the toros.

Parameters:
  • base – The base polygon edges number, for the toros.
  • base_radius – The base polygon radius, for the toros.
  • toros_radius – The toros radius.

This low-level function does not generate an toros object but return the polygons to assembly the toros.

Returns:An list of polygons within each is composed of objects from type Vertex composing the toros.
pyglut.generate_polyhedron_26_faces(side_length)

Generate an 26 faces polyhedron from the given side length and return:

  • An sequence of 8 triangles
  • An sequence of 18 quads

composing the 26 faces of the polyhedron.

Parameters:side_length – The side length of the 26 faces polyhedron.

This low-level function does not generate an 26-faces-polyhedron object but return an 2-item array (triangles,quads) composing the 26 faces polyhedron.

Returns:An list of triangles and an list of quads within each is composed of objects from type Vertex.
pyglut.generate_polyhedron_32_faces(side_length)

Generate an 32 faces polyhedron from the given side length and return:

  • an sequence of the triangles.
  • an sequence of the pentagons.
Parameters:side_length – The side length of the 32 faces polyhedron.

This low-level function does not generate an 32-faces-polyhedron object but return an 2-item array (triangles,pentagons) composing the 32 faces polyhedron.

Returns:An list of triangles and an list of pentagons within each is composed of objects from type Vertex.

Spheres generators

pyglut.generate_quad_sphere(basis, radius)

Generate an quads sphere and return an tuple from 2 arrays:

(base polygons, quads).

In relationship with the base for the sphere generating: faces count = basis * basis

and the given sphere radius.

Parameters:
  • basis

    The polygon to take as basis for the quad sphere generation.

    Must be % 2 == 0.

  • radius – The quad sphere radius.

This low-level function does not generate an quad sphere object but return an 2-item array (base polygons, quads) each can be using to display the quad sphere.

Returns:An list of polygons and an list of quads within each is composed of objects from type Vertex.
pyglut.generate_trigon_sphere(basis, radius)

Generate an trigon sphere and return an tuple from 2 arrays:

(base polygons, trigons).

In relationship with the base for the sphere generating: faces count = basis * basis

and the given sphere radius.

Parameters:
  • basis

    The polygon to take as basis for the trigon sphere generation.

    Must be % 4 == 0.

  • radius – The trigon sphere radius.

This low-level function does not generate an trigon sphere object but return an 2-item array (base polygons, trigons) each can be using to display the trigon sphere.

Returns:An list of polygons and an list of trigons within each is composed of objects from type Vertex.

Table Of Contents

Previous topic

pyglut utils

Next topic

pyglut polyhedrons

This Page