matrix

(module)

A module for setting the current matrices used with various graphics functions in Codea

General

matrix.push()
matrix.pop()
matrix.reset()

Functions for manipulating the matrix stack, use these when you want to temporarily change current space-transform for drawing operations

matrix.model()
matrix.model(matrix)

Gets/sets the model matrix used to transform from local to world space

matrix.view()
matrix.view(matrix)

Gets/sets the view matrix used to transform from world to view space (generally controlled by cameras)

matrix.projection()
matrix.projection(matrix)

Gets/sets the projection matrix, used for final projection (i.e. othro and perspective projection)

Transform

matrix.transform2d(x, y[, sx = 1, sy = 1, r = 0])

Apply a generic 2D transform to the model matrix

matrix.transform3d(x, y, z, sx, sy, sz, rx, ry, rz)

Apply a generic 3D transform to the model matrix

matrix.translate(x, y[, z])

Translate the current model matrix

matrix.rotate(quat)
matrix.rotate(angle, x, y, z)

Rotate the current model matrix

matrix.scale(x, y[, z])

Scale the current model matrix

Projection

matrix.ortho()

Set the projection matrix to ortho using the device screen settings (i.e. coordinates range [0, 0] to [WIDTH, HEIGHT])

matrix.ortho(height)

Sets an orthographic projection matrix height units high, using the aspect ratio of the screen to set the width

Parameters:

height – The height of the orthographic projection

matrix.ortho(left, right, bottom, top[, near, far])

Sets an orthographic projection matrix using the supplied edge values

matrix.perspective(fov, aspect, near, far])

Sets a perspective projection matrix