Here is something I've been working on for a while...
# share-your-work
r
Here is something I've been working on for a while that I've finally figured out how to do. You draw rectangles in the plane and 'transclusions' between them. Transclusions produce copies which display only in the target. Transclusions copy rectangles to produce new (cropped) rectangles. Transclusions also copy copied rectangles. Additionally, transclusions copy transclusions, which in turn copies transclusions and rectangles as well. Because rectangles can be moved around and resized every transclusion copies every rectangle and every transclusion ad infinitum at all times (though currently we stop after four steps). You can think of this structure as something like a syntax tree whose pieces can be moved in and out continuously at will, and two way transclusions as a kind of symbolic variable with the symbol missing. The math behind all this is really interesting too, but I probably don't want to go on about that here. (cc @Elliot and @Lu Wilson, thanks for inspiring me to think about rectangles and affine transformations! Also cc @jonathoda since transclusions are very similar to inclusions from First Class Copy and Paste.)

https://youtu.be/iGHphz-NbBI

l
cool!
what did you learn while making this?
r
One neat thing you can do is define a group structure (multiplication, identity, inversion) on rectangles. The geometric results of these operations depend on how you set up your coordinate systems, but when you use them to describe affine transformations, e.g. the affine transform taking one rectangle to another, the coordinate system doesn't matter anymore. We can model a rectangle as a 4-tuple (x,y,w,h) comprised by the coordinates of (the upper left) corner and a width and height. Then the identity element is (0,0,1,1), multiplication is (x1,y1,w1,h1)(x2,y2,w2,h2) = (x1+w1*x2, y1+h1*y2, w1*w2, h1*h2), and inversion is (x,y,w,h)^{-1} = (-x/w, -y/h, 1/w, 1/h). Given two rectangles a and b there is a unique affine transform of the plane taking a to b,. If we apply that affine transform takes a third rectangle c, then the result can also be given by the formula b*a^{-1}*c. The other neat thing about this is we don't have to implement rectangles and affine transformations as separate entities because rectangles also act as affine transformations. I think this is reminiscent of some ideas from geometric algebra, although that wasn't intentional at all.
e
Wonderful!
Maybe I missed it, but I don't think you showed two-way transclusion? I.e. where putting a box inside either one of two other boxes also shows it in the other. Can you do that?
r
oh, my bad, here is a video showing a bidirectional transclusion. Its just a matter of "drawing" one transclusion in each direction. It is admittedly a little hard to see the process of drawing because there is no visual indication anything is happening beyond the mouse being down. It would be better if there were an arrow or some kind of highlighting the source and target of a transclusion as its being drawn, but I haven't done that yet.
j
Nice. You might be interested in Toby Schachman’s Apparatus: http://aprt.us
e
Somehow missed this but that is wonderful @Robin! I will revisit this thread when I come back to recursive stuff