Polygon by Edge Length and Angle

Hey everyone,

I have a dataset in which i have set of line lengths and angles for two corners. I am trying to create polygons using edge lengths and angle for its two corners and add dimensions to them. But i have failed to create lines by length and the polygon by connecting and defining an angle between two lines. Following picture will explain what i am trying to do better i hope. i have attached example file as well. Any help is welcomed

ex_data_polygonByLengthAndAngle.csv (98 Bytes)

I use solely Office Libre (meaning that there’s some “minor” issues reading excel like OL sheets via C# [I work only that way]).

Anyway and assuming that your data are correct:

  1. Assume that we are working counter clock wise.
  2. Get bottom value (d2) and define pts p1 (at some origin) and p2 (p1 + PlaneXY.XAxis * d2).
  3. Get the p2-p1 Vector and rotate counterclockwise by a2. Unitize. Multiply by the right value (d4).
  4. Get p3 (p3 = p2 + the Vector in 3).
  5. When at the last “segment” … decide either to abort (faulty data) or close the loop according some tol value.
  6. Define a Polyline from all the pts and then add the first (closed Polyline, that is).
  7. Define a “shifted” new origin and repeat.

Or … sample your data in a DataTree (in the correct order I do hope) and post it here.

1 Like

Hi @mucahitbgoker

If your polygon has to lie in a plane this is overconstrained.
You can specify 4 lengths and one angle, and that determines all the other angles.

@DanielPiker you are absolutely right. it should be 1 angle 4 dimensions or 2 angles 3 dimensions.

i have done what you said but in grasshopper :slight_smile: i have created the geometry using one row and it generated desired result. thanks for that. i will try it with multiple lines of data and see whether if it works or not.

Well … you guess what the attached is (I guess):

Polyline_RndFromData_V1.gh (122.1 KB)

This works using a random demo (*) dTree (containing the right amount of info for the job: lengths and angles - spot that the last branch [per Polyline] contains only length value). PRIOR inputing your stuff (say from excel) … check how the data are organized [for counter clock wise Polyline creation].

For instance if you want solely demo triangles (Set sidesMin, sidesMax = 3): this is the info required (angle [i.e. item 2 per branch - if exists ] is the curr-next segment angle in rad)

Layout does what a classic layout does.

(*) If you input bananas … blah, blah,

BTW: If on the other hand you have overconstrained data and you want to check them for valitidy (meaning if a valid Polyline can come out of them) … well … in this case a few lines of code more are required.