Quote:The way jyk proposed above is good in efficiency, right you are, but it relies in that the z axis (or which ever) is correctly aligned, and alignes the other axes accordingly to this assumption.You are absolutely right about that. If the angular displacement isn't too great this can be a reasonable approximation. (For example, I think the Doom 3 physics library uses this method for 3x3 matrix orthogonalization.) For the sake of simplicity I gave the example using a 'fixed forward' axis. In my own code however, the orthogonalization function is set up to perform n steps of iterative Gram-Schmidt first, where n is an argument and can be zero, and then finalizes with the cross-product method. For this latter step (which is the only step if n is zero), the caller can specify which of the three axis' direction is unchanged. For example, if the object is a spaceship you might choose to leave its forward direction unchanged by the orthogonalization.
As this thread shows, there are various ways to do it, and I may switch to something else in the future. But for now I like the above method as it gives the option of quick 'n dirty if you don't mind the approximation, or iterative if for some reason you need to converge on the solution.