Hi, I was exploring codea and found matrix, what is a matrix?

It’s a grid of numbers. In codea, the native matrices are 4x4, meaning that they have four rows and four columns. The identity matrix is thus:

```
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 0
```

If you want more details, you should explain what context you are talking in - conceptual or coding.

Ok, whats help me a matrix when i programming? or what is the funcionality of a matrix?

Some objects, such as meshes, can use a 3d coordinate system internally. When rendered onto the screen, this has to be projected to a 2d system. The matrix is one step in that projection that allows you considerable freedom as to how that projection is done. My roller coaster in the example project works by manipulating the matrix: the planks are actually stationary the movement all comes from changing how they are projected onto the screen.

I don’t understand clear, You can give me a example of a code that us a matrix?

In the example projects there is one called “Roller Coaster”. That uses matrix manipulation.

Ok Thanks

A matrix is essentialy a 2D array, with the exception that it only holds numerical values (remember, Lua arrays can hold *anything*, including other arrays!). What’s neat about matrices is that you can operate on them in some pretty neat ways, making 3D much easier to deal with.

Here’s a really awesome link which gives you a good introduction to what matrices are and what to use them for: http://stackoverflow.com/questions/487352/learning-game-programming-part-2-math

Check out this tutorial, it is written about another programming language called processing, but it is very similar to Codea. Most of what you want to know is here: