Why does the author of the code choose to use a shift operation for the indicies of his array of numbers in his matrix?
Here is an example of his code
Code: Select all
void matrix_identity(float* matrix)
{
matrix[(0<<2)+0] = 1.0f;
matrix[(0<<2)+1] = 0.0f;
matrix[(0<<2)+2] = 0.0f;
matrix[(0<<2)+3] = 0.0f;
matrix[(1<<2)+0] = 0.0f;
matrix[(1<<2)+1] = 1.0f;
matrix[(1<<2)+2] = 0.0f;
matrix[(1<<2)+3] = 0.0f;
matrix[(2<<2)+0] = 0.0f;
matrix[(2<<2)+1] = 0.0f;
matrix[(2<<2)+2] = 1.0f;
matrix[(2<<2)+3] = 0.0f;
matrix[(3<<2)+0] = 0.0f;
matrix[(3<<2)+1] = 0.0f;
matrix[(3<<2)+2] = 0.0f;
matrix[(3<<2)+3] = 1.0f;
}
Code: Select all
matrix[(3<<2)+3]
Code: Select all
matrix[15]
Please enlighten me.