Math trickery for 1D & 2D arrays

Once upon a time, there was a language that didn’t have 2 dimensional arrays. This greatly upset the programmer. Fortunately, the programmer was swift in the art of arithmetic and overcame this obstacle easily.

Lets say for example, we only have access to a 1 dimensional array data structure and it has 50 elements in it.

Lets break this array up into 10 rows and 5 columns to make a grid. So how do we get access to a position say data[4][3]?
There are two things I’m going to teach you now:
1) Retrieve the column & row numbers from a linear index counter.
2) Retrieve the index from a row & column numbers.

Before I continue, i want you to notice that the row and column numbers are zero based. So they start at zero, not one.

Lets do #1 first:

Read the rest of this entry »

Misc Useful Links

These are miscellaneous useful links that don’t really fit into any of the other categories I have.

Essential Mathematics Book Website
Gallery of Processor Cache Effects
Easy Git
IEEE-754 Floating Point References

Programmer Fonts
Design Patterns



The Physics Encyclopedia


Essential Math for Games Programmers

David Baraff’s Papers
Game Physics Resources

IBDS – Physics library
Ron Fedkiw
My Physics Lab – Math and Physics Section
Game Physics
David EberlyChris Hecker
Bullet Physics Forum
Math and Physics Forum –
Game Physics Resources
Erin’s Physics Weblog
Molly Rocket Forum
Real Time Collision Detection
Algorithms overview
Gino van den Bergen


Open Dynamics Engine
Dr. Jan Bender
Awesome Physics Engine
2D Physics Engine
Bullet Physics