Skip to content

Matplotlib

Implementation notes

The matplotlib implementation is only a partial implementation because of several limitations:

  • Depth buffer: matplotlib does not have a proper depth buffer that allows to test individual pixels. This means points/lines/triangles need to be sorted in order to draw them from back to front. Most of the time, this does the trick but there exist some situations where it is impossible to avoid problems. For example, consider two triangles that intersect each other. In in such a case, we have to decide arbitrarily which triangle will be drawn on top of the other.

  • Trilinear interpolation: there is no easy (nor fast) way to interpolate a color inside a triangle and this limits the kind of shading we can use. Namely, we can have flat shading (per face) but not Gouraud (per vertex) nor Phong (per pixel).

The matplotlib implementation relies a lot on numpy arrays because they're compatible with the Data/Buffer approach. However, this is only a design choice and it is possible to use other approaches. The only difficulty is to control memory usage such as not to make too many copies of buffer.

Status

Core

Visual

Zero dimension

One dimension

  • visual.Segments - create a collection of line segments
  • visual.Lines - create a collection of straight lines
  • visual.Paths - create a collection of smooth lines

Two dimensions

  • visual.Triangles - create a collection of triangles
  • visual.Polygons - create a collection of polygons
  • visual.Glyphs - create a collection of glyphs

Three dimensions

  • visual.Mesh - create a mesh
  • visual.Volume - create a volume

Transform

Base

Colors

Operators (T[n] × T[n] → T[n])

Accessors (T[n] → T[1])

Geometry (T[n] → T[n])

  • transform.Scale - Arbitrary scaling
  • transform.Translate - Arbitraty translation
  • transform.Rotate - Arbitraty rotation
  • transform.MVP - Model / View / Projection (T[n] → T[3])

Screen (JIT) (∅ → T[1])

Measure (T[n] → T[n])