


I enjoy Mathematica‘s ability’s to make images part of the code. I added the ability to overlay the cutting paths over a few photographs I’ve taken over the years: This also provides an excellent tool for adjusting, removing, and adding polygons to achieve the best visual design. To fix this we introduce an interactive interface where slight discrepancies can be manually fixed. There are some overlaps, some pieces are too small, and sometimes locks appear on the sides with no adjacent pieces. This alone could be a puzzle design if not for a few problematic issues. We will use MorphologicalComponents and a few other image processing functions to color the polygons, now with locks. Next we define a function that will extract from a Voronoi diagram all pairs of points representing the polygons’ sides: Once we find the satisfactory geometric parameters, we use them to define the lock function: That would make cutting it out with scissors difficult.

For short enough distances the spline line will disappear and leave the polygon side intact to make sure that the lock is not too small. The lock size is proportional to the distance between the points. This emphasizes that for every pair of points, the lock orientation will be chosen randomly. Try this with the interactive CDF (Computable Document Format) below:ĭragging locators of endpoints in the app above will frequently flip the lock direction. Varying point positions and spline parameters, we can design an interlocking part in a shape we like. In addition to two endpoints of a polygon side, we need to provide three more points: a midpoint to mark where the interlocking part is and two extra points to wrap the spline around. The next step is to replace the sides of these polygons with interlocking parts. Use InputForm to see the complete structure. Here Voronoi cells are represented by the Polygon function this is a typical element: Such graphics objects consist of graphics primitives and their options. But perhaps the simplest way is using Mathematica‘s native graphics functions, such as ListDensityPlot. For example, from an image processing angle this can be achieved with the DistanceTransform function. We could use the Computational Geometry Package to build a VoronoiDiagram, but there are other perhaps less known ways worth sharing. This will guarantee uniqueness of shapes with high probability.
:max_bytes(150000):strip_icc()/jigsawpuzzles-jigsawexplorer-5bfbbba146e0fb0026ef2271.jpg)
A Voronoi diagram (or Dirichlet tessellation) is a good start because it can be constructed on a set of random points. Yet as it often happens with Mathematica, a solution was right around the corner.įirst we start with a tessellating tiling producing more or less unique shapes. At first I thought that if we want to recreate interlocking parts and non-standard shapes and guarantee a perfect tessellation, the task could be a bit elaborate. It must be possible to generate different paths (sets) for a specific shape that are not merely rotations or reflections of the first.Īdditionally, the author of the question notes that he seeks original designs alternative to typical mass-produced shapes.Pieces must be interlocking such that each piece is held by adjacent pieces.All pieces must be unique to preclude placing a piece in the wrong spot.However, since this question was asked on Mathematica Stack Exchange, a young, modern technical Q&A site, it was very specific in accordance with the community rules. For instance, this single mathematical formula from our graphics examples produces a beautiful tessellation: There are many approaches to producing such patterns. Uniqueness is achieved by making a piece be a part of a large image, have a specific shape, or a combination of these. Moreover, every piece is unique and has a definite place in the puzzle. In its essence, a jigsaw puzzle is a tiling or tessellation, which means there are no gaps or overlaps between the pieces. I was browsing Mathematica user communities for original projects and came by the following question: “ How can I calculate a jigsaw puzzle cut path?” Such creative problems are in abundance at our user forums, the Wolfram Demonstrations Project, and The Mathematica Journal, which tells me that Mathematica, at its heart, is a conduit for creativity: it’s a programing language that likes the challenge of convoluted problems and inspires elegant, often unexpected solutions.
