Reputation: 43
I want to calculate the total length of the Linear (Straight curves) by Ignoring the bends. Note: Bend angle will be 90 degrees.
I have a solution but need it in an optimal way or any formula will be welcomed.
Current Solution:
Upvotes: 0
Views: 245
Reputation:
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.
Upvotes: 1
Reputation: 80197
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
Upvotes: 1