orthonormalization
gram-schmidt orthonormalization is really elegant, but i haven't had occasion to use it in practice. a common situation i run into requires creating an orthonormal basis from three 3d vectors which start pretty close to orthogonal. for example, say you have a forward vector and also approximate right and up vectors and you want them all orthonormal. sounds like a perfect job for gram-schmidt orthonormalization right? sure, but it's more efficient to just do two cross products.
cross product method:
right = normalize(cross(up, forward))
up = cross(forward, right)
= 1 normalize + 12 multiplies + 6 subtracts
gram-schmidt method:
right = normalize(right - dot(right, forward)*forward)
up = normalize(up - dot(up, forward)*forward)
= 2 normalize + 12 multiplies + 6 adds + 6 subtracts
(note that a second normalize is skipped for the cross product method because forward is assumed to be unit length and the cross product of two unit length vectors is also unit length. note also for the gram-schmidt method that subtracting the projection of up onto right is skipped because the right and up approximations we started with are assumed to be orthogonal.)
is there any use of gram-schmidt orthonormalization in three dimensions that can't be replaced by a more efficient algorithm with cross products?