View Full Version : Matriz vs array?
SCELF
02-06-2009, 01:35 AM
Silly little question...
What's the difference between a Matrix/matriz and an array? I remember very little from highschool calculus so please don't bash on me :D
A few sources say that they are the same, and some other say they handle variables differently. Like, I remember arrays being used kinda like:
{
[0,0,0,0,0];
[0,0,0,0,0];
[0,0,1,0,0];
[0,1,1,1,0];
}
(Tetris T)
senocular
02-06-2009, 12:54 PM
Arrays are a series of ordered values. Matrices (i.e. more than one matrix) are 2-dimensional arrays - or arrays of arrays.
Array:
var array = ["a", "b", "c", "d", "e"];
array[0] = "a";
array[4] = "e";
Matrix:
var array = [
["a", "b", "c", "d", "e"],
["f", "g", "h", "i", "j"],
["k", "l", "m", "n", "o"],
["p", "q", "r", "s", "t"]
];
array[0][0] = "a";
array[0][4] = "e";
array[1][0] = "f";
array[2][2] = "m";
array[3][4] = "t";
ActionScript also has special objects that represent matrices. There's the Matrix object (a 3x3 matrix), and new to AS3 in Flash Player 10, Matrix3D (a 4x4 matrix). However, these are nothing more than wrapper classes for data which could otherwise be represented in 2D arrays. For example the ColorMatrixFilter class - which is not itself a matrix, but works with one, accepts matrix data in the form of a 4x5 matrix Array. The advantage of being in a class is that they can have special functions that work specifically on the matrix data. In the end, the data is still the same that would be represented in arrays.
SCELF
02-06-2009, 09:49 PM
Wow, you sir win +1 internets!
You answered my question and then some! The extra info REALLY helped out too. Thanks, I understand :)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.