The heisenberg exchange integral in a non-orthogonal basis for antiferromagnetic and ferromagnetic systems