d3d11.Matrix

A 4x4 row-major floating point matrix. Supports pickling.

Most methods completely override the old state, so “chaining” method calls is not possible.

m = Matrix()
m.scale((2, 2, 2)) #This is useless, it will be overwritten soon.
m.translate((0, 1, 4)) #Set m as a translation vector. All previous data is overwritten.

Methods

class Matrix
Matrix() → Matrix

Creates a new identity matrix.

Matrix(Matrix m) → Matrix

Creates a new matrix from another one.

Matrix(sequence) → Matrix

Creates a new matrix from a sequence. If the lenght of the sequence is 4 it is assumed to be a some kind of a matrix and will be accessed as sequence[row][col]. If the lenght of the sequence is 16 it will be accessed as a 1D-list, for example the list returned by toList() is a valid argument.

identity() → None

Sets self as an identity matrix.

invert() → float

Inverses self and returns the determinant. Raises an exception if the inverse can’t be done.

lookAt(eye, lookat, updir) → None
Parameters:
  • eye – Eye position vector.
  • lookat – Look-at position vector.
  • updir – Up direction, usually (0.0, 1.0, 0.0).

Sets self as a left handed view matrix.

orthographic(float w, float h, float zmin, float zmax) → None
Parameters:
  • w – Width of the view volume.
  • h – Height of the view volume.
  • zmin – Z-value of the near view-plane.
  • zmax – Z-value of the far view-plane.

Sets self as a left handed orthographic projection matrix.

perspectiveFov(float fov, float aspect, float zmin, float zmax) → None
Parameters:
  • fov – Field of view in radians.
  • aspect – Aspect ratio (width divided by height).
  • zmin – Z-value of the near view-plane.
  • zmax – Z-value of the far view-plane.

Sets self as a left handed perspective projection matrix.

rotate(xyz) → None

Sets self as a rotation matrix.

scale(xyz) → None

Sets self as a scaling matrix.

transformation([translation=(0, 0, 0), rotation=(0, 0, 0), scaling=(1, 1, 1), rotorigin=(0, 0, 0), scaleorigin=(0, 0, 0), scaleorientation=(0, 0, 0)]) → None
Parameters:
  • translation – Translation vector.
  • rotation – Rotation vector.
  • scaling – Scaling vector.
  • rotorigin – Rotation origin.
  • scaleorigin – Scaling origin.
  • scaleorientation – Scaling orientation vector.

Sets self as transformation vector.

transformNormal(vector) → Vector

Transforms the argument normal and returns the result.

transformVector(vector) → Vector

Transforms the argument vector and returns the result.

translate(xyz) → None

Sets self as a translation matrix.

transpose() → None

Transposes self.

toList() → list

Returns self as a 1D list.

Numeric protocol

class d3d11.Matrix
Matrix * Matrix -> Matrix

Matrix multiply. Also supports in-place (*=) operation.

Sequence protocol

Indices are zero-based.

class d3d11.Matrix
Matrix[row, column] -> float

Returns the indexed value.

Matrix[row, column] = float -> None

Sets the indexed value.

m = Matrix()
m[3,0] = 8.0 #Set x-translation to 8.0
m[3,1] = 5.0 #Set y-translation to 5.0
m[3,2] = 2.0 #Set z-translation to 2.0

Table Of Contents

Get DirectPython 11 at SourceForge.net. Fast, secure and Free Open Source software downloads