Code:
cx=(x1+x2)/2
cy=(y1+y2)/2
Thats all it is.

Consider the line (123,456)-(765,432)

cx=(123+765)/2=444
cy=(456+432)/2=444

The center point is 444,444