How to calculate coordinates and line segments

Like this:

A clearer version of the BP ( auto format not always a good thing ):