Saturday, 1 October 2011

Unit Tests, Love Hate

Today I decided to try and get some unit tests created for the matrix functions which I implemented in yesterdays push (https://github.com/saecob/gladius.math/tree/Matrix2).

After spending some time identifying how unit tests are launched (index.html),


I created my own test script with the name Math.Matrix2.js which tests 2 x 2 matrices.

When I first ran the newly created test, I noticed that none of the coded implementations of any size matrix had been tested.  After further inspection, the matrix functions seem to be direct logic and code copies of all the implemented vector functions.

At first glance this doesn't seem to be such a big problem but I don't think that they correlate exactly.

The second issue which came about from these discoveries is, that at the moment I feel like I am implementing and adding functions arbitrarily not knowing if they will even be useful to someone using the library.

For example, we have a function rotate() which creates a rotation matrix given a Quaternion(http://en.wikipedia.org/wiki/Quaternion). This function is implemented under matrix4 functions, i.e 4x4 matrices.

The question is: Do we need this function for 2x2 and 3x3 matrices as well?

        // Construct a 2x2 rotation matrix from a Quaternion.
        rotate: function() {
            if( 0 === arguments.length ) {
                return Matrix( 4, that.matrix2.identity );
            } else if( 1 === arguments.length ) {
                var v = arguments[0];
                var r = v[0];
//              return Matrix( 4, [] );
            // Todo (Quaternion = w + xi + yj + zk)
            } else {
                return Matrix( 4, arguments );
            }
        }
    };


It seems like it would be a good idea to collaborate with the different areas of the project (Physics, Rendering, etc.) and come up with an interface with a list of functions, parameters, and return types/values so that everything put in Gladius.Math is useful as a library.

Thursday, 29 September 2011

An Ode To Math

Recently I decided to contribute to the Gladius/Paladin (https://github.com/alankligman/gladius) open source project, more specifically, the Gladius.Math(https://github.com/alankligman/gladius.math) library.  Having only recently decided to get involved with the project, I was feeling a little overwhelmed but excited as well.

The issues/tickets I have decided to work on are the implementations of several math functions involving various size matrices and vectors.

In order to scope this correctly I decided to start with all the functions for 2x2 matrices, then 3x3 and so forth.  For each matrix size from 2x2 to 4x4 there are a number of functions which perform various operations, or specifically:
  • Translate
  • Scale
  • Rotate 
Everyone loves wiki links:
Translations - http://en.wikipedia.org/wiki/Translation_%28geometry%29
Scaling - http://en.wikipedia.org/wiki/Scaling_%28geometry%29
Rotations - http://en.wikipedia.org/wiki/Rotation_matrix

Also an interesting read: http://knol.google.com/k/matrices-for-3d-applications-translation-rotation#

For my first push I implemented these functions for 2x2 matrices.  The unit testing will be the next major focus in order to determine performance and test logic.

Take a look at the code yourself : https://github.com/saecob/gladius.math/commit/20caebde7578ca3a772440a7bc2b2421740b51e6#L0R548

While coding I noticed that there were a number of basic matrix functions which were missing  and a number which didn't seem to be present in other math libraries which i used for code examples.

If I'm going to spend some time with this library I think I'll need to look at some other game engine math libraries to see if there are functions which would help to include.

To Git, Or Not To Git

After being introduced to GitHub (www.github.com) a few weeks ago, I thought that things were pretty straight forward and easy to use, that is until you actually start doing some work of course. 

The Git Bash tool, used to communicate with the Git server and to organized your branches and repositories, uses many different commands to do these things which I found very difficult to remember when it came down to working with them.

Luckily Git provides lots of support and guides to help new users like me along.  Here are some which I found helpful.

http://help.github.com/ - The main hub of information on all things Git
http://help.github.com/git-cheat-sheets/ - A compilation of cheat sheets and quick guides to using the bash commands.

I found these resources very helpful and I thought I would share.

Wednesday, 28 September 2011

Out With The Old, In With The New

I decided to change the layout a bit to make the blog easier to read and a little more pleasant.

This afternoon I decided to dedicate my efforts to contributing to an Open Source project named Gladius/Paladin (https://wiki.mozilla.org/Paladin) which is a browser game engine written in Javascript.

After looking at the code (https://github.com/alankligman/gladius), and recovering from being overwhelmed, made a local copy of the repository to browse on my own time.

More to come...

Monday, 26 September 2011

Obligatory First Post

After putting this off for too many months, the blog is finally up.

Just creating this page i realized the astounding number of customization options available to the general blogger on the internet today.  I'm going to have to spend some time getting this set up just right.

- Sergiu