< Previous | Contents | Next >

Usage

To create a Matrix4 object, you can call:


-- <table> is a table of 16 elements mat = Matrix4(<table>)


To convert a Matrix4 object back to a table (for printing etc...), call:


<table> = mat:GetTable()


Most matrix methods modify the existing matrix object and "add" their transformations to it (e.g. Move(), Scale(), ...). The Inverse() and Transpose() methods, however, simply return the desired matrix without modifying the object itself.

image

mat1 = Matrix4() mat2 = Matrix4()

mat3 = mat1 * mat2

-- transform defined by mat1 followed by transform defined by mat2

The Matrix4 class has overloaded operators in LUA, which means you can multiply and add matrices by simply writing