Edge collision detection first version. needs corrections.