changed code style
small refactoring
fixed calculation error in edge intersection
Fixed algorithm