added preliminary calculations
adding intersection detection code