Someone have an idea how i can calculate the position?

Viewed 60

So I have triangles and getting Information of which triangles is on what Connection.
like so:

[
{id:3
connected:[2,1,null]}
{id:1
connected:[null,null,3]}
{id:2
connected:[4,3,null]}
{id:4
connected:[2,null,null]}
]

It would look like this:

enter image description here

I need some method to calculate the X- and Y-position and rotation
When i hard code it would look like this:

[
        {
          id: 3,
          x: 200,
          y: 200,
          radius: 100,
          rotation: 0,
        },
        {
          id: 1,
          x: 300,
          y: 150,
          radius: 100,
          rotation: 180,
        },
        {
          id: 2,
          x: 200,
          y: 310,
          radius: 100,
          rotation: 180,
        },
        {
          id: 4,
          x: 300,
          y: 360,
          radius: 100,
          rotation: 0,
        },
]
0 Answers
Related