Mathematical and Physical Journal
for High Schools
Issued by the MATFUND Foundation
Already signed up?
New to KöMaL?

Problem I. 243. (May 2010)

I. 243. Optical illusions are created in the brain when inconsistent information is transmitted by the optic nerves. One peculiar example is the Münsterberg illusion, in which lower and upper edges of the parallel black and white squares seem to be bent and converge towards each other near the boundary.

Prepare your program that creates an SVG vector graphics file containing an image of the Münsterberg illusion after reading the parameters. Most browsers are able to display SVG files without any problem. The structure of an SVG file is described, for example, on the page http://svg.elte.hu/.

Parameters to be read:

[--] \(\displaystyle N\), being the number of horizontal and vertical black squares (\(\displaystyle 3\le N\le 50\));

[--] OLDAL, being the side length of each square (\(\displaystyle 5\le \text{OLDAL} \le 50\));

[--] VV, being the thickness of the horizontal separating lines (\(\displaystyle 0\le \text{VV}\le \text{OLDAL}\));

[--] finally FAJLNEV, being the name of the image.

In the example (Példa bemenet az ábrához) you can see the parameters for the sample image.

Példa bemenet az ábrához
\(\displaystyle N = 8\)
\(\displaystyle \mbox{OLDAL} = 30\)
\(\displaystyle \mbox{VV} = 2\)
\(\displaystyle \mbox{FAJLNEV} = \mbox{'optika.svg'}\)

One can experience the strongest optical illusion if colour tones of the squares are rather different and the colour of the separator line is between theirs.

The source code (i243.pas, i243.cpp, ...) together with a short documentation (i243.txt, i243.pdf, ...) -- also describing which developer environment to use for compiling, further a brief description of your solution -- should be submitted in a compressed file (i243.zip).

(10 pont)

Deadline expired on June 10, 2010.


Sorry, the solution is available only in Hungarian. Google translation

Megoldásokról

A feladat az SVG állomány szerkezetének megismerését igényelte, programozási szempontból egyszerű volt. Szükséges SVG elemek (stílusok, vonalak húzása, négyzetek rajzolása…), megtalálhatók voltak a megadott linken.

Mintamegoldás Horváth Lóránd (Budapest, Németh László Gimnázium) 12. osztályos tanuló megoldását közöljük:

Első lépésként bekérem a szükséges paramétereket a felhasználótól (n, oldal, vv, fajlnev) és létrehozom a kívánt .svg fájlt. Ebbe először az svg fejlécet írom bele:

A hossz és a magassag adatokat a bekért adatok alapján számítom ki:

A kép hossza: n*oldal*2 mivel n darab fekete és fehér négyzet van a képen vízszintesen.

A kép magassága: n*(oldal+vv) mert függőlegesen n darab négyzet és elválasztóvonal követi egymást.

Ha megnézzük a készíteni kívánt kép felépítését látjuk, hogy minden sor több egyforma elemre bontható. Az első sor például egy fekete és egy fehér négyzetre, ami a sor többi részén n-szer ismétlődik. Második sor hasonló logika alapján bontható szét (+ sorok között szürke vonal):

Ezt a két elemet készítettem el, csoportba foglaltam ezeket a <g> ill. </g> tagek segítségével és elnevezem őket resz1 és resz2-nek. A teljes kép legenerálása ezen részek felhasználásával történik a <usexlink:href="#resz1" tag segítségével. 2 egymásba ágyazott for ciklus-t használok. Ha a külső for ciklusváltozója páratlan, akkor az első fajta elemet ismételgetem, ha páros, akkor a második fajta elemet ismételgetem – így kialakítva a különböző sorokat.

Az utolsó lépésben egy kis szürke keretet rajzolok a kép köré (ahogy a mintán is látszik) és lezárom az svg fájlt.

i243.pas


Statistics:

5 students sent a solution.
10 points:Balla Attila, Barta 111 János, Horváth 135 Loránd, Szabó 928 Attila.
9 points:Pap 999 Dávid.

Problems in Information Technology of KöMaL, May 2010