Well, in my collision detection, I take any polygon and a point. To see if that point is within the polygon, I project a line in one direction away from that point and check how many sides of the polygon it intersects with. If the number is odd, its inside the polygon. If the number if even, it's outside. This works for any shape polygon with any number of sides, even if the polygon has holes in it etc.
Anyways, I use y=mx+c and simulatenous equations to find out where the line being projected and each side of the polygon intersect. Works pretty well, but obviously for vertical and horizontal lines the m part of the equation gets messed up, as you cant represent vertical gradients using m.
Insiiiiiiiiiiiiiiiiiiiiiiiide!