Engare (Mahdi Bahrami)
"Engare is a game about motion and geometry." - Author's description

seen from United States

seen from Canada

seen from United States

seen from United States
seen from China
seen from Germany
seen from China
seen from United Kingdom

seen from United States
seen from Russia
seen from Malaysia
seen from Hong Kong SAR China
seen from United Kingdom
seen from Philippines

seen from United Kingdom
seen from Russia

seen from United Kingdom
seen from Jordan

seen from United States
seen from United States
Engare (Mahdi Bahrami)
"Engare is a game about motion and geometry." - Author's description

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Islamic Art Drawing Tools
I really like parametric tools like this, where the history and rules of constructing something is interactively adjustable.
This particular one was developed as a side effect of Engare, a game by Mahdi Bahrami about motion and geometry.
The history of Islamic art has a lot of fascinating context I won’t get in to here, but its use of geometric patterns and rules overlaps with my interest in procedural art. I’m glad that Mahdi has found a way to bring some of that to the interactive world.
Engare/انگاره is such a beautiful game <3
Engare and its patterns
The other day I came across an enthusiastic tweet about a game just published called Engare. This is a graphics game is inspired by Islamic art and developed by Mahdi Bahrami, a young Iranian living in Amsterdam. The game has been over 6 years in development and has won many prizes for its creator. The game is available via the Steam gaming platform and costs around £5. The previews looked really nice, so I thought I’d support Mahdi and pay actual money for software for once. [Update - it is also available from his website.]
In the game, you have to work through puzzles in which you attach a pen to a mechanism such as rolling wheels. Given a target graph, you have to attach the pen to the location on the mechanism which generates this graph. The graphics and music are very lovely and the puzzles satisfying to solve, although the challenge posed is somewhat uneven. Most exercises required only a few trials but a couple took me ages. This was partly due to my difficulty in clicking on a moving object, a task which was a lot easier when I discovered that the right mouse key slows the movement.
The prize at the end is access to a set of drawing tools, a couple of which use the main drawing mechanism found in many of the puzzles. This is a set of 2, 3 or 4 linked bars of differing lengths, rotating at different rates of rotation.
This ‘spirograph’ like mechanism can produce a huge variety of patterns. This very general family of curves, with suitable constraints on the parameter values and using only two links, includes circles, elipses,epicycloids, epitrocoids, hypercyloids, hypertrocoids, Limacon and other known curves , but not rose curves in general as these contain products rather than sums of sinusoids. The drawing tools have limited output soI thought it would be nice to implement this mechanism in OpenSCAD.
The basic equations for the motion of the 3-link version are
X=a1*cos(r1*t)+a2*cos(r2*t)+a3*cos(r3*t)
Y=a1*sin(r1*t)+a2*sin(r2*t)+a3*sin(r3*t)
where t is an angle from 0:360 (or multiples thereof from multiple cycles), a* are amplitudes (length of link) and r* are the rates of revolution (+ clockwise).
r* are absolute rotation rates in the x/y plane. It is easier to express rotations relative to their moving centre of revolution since this directly relates to the pattern. So if Rn are relative rates:
r1=R1, r2=R2+r1, r3=R3+r2
By inspection, the example above has R2=4. For symmetry, R3 must be a multiple of R2 which must be even and probably 4. The links are defined by rate/amplitude pairs. The value of the amplitudes can be judged by eye, but we can see that a2+a3 < a1 (since the curve doesn’t reach the centre).
R=4;
link1=[1,10]; link2=[R,6]; link3=[4*R,1.7,0];
Given a function f(t, params) to compute [X,Y], we can generate the path :
function path_points(step,min=0,max=360,params) =
[for (t=[min:step:max-step]) f(t,params)];
A 2D object can be created by hulling circles placed at points along this path
module graph(path,thickness=0.5) { for(i =[0:len(path)-1]) { hull() { translate(path[i]) circle(d=thickness); translate(path[(i+1) % len(path)]) circle(d=thickness); } } }
The main program is
step=0.5; // step size in degrees thickness=0.5; // width of the line
R=4;
link1=[1,10,0]; link2=[R,6,0]; link3=[4*R,1.7,0]; links=[link1, link2, link3];
path = path_points(step, 0, 360, links); color("red")
graph( path,thickness);
and the result exported as DXF or SVG
Similarly we can reproduce this pattern which appears in the game:
with parameters
R=10;
link1=[1,10,0]; link2=[-R,5,0]; // anticlockwise link3=[3*R,1.75,0];
If we apply the linear_extrude transformation to the 2D object created by the hull_path() module, we can generate a 2.5D object suitable for printing:
Printed in PLA on the Reprap printer at BristolHackspace (thickened a bit since this print is only 3.5 cm diameter) :
To create a 3D object, we need to compute a Z value. We can compute the radial position of each point r = sqrt(X^2 + Y^2) and then Z from a function such as r^2 for a parabolic dome. The simple way to create the 3D object is to hull spheres placed at points along the path:
module hull_path(path,r) { for (i = [0 : len(path) - 1 ]) { hull() { translate(path[i]) sphere(r); translate(path[(i + 1) % len(path)]) sphere(r); } } };
This approach is slow to run but is reliable:
An alternative construction is to create a polyhedron using the approach I developed for modelling knots. This is much faster to render, but sometimes fails.
In fact, the hull model is detected to be non-manifold in Repetier (but slices ok) whereas the polyhedron is correct.
When using these patterns in real objects, the numbers matter. Suppose I want to design a fridge magnet with a diameter of 50mm and a hole for an 8mm diameter magnet. Whatever the pattern, the outer radius is at most a1+a2+a3 and the inner radius is at least a1-a2-a3. Whether these limits are reached depends on the rates. Adding these equations shows that a1 must be (25+4)/2 = 14.5 so a2+a3=10.5. so
where
nodes=15; cycles=4; R=nodes/cycles; d=2; // vary from 0 to 10.5 link1=[1,14.5,0]; link2=[R,10.5-d,0]; // anticlockwise link3=[2*R,d,0]; links=[link1,link2,link3];
with an added cylinder so we can check for fit.
One way of seeing how the pattern changes is use the animation mode in OpenSCAD by replacing d=2 by d=10.5*$t; and watching the changing pattern. [actually, as we can see this wont work very well because I haven’t allowed for the thickness of the plastic so the inner diameter must be greater than 8mm if the magnet is to fit easily.]
As a further extension, I added a phase angle to the definition of a link. The results vary tend to lose mirror and/or rotational symmetry but gain some life I think. Here is one pattern I rather like:
with these parameters:
R=6; link1=[1,8,0]; link2=[-R,5,0]; link3=[5*R,2.25,90];
These equations also crop up in other work. In Pradeep Mutalik’s column How to Create Art with Mathematics, he explores some patterns from Frank Ferris’ book Creating Symmetry: The Artful Mathematics of Wallpaper Patterns, such as this one:
He uses a mixture of sines and cosines and absolute rotations which complicates the problem. So the “mystery curve” in the column has a formulation in this parameterisation :
R=6; link1=[1,10,0]; link2=[R,5,0]; link3=[-4*R,3.333,-90];
OpenSCAD code
The draft OpenSCAD code is on Github
Here is my wishlist for Engare:
1. The puzzles, while sometimes challenging, are about the construction of a portion of a curve, not full curves. Exercises in which sliders change parametric values with the aim to match a target pattern (as I have had to do to match patterns found in the game) would be good.
2. It would greatly add value to the drawing tools if the parametric values themselves could be displayed or exported, so patterns can be replicating using other software.
3. The connection with Islamic art is a little tenuous. Certainly this art is highly patterned as are patterns generated by this mechanism, but as far as I know, (and I know every little!) construction of early Islamic art used ruler and compass alone. Recent research on tiling has shown that the mathematics underlying knot-work (girih) tiling is mathematically sophisticated, but not based on spirograph-like instruments. It would be interesting to see if a game could be made using these tiles.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Engare: a game about movement and geometry by Mahdi Bahrami.