Earlier this year, an artist’s new model for a door became wildly popular on social media outlets like Twitter and Facebook.  And rightfully so–it’s pretty cool.  And I want one in my apartment!  It looks so simple, but it might not be immediately obvious how to wrap your head around how it works.  The artist’s name is Klemens Torggler.  He’s made a few different models of doors, which you can find online.  I like this one the best: Then someone started a contest–who can make this in Dynamo first?  Obviously I had to win.  But it also turns out that this is a great problem to show how to use the breadth of Dynamo’s capabilities–how to solve a spatial problem using anything and everything in the toolbox, whatever gets you there faster.  So here’s how.

You could be a boring math snob and figure this all out on paper with line drawings and plenty of trigonometry.  (I did that first.)  But that’s like owning a Ferrari and only driving to the grocery store once per week.  Dynamo can do so much more!  Check out how I figured this out, explanation below.  You can also download the attached .dyn file.  Then tell me how much smarter you are when you can solve this even faster.

To begin, remember that your ability to solve a problem is only as good as how well you understand what you are looking for.  Basically, we need to know where each of the door’s four panels are as the artist pushes the pivot point with his hand to open or close it.  In Dynamo-speak, we need 4 sets of 3 points, since there are 4 panels and each is a triangle. The door consists of two square sections, each divided in half along the diagonal.  The diagonals are where two triangular panels meet, connected with something like a piano hinge so that each square can fold as the door moves.  Just two pin joints, one at the top and one at the bottom, attach it to the wall.  And then there is a rotating joint, like your shoulder, where the two square sections meet at a single point.

Easy, right?  Some of the points are gimmes, some take just a little bit of effort, but one point–that ball hinge joint–can be tricky.  I used to tutor math and physics regularly, and I always stressed that a good diagram is critical.  Here’s mine. h = The total height of the door m = The position of the artist hand (the slider–your moving parameter) ? = The angle of the door’s rotation (0° – 90°) x = Distance from the wall to the pivot point

You know h and m, and to solve for all of the points, we’ll need to find the angle ? and the distance x.  Let’s get the angle first.  You can probably picture that the angle is directly related to the the parameters we already know, namely where the rotation joint is and the height of the door.  This will take some trig, but I promise it will be worth your while.  Back to that handy diagram…  Looking for a way to relate m to that angle, I found the blue triangle, in the plane of the wall: It’s a right triangle: the bottom is m and the side is half the height of the door, h/2, and the angle at the top is related to ?.  That equation is:

tan(?/4 – ?) = m / (h/2),
? = ?/4 – atan(2*m/h) Worry not, the pain is over.  No more trig.  The advantage is that with this angle, we can just take the points for the closed door and apply a rotational transform about the pin joints. Then Dynamo does all of the rest of the trig behind the scenes.  Check this out with Door_01.dyn.  For just one of the points: Now all that’s left is the position of the rotation joint that joins the two halves of the door.  For this we’ll zoom in: We have points P1 and P2.  We just found them with a rotation transform.  P3 is the midpoint of the line between P1 and P2.  We are looking for P5, which is shared by both flexing triangular panels on the top and bottom.  As the door starts to rotate, the point P5 needs to move away from the wall as the piano hinges start to bend.  All of this must happen because the middle triangular panels are rigid, and they are “pinched” out of the plane of the wall.  In the diagram below, when the door is all the way open (moved fully to the right), x =0 and P4 and P5 are the same thing.  P4 is the projection of P5 back onto the wall.  That distance x is the holy grail, and it’s the only missing piece of information to locate P5.

Notice the triangle in blue, which is perpendicular to the wall.  It is a right triangle and its side lengths mean that x2 + b2 = a2.  If we can find a and b, we have x.  Obviously, I wouldn’t have pointed it out if we couldn’t find a and b easily.  Here goes.  a is just the diagonal of a triangular panel:

To find b, notice that we can find that line’s end points.  P3 is the midpoint of the line connecting P1 and P2.  In Dynamo, you can draw a line by endpoints between P1 and P2 and then evaluate that line at the parameter 0.5.  You can also get P3 by averaging the XYZ components of P1 and P2, whichever is easier. We also know P4 since it is in the plane of the wall (P4x = 0), the artist’s hand distance from the door jam (P4y = m), and half the door height above the floor (P4z = h/2).  Then the length bis the distance between P3 and P4—just use XYZ Distance!

Putting it all together: from before, the sides of the blue triangle mean that x2b2a2, which means:

 x = sqrt(a2 – b2), x = sqrt(h2/8 – b2) Now make the point P5 with the coordinates in the diagram above and build the lists of three-points for the flexing panels.  Here’s the final file: Door_02.dyn. 