your code is incredibly hard to follow as the names for variables is poorly chosen and there are not too much in the comments department.
also, what happens when some of your points have the same y value? step through your code and see if you can see what happens?
what is a bottom half and top half of triangle? what is a top, middle, and bottom point? perhaps draw a pic and put it with your post?