Constructing triangles with known edge lengths

Hi, I’m making a script that does some sort of flattening of strips.
The strips are defined by polylines (and theirs offsets), so the method should be simple. get triangles from the strips, and draw the same triangles sequentially on a plane.

But I just noticed, just drawing a triangle based on known edge lengths is not an easy task. I cannot find any built-in component that does this. I’m very curious how people are achieving this.

I’d omit solutions by circles and Kangaroo, since I assume there are more direct solutions.
Please help!

To me, what you’re saying is the same as the function of “Unroll Brep”. There’re many plugins that have the feature or script components.

depending on your needs, you could also look into Ivy

Thanks for the solution(s)!
But I want to script on my own to gain control over the geometry.

If you want to script it , once you have a edge you can make 2 circles with radius equal to the triangle edges, intersection of these 2 circles gives the third point, which point to choose depends on winding CCW or CW of the source triangle.

Hi, thanks! But as I wrote in the original post, I don’t want to call a circle-circle intersection.
I assume there is a more direct way…

Alternative is using angles and vectors and cross product for orientation

Gd

I made my own script to do that. I have a MeshUnroller (similar to McNeel one) and a Mesh Flattener (suppress inner point of a mesh).
It is useful to make the whole script as sometime mesh will self intersect during unrolling, so you’ll have to cut it and add some geometry.

So my advice, built your own library (a dll), it will help you to do more complex things and also more tune able.

You wrote this after I created a model. Still, there may be issues you haven’t considered in trying to script your own unroll component.


triangles_2021Feb7a.gh (11.1 KB)

The purple group shows two of them:

  1. location of first point?
  2. location of second point relative to the first point?

When those two points are established, the next issue is which side of the line between them do you want the triangle? As you can see, there are two possibilities. Unrolling a series of triangular panels so they remain adjacent and connected is not trivial - unless you use existing code.

Ya, this is the one! Thanks!

wrote it.
input: crv1,crv2
output: pp,qq

import Rhino.Geometry as rg
import math
for i in range(crv1.Count-1):
    p=crv1[i]
    q=crv1[i+1]
    r=crv2[i]
    w=crv2[i+1]
    if i==0:
        pp=[rg.Point3d(0,,0)]
        L=(r-p).Length
        qq=[rg.Point3d(0,-L,0)]
    A=(r-p).Length
    B=(q-p).Length
    C=(r-q).Length
    _cos=(q-p)*(r-p)/A/B
    theta=math.acos(_cos)
    R=rg.Transform.Rotation(theta,rg.Vector3d(0,0,1),pp[i])
    V=qq[i]-pp[i]
    V.Transform(R)
    V.Unitize()
    V*=B
    p=pp[i]
    p+=V
    print p
    pp.append(p)

    A=(w-q).Length
    B=(q-r).Length
    C=(w-r).Length
    _cos=(w-q)*(r-q)/A/B
    theta=math.acos(_cos)
    R=rg.Transform.Rotation(theta,rg.Vector3d(0,0,1),pp[i+1])
    V=qq[i]-pp[i+1]
    V.Transform(R)
    V.Unitize()
    V*=A
    r=pp[i+1]
    r+=V
    qq.append(r)
    

Then you may want Triangle Trigonometry:

But that still leaves all the issues I mentioned:

  1. location of first point?
  2. location of second point relative to the first point?
  3. which side of the line between them do you want the triangle?

First point arbitrary whatever you want, first edge arbitrary (You can make a transform at the end to position your flattened triangles) , orientation of the sides based on cross product of the original edges
Only first edge of the triangle group is arbitrary, afterwards you have all the data from previous flattened triangles based on connection data.

All this if your mesh is developable, if not you will have openings and overlaps based on mesh surface.

Well, that’s shoving aside a major complexity in “unrolling” a series of connected triangles so their edges stay connected.