Transformation

This module contain a Matrix class, used for our Graphics calculation. We are supporting:

  • rotation, translation, scaling matrix
  • multiply matrix
  • create clip matrix (with or without perspective)
  • transform 3d touch on a matrix

Changed in version 1.6.0: Added Matrix.perspective(), Matrix.look_at(), Matrix.transpose()

class kivy.graphics.transformation.Matrix

Bases: object

Optimized matrix class for OpenGL:

>>> from kivy.graphics.transformation import Matrix
>>> m = Matrix()
>>> print m
[[ 1.000000 0.000000 0.000000 0.000000 ]
[ 0.000000 1.000000 0.000000 0.000000 ]
[ 0.000000 0.000000 1.000000 0.000000 ]
[ 0.000000 0.000000 0.000000 1.000000 ]]

[ 0   1   2   3]
[ 4   5   6   7]
[ 8   9  10  11]
[ 12  13  14  15]
identity()

Reset matrix to identity matrix (inplace)

inverse()

Return the inverse of the matrix as a new Matrix.

look_at()

returns a new lookat Matrix (simmilar to gluLookAt)

New in version 1.6.0.

multiply()

Multiply the given matrix with self (from the left). I.e., we premultiply the given matrix to the current matrix and return the result (not inplace):

m.multiply(n) -> n * m
normal_matrix()

Computes the normal matrix, which is the inverse transpose of the top left 3x3 modelview matrix used to transform normals into eye/camera space.

New in version 1.6.0.

perspective()

Creates a perspective matrix (inplace)

New in version 1.6.0.

rotate()

Rotate the matrix with the angle, around the axis (x, y, z)

scale()

Scale the matrix current Matrix (inplace).

translate()

Translate the matrix

transpose()

Return the transposed of the matrix as a new Matrix.

New in version 1.6.0.

view_clip()

Create a clip matrix (inplace)

Changed in version 1.6.0: Enable support for perspective parameter