 # Create adjustable 5 line shape with whole number line lengths with 1 set angle & 3 right angles

Hi all, I need to create a Grasshopper definition that works out 5 line lengths to the nearest whole number including an angled line. Below is a image or link to better illustrate what I mean.

The problem is I have a 5 line shape with three set right angles as illustrated in the image and one angled line and I need to preserve the angled line angle while adjusting the remaining 4 lines.

I have a small amount of room for movement along the x axis for the angled line so as to enable the adjustment of the lengths of the other 4 lines. The key is to arrive at a point where all 5 lines lengths have no decimals (whole numbers).

II have several of these shapes to work out with the unique angle line, so ideally I need a definition that can update for each problem, possibly with a slider to adjust the length of the lines around the predetermined angle.

I look forward to some assistance with my problem.

Looking just at the diagonal line there, what you are asking is equivalent to finding a right-angled triangle with integer side lengths - a Pythagorean triple.
These do not exist for arbitrary angles, so what you are asking is impossible in the general case.

(from the Wikipedia article above)

Hi Daniel, thank you for your feedback. You will note that my triangle has a cut off corner which is to take that fact into account. This means the short right angle line on the right in my drawing can be moved along the x axis as can the long right angle line. The angled line points would update accordingly all the while maintaining the predetermined angle.
I am attempting to save myself time of going through a range of line measurements individually to arrive at the working solution. My skills are not up to the challenge hence my asking for assistance.

If your top and bottom horizontal lines are both integer length, then the width of the diagonal line is their difference - which must be another whole number.
Same for the vertical lines and its height.
Therefore no solution exists for arbitrary angle.

Hi Daniel, thank you for pointing that out to me. I understand the error in my thinking. A good case for taking math’s further than I did.
All the best, Rob.

1 Like