tabatkins / efmath

Fork of Erich Friedman's repo to turn all the gifs into svgs
0 stars 0 forks source link

Packing attack plan #1

Open tabatkins opened 1 year ago

tabatkins commented 1 year ago

So the first project is converting the Packing projects to SVG. I presume we'll start with the square-in-square, as it's both simple and just barely non-trivial enough to explore the solution space well (and the angled squares are so ugly in the current gifs).

Proposed plan:

Instead of JSON, maybe we can use KDL? It's a better config language than JSON, and I'm the author of a Python KDL-parsing library (kdl-py on pip), so I'd like an excuse to try it out in a real-world example and find friction points to fix. ^_^

tabatkins commented 1 year ago

Like

diagram "s1" {
    background square="1"
    square x=.5 y=.5
}
diagram "s2" {
    background square="2"
    square x=.5 y=1.5
    square x=1.5 y=1.5
}
...

square nodes can also have a rotate attribute giving an angle. Probably a color too, since some examples have more than just the gray.

When we get to the non-trivial container shapes (like circle-in-L or whatever) the background node can have a path attribute instead.

We auto-calculate the canvas size based on the background and set up the viewport automatically.

tabatkins commented 1 year ago

Got a response from Erich on the details of some of the odder square placements:

let's start with squares in squares. the easy ones are the ones where all the tilted squares are 45 degrees. i'm sure you can figure out those on your own. that handles n=5, 10, 26, 27, 28, 38, 40, 52, 65, 66, 67, 82, 83, 84, 87, 89.

the next hard one is n=11. the 5 tilted squares are rotated 40.182 degrees and have corners (2.02,.985), (1.34,1.72), (2.68,1.73), (2.00,2.465), and (3.23,.85). that isn't quite 3 decimal places.

the last one for today is n=17. there are 6 tilted squares rotated .6947 radians, and have corners (2.4,2.59),(1.67,1.91),(3.09,1.86),(2.36,1.18),(.78,1.27),(1.51,.59) the last tilted square is rotated .9316 radians and has corner (3.14,.60). only 2 decimal places.