My favorites | Sign in
Project Home Issues Source
Project Information
Members
Links

vectypes provides 2, 3 and 4-element vector and matrix types for Python using an API very similar to GLSL. The types provided are:

  • float vectors: vec2, vec3, vec4
  • int vectors: ivec2, ivec3, ivec4
  • bool vectors: bvec2, bvec3, bvec4
  • square matrices: mat2, mat3, mat4
  • non-square matrices: mat2x3, mat2x4, mat3x2, mat3x4, mat4x2, mat4x3

Binary operators are overloaded for component-wise operations between a vector or matrix and a scalar, between two vectors, and between two matrices. Multiplication can also be done between a row vector and a matrix, between a matrix and a column vector, and between two matrices.

Additionally, the following vector and matrix functions are implemented:

  • length, distance, normalize
  • dot, cross
  • faceforward, reflect, refract
  • matrixCompMult, outerProduct, transpose

The module is provided as a single source file that can be distributed without requiring installation, or generated from template sources if customisation is desired.

Powered by Google Project Hosting