I have a drawing in Autocad and I need to box-fit a set of pipes to match some input dimensions. For this I need to know the length, width and height for my set of pipes. I start from one end, grab the length of each pipe and then go to the next neighbour until I reach the other end.
For this question, I will only ask about the X axes, the others using the same logic. The distance between the start and end point is not always the total length.
For example in this image I can sum the values and it will output the correct length (3 - 1 + 2 = 4) Case 1
But in this image if I sum the values it will not output the correct length case 2
Can someone please help me with an algorithm that finds the maximum length on each axes, not for this 2 cases, but a general algorithm ? It doesn't matter the programming language, I just need the logic. Thank you!
I tried creating a Dictionary<string, int> to keep a record on each axes. I was finding the orientation of each pipe (e.g. X, -X, Y, -Y...) and adding it's length to the dictionary
var LengthAxes = new Dictionary<string, double>() { { "X", 0 }, { "Y", 0 }, { "Z", 0 } };
But it didn't go well since this will return the distance between the start and end point.