Adding 3D angle algorithm for matching --ahack