Professional Documents
Culture Documents
Flexagons and Prolog
Flexagons and Prolog
1
2 Flexagons and Prolog
α α
2a 4a 6a 8a 10a 12a 14a 16a 18a
1a 3a 5a 7a 9a 11a 13a 15a 17a β G
β
β β G
1b 3b 5b 7b 9b 11b 13b 15b 17b
α 2b 4b 6b 8b 10b 12b 14b 15b 18b
α
shown by Tuckerman that certain sequence (so will be noted by list of numbers - id's of triangles
called Tuckerman's traversal) of pinch-
ex and ro- that form it: from front to the back. For example
tations will lead to revealing of all possible faces initial state of the
exagon we've made in 2.1 can
of hexahexa
exagon. It also led to developing of be written as:
hexa
exagrams[8] - graph-like notation for trans- (2,3-5,4,7,6-8,9-11,10,13,12-14,15-17,16,1,18)
actions between dierent
exagon states. Knowl-
edge of Tuckerman's traversal was really handy
when we tested our implementation of
exing for-
mula (see 3.2 and 4.1) 17a
2a 14a
3 Mathematical basis
11a
3.1 Flexagon state notion 5a
8a
Notion for
exagon state that we describe
here is taken from papers by McLean [11] and Oak-
ley,Wisner [12] and slightly modied to note com- Fig. 5: Initial face of hexahexa
exagon
plete colored
exagon state. Let's call triangu-
lar regions that form the hexagon pats. Each pat This notation is used by McLean [11] and dif-
is a set of triangles that form original paper strip. fers slightly from that of Oakley,Wisner [12]. On
Let's number pats from p1 to p6. And right down our behalf, we changed it little bit more, and
each one of them separated by the dash. Each pat each triangle is written as list : (closest to front
Logic Programming - Course project 3
side,triangle id,far side). Like ((a 2 b) (b 3 a) : : :) nd p5 can be optimized using fact that D(a1 ) =
Thus we can tell what side of triangle we see and D(a3 ) = D(a5 ) and D(b1 ) = D(b3 ) = D(b5 )
it's color. Necessity of such notation will be clear should exist.
the moment we'll present transformation formu-
las. 3.3 Simple Example
3.2 Flex vs. Formula Let's begin from the initial state of the
exagon built in 2.1:
We'll now build a transformation formula (2,3-5,4,7,6-8,9-11,10,13,12-14,15-17,16,1,18)
from state to state that will:
Formula requires splitting pats p2; p3 and p5.
Be consistent with physical parameters of the only way to do that is to split them into single
constructed
exagon triangles:
Will represent transformation identical to a1 = ae1 = 2, b1 = be1 = 3
pinch-
ex a3 = ae3 = 8, b3 = be3 = 9
a5 = ae5 = 14, b5 = be5 = 15
After simple observations of
exagon behavior un-
der pinch-
ex, one can easily notice the follow- So using formula we should obtain the following
ing1: Let denote addition modulo 6, and face face:
(p1 ? p2 ? p3 ? p4 ? p5 ? p6 ) is legal i: (2-3,6,7,4,5-8-9,12,13,10,11-14-15,18,1,16,17)
p is a pat for each i
i If you will check this face due conditions of 3.2,
you will see that newly obtained face is legal. If
p ? p 1 is a permutation of six2 consecutive
i i you will perform pinch-
ex on physical
exagon
numbers using corner of pats p1 ; p6 as base (one that goes
P D(p ) = 18, where D(p ) is number of tri-
6 up), you will see that new face is corresponding to
i=1
i i description obtained via pinch-
ex formula.
angles in pat p
3.4 Complex Example
i
e e
a1 = 16; 17, a1 = 17; 16, b1 = 1; 18 Legality conditions described in 3.2 can be eas-
e e
a3 = 4; 5, a3 = 5; 4, b3 = 7; 6 ily reached through standard prolog functions such
e e
a5 = 10; 11, a5 = 11; 10, b5 = 13; 12 as permutation and sort. The only problem might
will lead to legal face: occur from the fact that triangles 1 and 18 should
be consecutive, but that is solved by shifting num-
(16,17-1,18,3,2-4,5-7,6,9,8-10,11-13,12,15,14) bers to 0-17 range and using addition modulo 18
in consequency check.
Initial state representation is provided hard-
3.5 Notes on
exing coded
It is important to note that triangles forming
the
exagon have much more complex trajectory 4.2 Visualization
then just
ipping over and changing order. They
also turn around center of
exagon and, what is Thanks to great power of prolog, visualiza-
more important, around their own center in cer- tion became the hard part, instead of
exing it-
tain non trivial way. One consequence is that each self. Graphical representation required 3D opera-
face that we described is rather a class of
exagon tion over object dynamic in time.
faces. Although it is possible to extent
exagon Standing alone animation in Tcl/Tk is easy.
state notion to capture, in addition to all, relative The problem is interference between animation
position of the triangle corners, we preferred not running and user actions over graphical interface
to, so that resulting puzzle (see 4.3) will be easier at the same time. It was solved by centralizing
to solve. animation process. As for 3D, we had to limit an-
imation to 2D space, to avoid overcomplicated and
computationally expensive calculations.
4 Virtual Flexing Physically
exed, hexa
exagon undergoes rota-
tion unnoticed, when pinch-
ex is performed. Nor-
4.1 Prolog Flexing mal form of pinch-
ex formula does not create this
deceptive rotation, so we had to force it by ad-
One can easily observe that mathematical ditional programming. Which also created more
transformations described for
exing look like clas- complex animation.
sical logic programming problem. Beside legality Finally
exagon is presented as set of six
checking of
exagon face,
exing itself described smoothed triangles and their outlines, which form
as symbolic formula (1) in 3.2 - native language hexagonal gure, disharmonized to simulate 3D
of logic programming. Practically what left is to appearance. Under request of an animation, tri-
translate this formula to prolog syntax [14]. We angles begin to shrink by three opposite corners
use modication of dierence lists idea to trans- of the hexagon, so after a while
exagon looks
late
exagon state notion. like three lines, after that and change of color,
State = [P1 ? : : : ? P6 ]. triangles grow back revealing new
exagon face.
P = [S1 ; S2; : : :], P is a Pat.
i i To simulate and visualize physical spin deception,
i i
S = [c1 ; j; c2], j triangle's id forming the pat.
i j j while shrinking/growing,
exagon turns one pat
j
on, which makes
exing seems more natural.
c1 denotes color of closest to front side of Sji
j