Java: Orthogonalization of functions