Calculate Total Length of Given linear Curves ignoring Bends

Solution for Calculate Total Length of Given linear Curves ignoring Bends
is Given Below:

I want to calculate the total length of the Linear (Straight curves) by Ignoring the bends.
Note: Bend angle will be 90 degrees.

enter image description here

I have a solution but need it in an optimal way or any formula will be welcomed.

Current Solution:

  1. Calculate the endpoints of all Linear lines.
  2. Intersects the line and get virtual intersection points.
  3. Then calculate the distance between points with each linear line start and virtual intersection point.
  4. Sum all the lengths.

Don’t take it badly, but I fail to see a difficulty.

L = L1 + 2 R1 + L2 + 2 R2 + L3.

Note that the exact length (not ignoring bends) is

L = L1 + π/2 R1 + L2 + π/2 R2 + L3.

It is not quite clear what is done? Picture? Line segment and arcs description?

In any case – horizontal line will start at Y-coordinate of the previous vertical line and end at Y-coordinate of the next vertical line.

And vice versa – vertical line will start at X-coordinate of the previous horizontal line and end at X-coordinate of the next horizontal line.

So result is

 Sum(Abs(X(i+2) - X(i)))  +    //over horizontal lines
 Sum(Abs(Y(k+2) - Y(k)))  +     //over vertical lines
 two  end differences