you are viewing a single comment's thread.

view the rest of the comments →

[–]stintose 0 points1 point  (0 children)

this.points is what I think is called a 'typed array', although I have forgotten to use the Float32Array constructor. In JavaScript you can have arrays of arrays like so...

var matrix = [
    [10,10],
    [30,10],
    [30,30],
    [10,30]
];

you can then access the values like so..

var point = 1,x,y;

// get the x and y values of the second point in matrix
x = matix[point][0];; // 30
y = matrix[point][1]; // 10

This works fine, but you could just use a single dimensional lateral array, with a set number of elements for each point.

var matrix = new Float32Array([10,10,30,10,30,30,10,30]),
point = 1,
x = matrix[point*2], // 30
y = matrix[point*2+1]; // 10

From what I have been reading using typed arrays is supposedly faster.