vulk.math package

Submodules

vulk.math.interpolation module

class vulk.math.interpolation.Bounce(bounces)[source]

Bases: vulk.math.interpolation.BounceOut

apply(a)[source]
class vulk.math.interpolation.BounceIn(bounces)[source]

Bases: vulk.math.interpolation.BounceOut

apply(a)[source]
class vulk.math.interpolation.BounceOut(bounces)[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Circle[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.CircleIn[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.CircleOut[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Elastic(value, power, bounces, scale)[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.ElasticIn(value, power, bounces, scale)[source]

Bases: vulk.math.interpolation.Elastic

apply(a)[source]
class vulk.math.interpolation.ElasticOut(value, power, bounces, scale)[source]

Bases: vulk.math.interpolation.Elastic

apply(a)[source]
class vulk.math.interpolation.Exp(value, power)[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.ExpIn(value, power)[source]

Bases: vulk.math.interpolation.Exp

apply(a)[source]
class vulk.math.interpolation.ExpOut(value, power)[source]

Bases: vulk.math.interpolation.Exp

apply(a)[source]
class vulk.math.interpolation.Interpolation[source]

Bases: abc.ABC

apply(a)[source]
class vulk.math.interpolation.Linear[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Pow(power)[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.PowIn(power)[source]

Bases: vulk.math.interpolation.Pow

apply(a)[source]
class vulk.math.interpolation.PowOut(power)[source]

Bases: vulk.math.interpolation.Pow

apply(a)[source]
class vulk.math.interpolation.Sine[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.SineIn[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.SineOut[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Smooth[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Smooth2[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Smoother[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.Swing(scale)[source]

Bases: vulk.math.interpolation.Interpolation

apply(a)[source]
class vulk.math.interpolation.SwingIn(scale)[source]

Bases: vulk.math.interpolation.Swing

apply(a)[source]
class vulk.math.interpolation.SwingOut(scale)[source]

Bases: vulk.math.interpolation.Swing

apply(a)[source]

vulk.math.matrix module

Matrix module

This module contains all class relative to Matrices. In graphic computing, matrices is a key to manipulate object in space. I recommand you to read this article to understand what is the main goal of matrices: http://www.codinglabs.net/article_world_view_projection_matrix.aspx

class vulk.math.matrix.Matrix(values)[source]

Bases: object

Base class for Matrix

set(matrix)[source]

Set this matrix to matrix

Parameters:

  • matrix: Matrix to set
set2(values, offset=0)[source]

Set this matrix to values from offset

Parameters:

  • values: list of float
  • offset: Start of the update
values
class vulk.math.matrix.Matrix3(values=None)[source]

Bases: vulk.math.matrix.Matrix

Matrix3 class

class vulk.math.matrix.Matrix4(values=None)[source]

Bases: vulk.math.matrix.Matrix

Matrix4 class

inv()[source]

Inverse this matrix

mul(matrix)[source]

Multiply this matrix by matrix The order of operation is: this @ matrix.

Parameters:

  • matrix: Matrix4
to_identity()[source]

Set this matrix to identity matrix

class vulk.math.matrix.ProjectionMatrix(values=None)[source]

Bases: vulk.math.matrix.Matrix4

This class represents a projection Matrix.

Projection is the last step to compute Vertex position. It must be applied after the view matrix.

to_orthographic(left, right, bottom, top, near, far)[source]

Set this matrix to an orthographic projection matrix

Parameters:

  • left: Left clipping plane
  • right: Right clipping plane
  • bottom: Bottom clipping plane
  • top: Top clipping plane
  • near: Near clipping plane
  • far: Far clipping plane
**Note: Vulkan coordinate system is not the same as OpenGL,
thus the matrix is adapted to Vulkan**
to_orthographic_2d(x, y, width, height, near=0, far=1)[source]

Set this matrix to an orthographic matrix used in 2D rendering

Parameters:

  • x: X coordinate of the origin
  • y: Y coordinate of the origin
  • width: Width
  • hight: Height
  • near: Near plane
  • Far: Far plane
class vulk.math.matrix.TransformationMatrix(values=None)[source]

Bases: vulk.math.matrix.Matrix4

This class represents a transformation Matrix.

It’s a Matrix4 with added capabilities used to transform model space to world space.

to_translation(x, y, z)[source]

Set this matrix to a translation matrix. First set it to identity and then set the 4th column to the translation vector.

Parameters:

  • x: x-component of translation vector
  • y: y-component of translation vector
  • z: z-component of translation vector
class vulk.math.matrix.ViewMatrix(values=None)[source]

Bases: vulk.math.matrix.Matrix4

This class represents a view Matrix.

View Matrix convert vertex from World space to View space.

to_look_at(position, target, up)[source]

Set this matrix to a look at matrix with a position, target and up vector.

Parameters:

  • position: Position Vector3
  • direction: Direction Vector3
  • up: Up Vector3
to_look_at_direction(direction, up)[source]

Set this matrix to a look at matrix with a direction and a up vector.

Parameters:

  • direction: Direction Vector3
  • up: Up Vector3

vulk.math.plane module

class vulk.math.plane.Plane(normal=None, distance=0)[source]

Bases: object

Back = 2
Front = 3
OnPlane = 1
setFromVector3(v0, v1, v2)[source]

vulk.math.shape module

class vulk.math.shape.Rectangle(x=0, y=0, width=0, height=0)[source]

Bases: object

contains(x, y)[source]
overlaps(r)[source]
set(rectangle)[source]

vulk.math.vector module

Vector module

This module contains all Vector classes definition. Vector are a key of graphic computing.

class vulk.math.vector.Vector(values)[source]

Bases: object

Base class for Vector

Exemple:

` v1 += 10 # Add 10 to all components v1 += [10, 9, 8] # Add a different value to each component dot_product = v1 @ v2 # Dot product use the matmul operator `

**Note: Vector is just a wrapper around a numpy array. You can
get directly the numpy array if you need more power**
add(vector)[source]

Add vector to this vector

Parameters:

  • vector: Vector3
add2(values)[source]

Add values to this vector

Parameters:

  • values: list of float
crs(vector)[source]

Return the cross product between the two vectors

Parameters:

  • vector: Vector of the same size
crs2(values)[source]

Set this vector to the cross product with values

Parameters:

  • values: list of 3 float
nor()[source]

Normalize the vector and return it for chaining

size

Return the size of vector

sub(vector)[source]

Substract vector from this vector

Parameters:

  • vector: Vector3
sub2(values)[source]

Substract values from this vector

Parameters:

  • values: list of float
values
class vulk.math.vector.Vector2(values=None)[source]

Bases: vulk.math.vector.Vector, vulk.math.vector.XMixin, vulk.math.vector.YMixin

Vector2 class represents a Vector in 2D space. It has two components x and y.

X = <vulk.math.vector.Vector2 object>
Y = <vulk.math.vector.Vector2 object>
Zero = <vulk.math.vector.Vector2 object>
class vulk.math.vector.Vector3(values=None)[source]

Bases: vulk.math.vector.Vector, vulk.math.vector.XMixin, vulk.math.vector.YMixin, vulk.math.vector.ZMixin

Vector3 class represents a Vector in 3D space. It has three components x, y and z.

X = <vulk.math.vector.Vector3 object>
Y = <vulk.math.vector.Vector3 object>
Z = <vulk.math.vector.Vector3 object>
Zero = <vulk.math.vector.Vector3 object>
mul(vector)[source]

Multiply this vector by vector.

Parameters:

  • vector: Vector3
mul2(matrix)[source]

Multiply this vector by a Matrix4

Parameters:

  • matrix: Matrix4
prj(matrix)[source]

Project this vector to the matrix parameter. It’s just a multiplication followed by a division by w.

Parameters:

  • matrix: Matrix4
set(x, y, z)[source]

Set values of this vector

Parameters:

  • x, y, z: float
set2(vector)[source]

Set values of this vector

Parameters:

  • vector: Vector3
class vulk.math.vector.Vector4(values=None)[source]

Bases: vulk.math.vector.Vector, vulk.math.vector.XMixin, vulk.math.vector.YMixin, vulk.math.vector.ZMixin, vulk.math.vector.WMixin

Vector4 class represents a Vector in 3D space. It has four components x, y, z, w.

mul(vector)[source]

Multiply this vector by vector.

Parameters:

  • vector: Vector4
mul2(matrix)[source]

Multiply this vector by a Matrix4

Parameters:

  • matrix: Matrix4
norw()[source]

W normalization of this vector. All components are divided by w, w must not be 0.

set(vector)[source]

Set this Vector4 to vector.

Parameters:

  • vector: Vector4
set2(vector)[source]

Set this Vector4 to vector and set w to 1.

Parameters:

  • vector: Vector3
class vulk.math.vector.WMixin[source]

Bases: object

Mixin adding w property to class

w
class vulk.math.vector.XMixin[source]

Bases: object

Mixin adding x property to class

x
class vulk.math.vector.YMixin[source]

Bases: object

Mixin adding y property to class

y
class vulk.math.vector.ZMixin[source]

Bases: object

Mixin adding z property to class

z

Module contents