Browse Source

Splitted READMEs

root 7 years ago
parent
commit
17c10b1e5c
3 changed files with 540 additions and 540 deletions
  1. 264
    0
      README-en.md
  2. 274
    0
      README-es.md
  3. 2
    540
      README.md

+ 264
- 0
README-en.md View File

@@ -0,0 +1,264 @@
1
+
2
+# Repetition Structures - Tessellations
3
+
4
+![main1.gif](images/main1.gif)
5
+![main2.png](images/main2.png)
6
+![main3.png](images/main3.png)
7
+
8
+One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. In this lab experience you will use `for` loops produce patterns and mosaics.
9
+
10
+##Objectives:
11
+
12
+1. Practice the use of repetition structures to make patterns and tessellations.
13
+
14
+2. Strengthen the use of functions and objects.
15
+
16
+This laboratory experience is an adaptation of https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
17
+
18
+##Pre-Lab:
19
+
20
+Before coming to the laboratory session you should have:
21
+
22
+1. Reviewed the basic concepts related to repetition structures.
23
+
24
+2. Studied the concepts and instructions for the laboratory session, especially the use of the methods for:
25
+
26
+    a. adjusting the size of the windows,
27
+
28
+    b. adjusting the position of the tessellations,
29
+
30
+    c. rotate tessellations.
31
+
32
+3. Taken the Pre-Lab quiz available through the course’s Moodle portal.
33
+
34
+---
35
+
36
+---
37
+
38
+##Tessellations
39
+
40
+A tessellation is a mosaic that is created by repeating a figure to cover the surface without leaving empty spaces or overlapping the figures. A *regular tessellation* is a figure that is made by repeating the same *regular polygon*, like triangles, squares or hexagons. (A regular polygon is a polygon where all sides are congruent and the angles that form the sides are congruent.)
41
+
42
+---
43
+
44
+![figure1.gif](images/figure1.gif)
45
+
46
+**Figure 1** - The only regular tessellations possible obtained using triangles, squares and hexagons.
47
+
48
+---
49
+
50
+
51
+##Library
52
+
53
+The `Tessellations.pro` project available in `http://bitbucket.org/eip-uprrp/repetitions1-tessellations` contains the `Tessellation` class, which is an abstraction of a tessellation with squares, and the `DrawingWindow` class. The code shown in Figure 2 creates a `DrawingWindow` called `w`, a `Tesselation` called `t` and places the tessellation in position (50,100). Notice that the `addTessellation` method of the `DrawingWindow` class should be invoked to draw the tessellation.
54
+
55
+---
56
+
57
+```cpp
58
+int main(int argc, char *argv[]) {
59
+    QApplication a(argc, argv);
60
+
61
+    DrawingWindow w;        // Creates the w object of the DrawingWindow class    w.resize(300, 300);
62
+    w.show();
63
+
64
+    Tessellation t;          // Creates the t object of the Tessellation class 
65
+    t.move(50,100);         // Sets the tessellation's position
66
+
67
+    w.addTessellation(t);    // Adds the tessellation to the window
68
+
69
+    return a.exec();
70
+}
71
+```
72
+
73
+**Figure 2.** Code in the `main` function to create a window and tessellation.
74
+
75
+---
76
+
77
+The window that is obtained with the code in Figure 2 is similar to the window in Figure 3. The arrows and the numbers 50 and 100 illustrate the spaces between the tessellation's upper left corner and the window's borders. The tessellation's upper left corner is in the position (50,100).
78
+
79
+---
80
+
81
+![figure3.png](images/figure3.png)
82
+
83
+**Figure 3.** Window with the tessellation in the position (50,100).
84
+
85
+---
86
+
87
+**Example 1.** The code in Figure 4 contains a `foo` function to draw four tessellations in the positions (0,0), (50,50), (100,100), and (150,150), with the original figure's rotation of $$0^\circ, 90^\circ, 180^\circ y 270^\circ$$ (clockwise).
88
+
89
+---
90
+
91
+```cpp
92
+int foo(DrawingWindow &w) {
93
+    int rot = 0;
94
+    for (int i = 0; i < 4; i++) {
95
+        Tessellation t;
96
+        t.setRotation(rot);
97
+        t.move(i * 50, i * 50);
98
+        w.addTessellation(t);
99
+        rot += 90;
100
+    }
101
+
102
+}
103
+
104
+int main(int argc, char *argv[]) {
105
+    QApplication a(argc, argv);
106
+
107
+    DrawingWindow w;
108
+    w.resize(300, 300);
109
+    w.show();
110
+
111
+    foo(w);
112
+    return a.exec();
113
+}
114
+```
115
+
116
+**Figure 4.** Code for the `foo` function that draws four tessellations.
117
+
118
+---
119
+
120
+Observe how the `foo` function needs to receive a reference to the `w` object of the `DrawingWindow` class since its invoking the `addTessellation` method of the class in each iteration of the loop. The figure that is obtained is similar to the one in Figure 5.
121
+
122
+---
123
+
124
+![figure5.png](images/figure5.png)
125
+
126
+**Figure 5.** Tessellations drawn by the `foo` function in the code in Figure 4.
127
+
128
+---
129
+
130
+**Example 2.** The code in Figure 6 shows an example of how to use nested loops to create tessellations.
131
+
132
+---
133
+
134
+```cpp
135
+int fah(DrawingWindow &w) {
136
+    int rot = 0;
137
+    for (int i = 0; i < 4; i++) {
138
+     for (int j = 0; j < 4; j++) {
139
+Tessellation t;
140
+                t.move(i * 50, j * 50);
141
+t.setRotation(rot);
142
+            w.addTessellation(t);
143
+    }
144
+            rot += 90;
145
+    }
146
+
147
+}
148
+```
149
+
150
+**Figure 6.** Code for the `fah` function that uses nested loops to draw four tessellations.
151
+
152
+The figure that is obtained is similar to the one in Figure 7.
153
+
154
+---
155
+
156
+![figure7.png](images/figure7.png)
157
+
158
+**Figure 7.** Tessellations drawn by the `fah` function in the code in Figure 6.
159
+
160
+---
161
+
162
+
163
+---
164
+
165
+---
166
+
167
+!INCLUDE "../../eip-diagnostic/tesselations/en/diag-tesselations-01.html"
168
+
169
+!INCLUDE "../../eip-diagnostic/tesselations/en/diag-tesselations-02.html"
170
+
171
+---
172
+
173
+---
174
+
175
+
176
+##Laboratory Session
177
+
178
+In today's laboratory experience you will practice the use of nested loops to create different tessellations.
179
+
180
+###Exercise 1: Study the loop that produces tessellations
181
+
182
+####Instructions
183
+
184
+1. Load the Qt project called `Tessellations` by double-clicking on the `Tessellations.pro` file in the `Documents/eip/Repetitions-Tessellations` folder of your computer. Alternatively, you may clone the git repository `http://bitbucket.org/eip-uprrp/repetitions-tessellations` to download the `Repetitions-Tessellations` folder to your computer.
185
+
186
+2. The `Tessellations.pro` project contains the `Tessellations` and `DrawingWindow` classes and the `foo` function. Configure the project and run the program. You should see a window similar to the one in Figure 5.
187
+
188
+This figure is created with the `foo` function shown in Figure 4 and explained in Example 1. The `foo` function is invoked from `main()`. In this laboratory experience you will only be making changes to the `main()` function.
189
+
190
+Study the `foo` function once again and notice the creation of the objects from the `Tessellations` class, the use of the `setRotation` method, and the `move` method to set the tessellation in the desired position. Notice how the instructions in the `for` loop in the function use the loop's counter to determine the square's position and how the rotation's value is incremented. Also notice that you will need to use the `addTessellation` method to add the tessellation to the `w` window.
191
+
192
+
193
+
194
+###Exercise 2: Create the `herringbone` function and tessellation
195
+
196
+####Instructions
197
+
198
+1. Create a `herringbone` function that produces the tessellation in Figure 8. The size of the window is 400x400. The size of each square in the tessellation is its size by default: 50x50.
199
+
200
+    ---
201
+
202
+    ![figure8.png](images/figure8.png)
203
+
204
+    **Figure 8.** Tessellation that the `herringbone` function should draw.
205
+
206
+    ---
207
+
208
+2. Comment the **invocation** of the `foo` function.
209
+
210
+3. Invoke the `herringbone` function from `main()` and run the program so you can see the tessellation you created.
211
+
212
+###Exercise 3: Create the `zigzag` function and tessellation
213
+
214
+####Instructions
215
+
216
+1. Create a `zigzag` function that produces the tessellation in Figure 9.
217
+
218
+    ---
219
+
220
+    ![figure9.png](images/figure9.png)
221
+
222
+    **Figure 9.** Tessellation that the `zigzag` function should draw.
223
+
224
+    ---
225
+
226
+2. Comment the invocation of the `herringbone` function.
227
+
228
+3. Invoke the `zigzag` function from `main()` and run the program so you can see the tessellation you created.
229
+
230
+
231
+###Exercise 4: Create the `diamond` function and tessellation
232
+
233
+####Instructions
234
+
235
+1. Create a `diamond` function that produces the tessellation in Figure 10.
236
+
237
+    ---
238
+
239
+    ![figure10.png](images/figure10.png)
240
+
241
+    **Figure 10.** Tessellation that the `diamond` function should draw.
242
+
243
+    ---
244
+
245
+2. Comment the invocation of the `zigzag` function.
246
+
247
+3. Invoke the `diamond` function from `main()` and run the program so you can see the tessellation you created. 
248
+
249
+
250
+---
251
+
252
+---
253
+
254
+##Deliverables
255
+
256
+Use "Deliverables" in Moodle to upload the `main.cpp` file that contains the `herringbone`, `zigzag` and `diamond` functions that you created in Exercises 2, 3, and 4. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.
257
+
258
+---
259
+
260
+---
261
+
262
+##References
263
+
264
+[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.

+ 274
- 0
README-es.md View File

@@ -0,0 +1,274 @@
1
+
2
+# Estructuras de repetición - Mosaicos
3
+
4
+![main1.gif](images/main1.gif)
5
+![main2.png](images/main2.png)
6
+![main3.png](images/main3.png)
7
+
8
+Una de las ventajas de utilizar programas de computadoras es que podemos realizar tareas repetitivas fácilmente. Los ciclos como `for`, `while`, y `do-while` son  estructuras de control que nos permiten repetir un conjunto de instrucciones. A estas estructuras también se les llama *estructuras de repetición*.  En la experiencia de laboratorio de hoy practicarás el uso de ciclos anidados para producir patrones y mosaicos.
9
+
10
+
11
+##Objetivos:
12
+
13
+1. Practicar el uso de estructuras de repetición al construir patrones y mosaicos.
14
+
15
+2. Reforzar las destrezas de uso de funciones y objetos.
16
+
17
+Esta experiencia de laboratorio es una adaptación de https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
18
+
19
+##Pre-Lab:
20
+
21
+Antes de llegar al laboratorio debes haber:
22
+
23
+1. Repasado los conceptos básicos relacionados a estructuras de repetición.
24
+
25
+2. Estudiado los conceptos e instrucciones para la sesión de laboratorio, especialmente el uso de los métodos para:
26
+
27
+    a. ajustar el tamaño de las ventanas,
28
+
29
+    b. colocar las teselaciones en posiciones específicas,
30
+
31
+    c. rotar teselaciones.
32
+
33
+3. Tomado el quiz Pre-Lab que se encuentra en Moodle.
34
+
35
+---
36
+
37
+---
38
+
39
+
40
+##Teselaciones
41
+
42
+Una *teselación* ("tessellation" o "tilling") es un mosaico que se crea repitiendo una figura para cubrir una superficie sin dejar huecos y sin solapamientos. Una *teselación regular* es una figura que se forma repitiendo un mismo *polígono regular*, como triángulos, cuadrados o hexágonos. (Un polígono regular es un polígono cuyos lados son congruentes y en el que los ángulos que forman los lados son congruentes.)  
43
+
44
+---
45
+
46
+![figure1.gif](images/figure1.gif)
47
+
48
+**Figura 1** - Las únicas teselaciones regulares posibles obtenidas usando triángulos, cuadrados o hexágonos.
49
+
50
+---
51
+
52
+
53
+##Biblioteca
54
+
55
+El proyecto `Tessellations.pro` disponible en `http://bitbucket.org/eip-uprrp/repetitions1-tessellations` contiene la clase `Tessellation`, que es una abstracción de una teselación con cuadrados, y la clase `DrawingWindow`. El  código de muestra en la Figura 2  crea un `DrawingWindow` llamado `w`, un `Tessellation` llamado `t` y coloca la teselación en la posición (50,100). Nota que el método `addTessellation` de la clase `DrawingWindow` debe ser invocado para que la teselación se dibuje.
56
+
57
+---
58
+
59
+```cpp
60
+int main(int argc, char *argv[]) {
61
+    QApplication a(argc, argv);
62
+
63
+    DrawingWindow w;        // crea el objeto w de la clase DrawingWindow 
64
+    w.resize(300, 300);
65
+    w.show();
66
+
67
+    Tessellation t;          // crea el objeto t de la clase Tessellation 
68
+    t.move(50,100);         // dice la posición de la teselacion
69
+
70
+    w.addTessellation(t);    // añade la teselacion a la ventana
71
+
72
+    return a.exec();
73
+}
74
+```
75
+
76
+**Figura 2.** Código en función `main` para crear ventana y teselación.
77
+
78
+---
79
+
80
+La ventana que se obtiene con el código de la Figura 2 es similar a la ventana en la Figura 3. Las flechas y los números 50 y 100 ilustran los espacios entre la esquina superior izquierda de la teselación y los bordes de la ventana. La esquina superior izquierda de la teselación está en la posición (50,100).
81
+
82
+---
83
+
84
+![figure3.png](images/figure3.png)
85
+
86
+**Figura 3.** Ventana con teselación en la posición (50,100).
87
+
88
+---
89
+
90
+**Ejemplo 1.** El código de la Figura 4 contiene una función `foo` para dibujar cuatro teselaciones en las posiciones  (0,0), (50,50), (100,100), and (150,150), con rotaciones de la figura original de  $$0^\circ, 90^\circ, 180^\circ y 270^\circ$$ (a favor de las manecillas del reloj). 
91
+
92
+---
93
+
94
+```cpp
95
+int foo(DrawingWindow &w) {
96
+    int rot = 0;
97
+    for (int i = 0; i < 4; i++) {
98
+        Tessellation t;
99
+        t.setRotation(rot);
100
+        t.move(i * 50, i * 50);
101
+        w.addTessellation(t);
102
+        rot += 90;
103
+    }
104
+
105
+}
106
+
107
+int main(int argc, char *argv[]) {
108
+    QApplication a(argc, argv);
109
+
110
+    DrawingWindow w;
111
+    w.resize(300, 300);
112
+    w.show();
113
+
114
+    foo(w);
115
+    return a.exec();
116
+}
117
+```
118
+
119
+**Figura 4.** Código de la función `foo` que dibuja cuatro teselaciones.
120
+
121
+---
122
+
123
+Observa como la función `foo` necesita recibir una referencia al objeto `w` de la clase `DrawingWindow` ya que está invocando el método `addTessellation`  de esta clase en cada iteración del ciclo. La figura que se obtiene es similar a la de la Figura 5.
124
+
125
+---
126
+
127
+![figure5.png](images/figure5.png)
128
+
129
+**Figura 5.** Teselaciones dibujadas por la función `foo` en el código de la Figura 4.
130
+
131
+---
132
+
133
+**Ejemplo 2.** El código de la Figura 6 nos muestra un ejemplo del uso de ciclos anidados para crear teselaciones.
134
+
135
+---
136
+
137
+```cpp
138
+int fah(DrawingWindow &w) {
139
+    int rot = 0;
140
+    for (int i = 0; i < 4; i++) {
141
+     for (int j = 0; j < 4; j++) {
142
+Tessellation t;
143
+                t.move(i * 50, j * 50);
144
+t.setRotation(rot);
145
+            w.addTessellation(t);
146
+    }
147
+            rot += 90;
148
+    }
149
+
150
+}
151
+```
152
+
153
+**Figura 6.** Código de la función `fah` que utiliza ciclos anidados para dibujar  cuatro teselaciones.
154
+
155
+La figura que se obtiene es similar a la de la Figura 7.
156
+
157
+---
158
+
159
+![figure7.png](images/figure7.png)
160
+
161
+**Figura 7.** Teselaciones dibujadas por la función `fah` en el código de la Figura 6.
162
+
163
+---
164
+
165
+
166
+---
167
+
168
+---
169
+
170
+!INCLUDE "../../eip-diagnostic/tesselations/es/diag-tesselations-01.html"
171
+
172
+!INCLUDE "../../eip-diagnostic/tesselations/es/diag-tesselations-02.html"
173
+
174
+---
175
+
176
+---
177
+
178
+
179
+##Sesión de laboratorio:
180
+
181
+En la experiencia de laboratorio de hoy practicarás el uso de ciclos anidados para crear distintas teselaciones.
182
+
183
+###Ejercicio 1: Estudiar ciclo que produce teselaciones
184
+
185
+####Instrucciones
186
+
187
+
188
+1. Carga a Qt el proyecto `Tessellations`  haciendo doble "click" en el archivo `Tessellations.pro` en el directorio `Documents/eip/Repetitions-Tessellations` de tu computadora. También puedes ir a `http://bitbucket.org/eip-uprrp/repetitions-tessellations` para descargar la carpeta `Repetitions-Tessellations` a tu computadora.
189
+ 
190
+2.  El proyecto `Tessellations.pro` contiene las clases `Tessellation` y `DrawingWindow` y la función `foo`. Configura el proyecto y corre el programa. Debes observar una pantalla parecida a la Figura 5. 
191
+
192
+    Esta figura se crea con la función `foo` mostrada en la Figura 4 y explicada en el Ejemplo 1. La función `foo` es invocada desde `main()`. En esta experiencia de laboratorio solo estarás haciendo cambios a la función `main()`.
193
+
194
+    Estudia nuevamente la función `foo` y nota la creación de los objetos de la clase `Tessellations`, el uso del método `setRotation` y el método `move` para colocar la teselación en la posición deseada. Nota cómo las instrucciones en el ciclo `for` de la función utilizan el contador del ciclo para determinar la posición del cuadrado y como se incrementa el valor de la rotación. También nota que necesitas utilizar el método `addTessellation` para que la teselación se añada en la ventana `w`.
195
+
196
+
197
+###Ejercicio 2: Crear función y teselación `herringbone`
198
+
199
+####Instrucciones
200
+
201
+1. Crea una función  `herringbone` que produzca la teselación de la Figura 8. El tamaño de la ventana es 400x400. El tamaño de cada cuadrado de la teselación es su tamaño por defecto: 50x50.
202
+
203
+    ---
204
+
205
+    ![figure8.png](images/figure8.png)
206
+
207
+    **Figura 8.** Teselación que debe dibujar la función `herringbone`.
208
+
209
+    ---
210
+
211
+2. Comenta la **invocación** de la función `foo`.
212
+
213
+3. Invoca la función `herringbone` desde `main()` y corre tu programa para que veas la teselación que creaste.
214
+
215
+###Ejercicio 3: Crear función y teselación `zigzag`
216
+
217
+####Instrucciones
218
+
219
+1. Crea una función  `zigzag` que produzca la teselación de la Figura 9. 
220
+   
221
+    ---
222
+
223
+    ![figure9.png](images/figure9.png)
224
+
225
+    **Figura 9.** Teselación que debe dibujar la función `zigzag`.
226
+
227
+    ---
228
+
229
+2. Comenta la invocación de la función `herringbone`.
230
+
231
+3. Invoca la función `zigzag` desde `main()` y corre tu programa para que veas la teselación que creaste.
232
+
233
+
234
+###Ejercicio 4: Crear función y teselación `diamond`
235
+
236
+####Instrucciones
237
+
238
+1. Crea una función  `diamond` que produzca la teselación de la Figura 10. 
239
+
240
+    ---
241
+
242
+    ![figure10.png](images/figure10.png)
243
+
244
+    **Figura 10.** Teselación que debe dibujar la función `diamond`.
245
+
246
+    ---
247
+
248
+2. Comenta la invocación de la función `zigzag`.
249
+
250
+3. Invoca la función `diamond` desde `main()` y corre tu programa para que veas la teselación que creaste.
251
+
252
+
253
+---
254
+
255
+---
256
+
257
+##Entrega
258
+
259
+Utiliza "Entrega" en Moodle para entregar el archivo `main.cpp` que contiene las funciones  `herringbone`, `zigzag` y `diamond` que creaste en los Ejercicios 2, 3 y 4 y sus invocaciones. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
260
+
261
+---
262
+
263
+---
264
+
265
+##Referencias
266
+
267
+[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
268
+
269
+---
270
+
271
+---
272
+
273
+---
274
+

+ 2
- 540
README.md View File

@@ -1,540 +1,2 @@
1
-[English](#markdown-header-repetition-structures-tessellations) | [Español](#markdown-header-estructuras-de-repeticion-mosaicos)
2
-
3
-# Estructuras de repetición - Mosaicos
4
-
5
-![main1.gif](images/main1.gif)
6
-![main2.png](images/main2.png)
7
-![main3.png](images/main3.png)
8
-
9
-Una de las ventajas de utilizar programas de computadoras es que podemos realizar tareas repetitivas fácilmente. Los ciclos como `for`, `while`, y `do-while` son  estructuras de control que nos permiten repetir un conjunto de instrucciones. A estas estructuras también se les llama *estructuras de repetición*.  En la experiencia de laboratorio de hoy practicarás el uso de ciclos anidados para producir patrones y mosaicos.
10
-
11
-
12
-##Objetivos:
13
-
14
-1. Practicar el uso de estructuras de repetición al construir patrones y mosaicos.
15
-
16
-2. Reforzar las destrezas de uso de funciones y objetos.
17
-
18
-Esta experiencia de laboratorio es una adaptación de https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
19
-
20
-##Pre-Lab:
21
-
22
-Antes de llegar al laboratorio debes haber:
23
-
24
-1. Repasado los conceptos básicos relacionados a estructuras de repetición.
25
-
26
-2. Estudiado los conceptos e instrucciones para la sesión de laboratorio, especialmente el uso de los métodos para:
27
-
28
-    a. ajustar el tamaño de las ventanas,
29
-
30
-    b. colocar las teselaciones en posiciones específicas,
31
-
32
-    c. rotar teselaciones.
33
-
34
-3. Tomado el quiz Pre-Lab que se encuentra en Moodle.
35
-
36
----
37
-
38
----
39
-
40
-
41
-##Teselaciones
42
-
43
-Una *teselación* ("tessellation" o "tilling") es un mosaico que se crea repitiendo una figura para cubrir una superficie sin dejar huecos y sin solapamientos. Una *teselación regular* es una figura que se forma repitiendo un mismo *polígono regular*, como triángulos, cuadrados o hexágonos. (Un polígono regular es un polígono cuyos lados son congruentes y en el que los ángulos que forman los lados son congruentes.)  
44
-
45
----
46
-
47
-![figure1.gif](images/figure1.gif)
48
-
49
-**Figura 1** - Las únicas teselaciones regulares posibles obtenidas usando triángulos, cuadrados o hexágonos.
50
-
51
----
52
-
53
-
54
-##Biblioteca
55
-
56
-El proyecto `Tessellations.pro` disponible en `http://bitbucket.org/eip-uprrp/repetitions1-tessellations` contiene la clase `Tessellation`, que es una abstracción de una teselación con cuadrados, y la clase `DrawingWindow`. El  código de muestra en la Figura 2  crea un `DrawingWindow` llamado `w`, un `Tessellation` llamado `t` y coloca la teselación en la posición (50,100). Nota que el método `addTessellation` de la clase `DrawingWindow` debe ser invocado para que la teselación se dibuje.
57
-
58
----
59
-
60
-```cpp
61
-int main(int argc, char *argv[]) {
62
-    QApplication a(argc, argv);
63
-
64
-    DrawingWindow w;        // crea el objeto w de la clase DrawingWindow 
65
-    w.resize(300, 300);
66
-    w.show();
67
-
68
-    Tessellation t;          // crea el objeto t de la clase Tessellation 
69
-    t.move(50,100);         // dice la posición de la teselacion
70
-
71
-    w.addTessellation(t);    // añade la teselacion a la ventana
72
-
73
-    return a.exec();
74
-}
75
-```
76
-
77
-**Figura 2.** Código en función `main` para crear ventana y teselación.
78
-
79
----
80
-
81
-La ventana que se obtiene con el código de la Figura 2 es similar a la ventana en la Figura 3. Las flechas y los números 50 y 100 ilustran los espacios entre la esquina superior izquierda de la teselación y los bordes de la ventana. La esquina superior izquierda de la teselación está en la posición (50,100).
82
-
83
----
84
-
85
-![figure3.png](images/figure3.png)
86
-
87
-**Figura 3.** Ventana con teselación en la posición (50,100).
88
-
89
----
90
-
91
-**Ejemplo 1.** El código de la Figura 4 contiene una función `foo` para dibujar cuatro teselaciones en las posiciones  (0,0), (50,50), (100,100), and (150,150), con rotaciones de la figura original de  $$0^\circ, 90^\circ, 180^\circ y 270^\circ$$ (a favor de las manecillas del reloj). 
92
-
93
----
94
-
95
-```cpp
96
-int foo(DrawingWindow &w) {
97
-    int rot = 0;
98
-    for (int i = 0; i < 4; i++) {
99
-        Tessellation t;
100
-        t.setRotation(rot);
101
-        t.move(i * 50, i * 50);
102
-        w.addTessellation(t);
103
-        rot += 90;
104
-    }
105
-
106
-}
107
-
108
-int main(int argc, char *argv[]) {
109
-    QApplication a(argc, argv);
110
-
111
-    DrawingWindow w;
112
-    w.resize(300, 300);
113
-    w.show();
114
-
115
-    foo(w);
116
-    return a.exec();
117
-}
118
-```
119
-
120
-**Figura 4.** Código de la función `foo` que dibuja cuatro teselaciones.
121
-
122
----
123
-
124
-Observa como la función `foo` necesita recibir una referencia al objeto `w` de la clase `DrawingWindow` ya que está invocando el método `addTessellation`  de esta clase en cada iteración del ciclo. La figura que se obtiene es similar a la de la Figura 5.
125
-
126
----
127
-
128
-![figure5.png](images/figure5.png)
129
-
130
-**Figura 5.** Teselaciones dibujadas por la función `foo` en el código de la Figura 4.
131
-
132
----
133
-
134
-**Ejemplo 2.** El código de la Figura 6 nos muestra un ejemplo del uso de ciclos anidados para crear teselaciones.
135
-
136
----
137
-
138
-```cpp
139
-int fah(DrawingWindow &w) {
140
-    int rot = 0;
141
-    for (int i = 0; i < 4; i++) {
142
-     for (int j = 0; j < 4; j++) {
143
-Tessellation t;
144
-                t.move(i * 50, j * 50);
145
-t.setRotation(rot);
146
-            w.addTessellation(t);
147
-    }
148
-            rot += 90;
149
-    }
150
-
151
-}
152
-```
153
-
154
-**Figura 6.** Código de la función `fah` que utiliza ciclos anidados para dibujar  cuatro teselaciones.
155
-
156
-La figura que se obtiene es similar a la de la Figura 7.
157
-
158
----
159
-
160
-![figure7.png](images/figure7.png)
161
-
162
-**Figura 7.** Teselaciones dibujadas por la función `fah` en el código de la Figura 6.
163
-
164
----
165
-
166
-
167
----
168
-
169
----
170
-
171
-!INCLUDE "../../eip-diagnostic/tesselations/es/diag-tesselations-01.html"
172
-
173
-!INCLUDE "../../eip-diagnostic/tesselations/es/diag-tesselations-02.html"
174
-
175
----
176
-
177
----
178
-
179
-
180
-##Sesión de laboratorio:
181
-
182
-En la experiencia de laboratorio de hoy practicarás el uso de ciclos anidados para crear distintas teselaciones.
183
-
184
-###Ejercicio 1: Estudiar ciclo que produce teselaciones
185
-
186
-####Instrucciones
187
-
188
-
189
-1. Carga a Qt el proyecto `Tessellations`  haciendo doble "click" en el archivo `Tessellations.pro` en el directorio `Documents/eip/Repetitions-Tessellations` de tu computadora. También puedes ir a `http://bitbucket.org/eip-uprrp/repetitions-tessellations` para descargar la carpeta `Repetitions-Tessellations` a tu computadora.
190
- 
191
-2.  El proyecto `Tessellations.pro` contiene las clases `Tessellation` y `DrawingWindow` y la función `foo`. Configura el proyecto y corre el programa. Debes observar una pantalla parecida a la Figura 5. 
192
-
193
-    Esta figura se crea con la función `foo` mostrada en la Figura 4 y explicada en el Ejemplo 1. La función `foo` es invocada desde `main()`. En esta experiencia de laboratorio solo estarás haciendo cambios a la función `main()`.
194
-
195
-    Estudia nuevamente la función `foo` y nota la creación de los objetos de la clase `Tessellations`, el uso del método `setRotation` y el método `move` para colocar la teselación en la posición deseada. Nota cómo las instrucciones en el ciclo `for` de la función utilizan el contador del ciclo para determinar la posición del cuadrado y como se incrementa el valor de la rotación. También nota que necesitas utilizar el método `addTessellation` para que la teselación se añada en la ventana `w`.
196
-
197
-
198
-###Ejercicio 2: Crear función y teselación `herringbone`
199
-
200
-####Instrucciones
201
-
202
-1. Crea una función  `herringbone` que produzca la teselación de la Figura 8. El tamaño de la ventana es 400x400. El tamaño de cada cuadrado de la teselación es su tamaño por defecto: 50x50.
203
-
204
-    ---
205
-
206
-    ![figure8.png](images/figure8.png)
207
-
208
-    **Figura 8.** Teselación que debe dibujar la función `herringbone`.
209
-
210
-    ---
211
-
212
-2. Comenta la **invocación** de la función `foo`.
213
-
214
-3. Invoca la función `herringbone` desde `main()` y corre tu programa para que veas la teselación que creaste.
215
-
216
-###Ejercicio 3: Crear función y teselación `zigzag`
217
-
218
-####Instrucciones
219
-
220
-1. Crea una función  `zigzag` que produzca la teselación de la Figura 9. 
221
-   
222
-    ---
223
-
224
-    ![figure9.png](images/figure9.png)
225
-
226
-    **Figura 9.** Teselación que debe dibujar la función `zigzag`.
227
-
228
-    ---
229
-
230
-2. Comenta la invocación de la función `herringbone`.
231
-
232
-3. Invoca la función `zigzag` desde `main()` y corre tu programa para que veas la teselación que creaste.
233
-
234
-
235
-###Ejercicio 4: Crear función y teselación `diamond`
236
-
237
-####Instrucciones
238
-
239
-1. Crea una función  `diamond` que produzca la teselación de la Figura 10. 
240
-
241
-    ---
242
-
243
-    ![figure10.png](images/figure10.png)
244
-
245
-    **Figura 10.** Teselación que debe dibujar la función `diamond`.
246
-
247
-    ---
248
-
249
-2. Comenta la invocación de la función `zigzag`.
250
-
251
-3. Invoca la función `diamond` desde `main()` y corre tu programa para que veas la teselación que creaste.
252
-
253
-
254
----
255
-
256
----
257
-
258
-##Entrega
259
-
260
-Utiliza "Entrega" en Moodle para entregar el archivo `main.cpp` que contiene las funciones  `herringbone`, `zigzag` y `diamond` que creaste en los Ejercicios 2, 3 y 4 y sus invocaciones. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
261
-
262
----
263
-
264
----
265
-
266
-##Referencias
267
-
268
-[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
269
-
270
----
271
-
272
----
273
-
274
----
275
-
276
-[English](#markdown-header-repetition-structures-tessellations) | [Español](#markdown-header-estructuras-de-repeticion-mosaicos)
277
-
278
-# Repetition Structures - Tessellations
279
-
280
-![main1.gif](images/main1.gif)
281
-![main2.png](images/main2.png)
282
-![main3.png](images/main3.png)
283
-
284
-One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. In this lab experience you will use `for` loops produce patterns and mosaics.
285
-
286
-##Objectives:
287
-
288
-1. Practice the use of repetition structures to make patterns and tessellations.
289
-
290
-2. Strengthen the use of functions and objects.
291
-
292
-This laboratory experience is an adaptation of https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
293
-
294
-##Pre-Lab:
295
-
296
-Before coming to the laboratory session you should have:
297
-
298
-1. Reviewed the basic concepts related to repetition structures.
299
-
300
-2. Studied the concepts and instructions for the laboratory session, especially the use of the methods for:
301
-
302
-    a. adjusting the size of the windows,
303
-
304
-    b. adjusting the position of the tessellations,
305
-
306
-    c. rotate tessellations.
307
-
308
-3. Taken the Pre-Lab quiz available through the course’s Moodle portal.
309
-
310
----
311
-
312
----
313
-
314
-##Tessellations
315
-
316
-A tessellation is a mosaic that is created by repeating a figure to cover the surface without leaving empty spaces or overlapping the figures. A *regular tessellation* is a figure that is made by repeating the same *regular polygon*, like triangles, squares or hexagons. (A regular polygon is a polygon where all sides are congruent and the angles that form the sides are congruent.)
317
-
318
----
319
-
320
-![figure1.gif](images/figure1.gif)
321
-
322
-**Figure 1** - The only regular tessellations possible obtained using triangles, squares and hexagons.
323
-
324
----
325
-
326
-
327
-##Library
328
-
329
-The `Tessellations.pro` project available in `http://bitbucket.org/eip-uprrp/repetitions1-tessellations` contains the `Tessellation` class, which is an abstraction of a tessellation with squares, and the `DrawingWindow` class. The code shown in Figure 2 creates a `DrawingWindow` called `w`, a `Tesselation` called `t` and places the tessellation in position (50,100). Notice that the `addTessellation` method of the `DrawingWindow` class should be invoked to draw the tessellation.
330
-
331
----
332
-
333
-```cpp
334
-int main(int argc, char *argv[]) {
335
-    QApplication a(argc, argv);
336
-
337
-    DrawingWindow w;        // Creates the w object of the DrawingWindow class    w.resize(300, 300);
338
-    w.show();
339
-
340
-    Tessellation t;          // Creates the t object of the Tessellation class 
341
-    t.move(50,100);         // Sets the tessellation's position
342
-
343
-    w.addTessellation(t);    // Adds the tessellation to the window
344
-
345
-    return a.exec();
346
-}
347
-```
348
-
349
-**Figure 2.** Code in the `main` function to create a window and tessellation.
350
-
351
----
352
-
353
-The window that is obtained with the code in Figure 2 is similar to the window in Figure 3. The arrows and the numbers 50 and 100 illustrate the spaces between the tessellation's upper left corner and the window's borders. The tessellation's upper left corner is in the position (50,100).
354
-
355
----
356
-
357
-![figure3.png](images/figure3.png)
358
-
359
-**Figure 3.** Window with the tessellation in the position (50,100).
360
-
361
----
362
-
363
-**Example 1.** The code in Figure 4 contains a `foo` function to draw four tessellations in the positions (0,0), (50,50), (100,100), and (150,150), with the original figure's rotation of $$0^\circ, 90^\circ, 180^\circ y 270^\circ$$ (clockwise).
364
-
365
----
366
-
367
-```cpp
368
-int foo(DrawingWindow &w) {
369
-    int rot = 0;
370
-    for (int i = 0; i < 4; i++) {
371
-        Tessellation t;
372
-        t.setRotation(rot);
373
-        t.move(i * 50, i * 50);
374
-        w.addTessellation(t);
375
-        rot += 90;
376
-    }
377
-
378
-}
379
-
380
-int main(int argc, char *argv[]) {
381
-    QApplication a(argc, argv);
382
-
383
-    DrawingWindow w;
384
-    w.resize(300, 300);
385
-    w.show();
386
-
387
-    foo(w);
388
-    return a.exec();
389
-}
390
-```
391
-
392
-**Figure 4.** Code for the `foo` function that draws four tessellations.
393
-
394
----
395
-
396
-Observe how the `foo` function needs to receive a reference to the `w` object of the `DrawingWindow` class since its invoking the `addTessellation` method of the class in each iteration of the loop. The figure that is obtained is similar to the one in Figure 5.
397
-
398
----
399
-
400
-![figure5.png](images/figure5.png)
401
-
402
-**Figure 5.** Tessellations drawn by the `foo` function in the code in Figure 4.
403
-
404
----
405
-
406
-**Example 2.** The code in Figure 6 shows an example of how to use nested loops to create tessellations.
407
-
408
----
409
-
410
-```cpp
411
-int fah(DrawingWindow &w) {
412
-    int rot = 0;
413
-    for (int i = 0; i < 4; i++) {
414
-     for (int j = 0; j < 4; j++) {
415
-Tessellation t;
416
-                t.move(i * 50, j * 50);
417
-t.setRotation(rot);
418
-            w.addTessellation(t);
419
-    }
420
-            rot += 90;
421
-    }
422
-
423
-}
424
-```
425
-
426
-**Figure 6.** Code for the `fah` function that uses nested loops to draw four tessellations.
427
-
428
-The figure that is obtained is similar to the one in Figure 7.
429
-
430
----
431
-
432
-![figure7.png](images/figure7.png)
433
-
434
-**Figure 7.** Tessellations drawn by the `fah` function in the code in Figure 6.
435
-
436
----
437
-
438
-
439
----
440
-
441
----
442
-
443
-!INCLUDE "../../eip-diagnostic/tesselations/en/diag-tesselations-01.html"
444
-
445
-!INCLUDE "../../eip-diagnostic/tesselations/en/diag-tesselations-02.html"
446
-
447
----
448
-
449
----
450
-
451
-
452
-##Laboratory Session
453
-
454
-In today's laboratory experience you will practice the use of nested loops to create different tessellations.
455
-
456
-###Exercise 1: Study the loop that produces tessellations
457
-
458
-####Instructions
459
-
460
-1. Load the Qt project called `Tessellations` by double-clicking on the `Tessellations.pro` file in the `Documents/eip/Repetitions-Tessellations` folder of your computer. Alternatively, you may clone the git repository `http://bitbucket.org/eip-uprrp/repetitions-tessellations` to download the `Repetitions-Tessellations` folder to your computer.
461
-
462
-2. The `Tessellations.pro` project contains the `Tessellations` and `DrawingWindow` classes and the `foo` function. Configure the project and run the program. You should see a window similar to the one in Figure 5.
463
-
464
-This figure is created with the `foo` function shown in Figure 4 and explained in Example 1. The `foo` function is invoked from `main()`. In this laboratory experience you will only be making changes to the `main()` function.
465
-
466
-Study the `foo` function once again and notice the creation of the objects from the `Tessellations` class, the use of the `setRotation` method, and the `move` method to set the tessellation in the desired position. Notice how the instructions in the `for` loop in the function use the loop's counter to determine the square's position and how the rotation's value is incremented. Also notice that you will need to use the `addTessellation` method to add the tessellation to the `w` window.
467
-
468
-
469
-
470
-###Exercise 2: Create the `herringbone` function and tessellation
471
-
472
-####Instructions
473
-
474
-1. Create a `herringbone` function that produces the tessellation in Figure 8. The size of the window is 400x400. The size of each square in the tessellation is its size by default: 50x50.
475
-
476
-    ---
477
-
478
-    ![figure8.png](images/figure8.png)
479
-
480
-    **Figure 8.** Tessellation that the `herringbone` function should draw.
481
-
482
-    ---
483
-
484
-2. Comment the **invocation** of the `foo` function.
485
-
486
-3. Invoke the `herringbone` function from `main()` and run the program so you can see the tessellation you created.
487
-
488
-###Exercise 3: Create the `zigzag` function and tessellation
489
-
490
-####Instructions
491
-
492
-1. Create a `zigzag` function that produces the tessellation in Figure 9.
493
-
494
-    ---
495
-
496
-    ![figure9.png](images/figure9.png)
497
-
498
-    **Figure 9.** Tessellation that the `zigzag` function should draw.
499
-
500
-    ---
501
-
502
-2. Comment the invocation of the `herringbone` function.
503
-
504
-3. Invoke the `zigzag` function from `main()` and run the program so you can see the tessellation you created.
505
-
506
-
507
-###Exercise 4: Create the `diamond` function and tessellation
508
-
509
-####Instructions
510
-
511
-1. Create a `diamond` function that produces the tessellation in Figure 10.
512
-
513
-    ---
514
-
515
-    ![figure10.png](images/figure10.png)
516
-
517
-    **Figure 10.** Tessellation that the `diamond` function should draw.
518
-
519
-    ---
520
-
521
-2. Comment the invocation of the `zigzag` function.
522
-
523
-3. Invoke the `diamond` function from `main()` and run the program so you can see the tessellation you created. 
524
-
525
-
526
----
527
-
528
----
529
-
530
-##Deliverables
531
-
532
-Use "Deliverables" in Moodle to upload the `main.cpp` file that contains the `herringbone`, `zigzag` and `diamond` functions that you created in Exercises 2, 3, and 4. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.
533
-
534
----
535
-
536
----
537
-
538
-##References
539
-
540
-[1] https://sites.google.com/a/wellesley.edu/wellesley-cs118-spring13/lectures-labs/lab-2.
1
+## [\[English\]](README-en.md) - for README in English
2
+## [\[Spanish\]](README-es.md) - for README in Spanish