Browse Source

README-en.md edited online with Bitbucket

Jose R Ortiz Ubarri 8 years ago
parent
commit
ecbe6c4539
1 changed files with 12 additions and 12 deletions
  1. 12
    12
      README-en.md

+ 12
- 12
README-en.md View File

6
 
6
 
7
 [Version Verano 2016- Tatiana]
7
 [Version Verano 2016- Tatiana]
8
 
8
 
9
-Recursion is a technique that is commonly used in programming. With this technique, problems are solved by solving similar problems but for smaller cases. We can construct sets of objects or tasks using *recursive rules* and *initial values*. *Recursive functions* are functions that are self-invoking, using smaller sets or elements each time, until reaching a point where an initial value is used instead of self-invoking. In this laboratory experience, you will implement some tools to draw and practice the use of recursive functions to fill with color some figures.
9
+Recursion is a technique that is commonly used in programming. With this technique, problems are done by solving similar problems but for smaller cases. We can construct sets of objects or tasks using *recursive rules* and *initial values*. *Recursive functions* are functions that are self-invoking, using smaller sets or elements each time, until reaching a point where an initial value is used instead of self-invoking. In this laboratory experience, you will implement some tools to draw and practice the use of recursive functions to fill with color some figures.
10
 
10
 
11
 
11
 
12
 ## Objectives:
12
 ## Objectives:
36
 ## Drawing Applications
36
 ## Drawing Applications
37
 
37
 
38
 
38
 
39
-Probably many Windows OS users (if not all of them) have used the program called *Paint*, which is a simple drawing application. In that program, like many other drawing programs, there are several tools (for example: the pencil, the paint bucket and the line) that lets the user draw on the area in different ways.
39
+Probably many Windows OS users (if not all of them) have used the program called *Paint*, which is a simple drawing application. In that program, like many other drawing programs, there are several tools (for example: the pencil, the paint bucket and the line) that let the user draw on the area in different ways.
40
 
40
 
41
 In this laboratory experience, we will make some tools (square, circle, triangle, some special lines) work ... don't worry!, we will do it in a very simple way.
41
 In this laboratory experience, we will make some tools (square, circle, triangle, some special lines) work ... don't worry!, we will do it in a very simple way.
42
 
42
 
57
 	**Figure 1.**  The image shows the direction in which the coordinates are ordered in `Qt` images.
57
 	**Figure 1.**  The image shows the direction in which the coordinates are ordered in `Qt` images.
58
 
58
 
59
 
59
 
60
-* When we want to insert two-dimensional data (like the entries of a grid that has coordinates in $x$ y $y$) in an one-dimensional array we use a formula to convert every coordinate $(x,y)$ to an index $i$ of the array. For every point with coordinates $(x,y)$ in the grid, we evaluate $i=(number-of-columns)*y+x$, where `number-of-columns` represents the width of the two-dimensional array, and the result $i$ will be the index of the one-dimensional array that corresponds to the point with coordinates $(x,y)$ in the grid. For example, the index $i$ that corresponds to the point $(1,2)$ in the grid of width $5$ is $i=(5)*2+1=11$.
60
+* When we want to insert two-dimensional data (like the entries of a grid that has coordinates in $x$ and $y$) in an one-dimensional array we use a formula to convert every coordinate $(x,y)$ to an index $i$ of the array. For every point with coordinates $(x,y)$ in the grid, we evaluate $i=(number-of-columns)*y+x$, where `number-of-columns` represents the width of the two-dimensional array, and the result $i$ will be the index of the one-dimensional array that corresponds to the point with coordinates $(x,y)$ in the grid. For example, the index $i$ that corresponds to the point $(1,2)$ in the grid of width $5$ is $i=(5)*2+1=11$.
61
 
61
 
62
 
62
 
63
 ---
63
 ---
71
 
71
 
72
 * `int qFloor(qreal v)` // Returns the “floor” value $v$.
72
 * `int qFloor(qreal v)` // Returns the “floor” value $v$.
73
 * `qreal qSqrt(qreal v)` // Returns the square root of the value $v$.
73
 * `qreal qSqrt(qreal v)` // Returns the square root of the value $v$.
74
-* `qreal qPow(qreal x, qreal y)` // Returns the value of $x$ to the power $y$.
74
+* `qreal qPow(qreal x, qreal y)` // Returns the value of $x$ to the power of $y$.
75
 
75
 
76
 In addition, you will need to use the function that paints the grid:
76
 In addition, you will need to use the function that paints the grid:
77
 
77
 
106
 		* Using the virtual machine: Double click the file `GridPlotter.pro` located in the folder `home/eip/labs/recursion-gridplotter` of your virtual machine. 
106
 		* Using the virtual machine: Double click the file `GridPlotter.pro` located in the folder `home/eip/labs/recursion-gridplotter` of your virtual machine. 
107
 		* Downloading the project's folder from `Bitbucket`: Use a terminal and write the command `git clone http://bitbucket.org/eip-uprrp/recursion-gridplotter' to download the folder `recursion-gridplotter` from `Bitbucket`. Double click the file `nombre.pro` located in the folder that you downloaded to your computer. 
107
 		* Downloading the project's folder from `Bitbucket`: Use a terminal and write the command `git clone http://bitbucket.org/eip-uprrp/recursion-gridplotter' to download the folder `recursion-gridplotter` from `Bitbucket`. Double click the file `nombre.pro` located in the folder that you downloaded to your computer. 
108
 		
108
 		
109
-2. The project contains the skeleton for the application that draws lines and figures in a grid. The application has an interface that allows the user to select the color we want to draw with, the color of the background of the grid, the figure you want to draw (for example, the circle or the square) and the size of the figure. The selected figure is drawn when the user clicks a cell in the grid.
109
+2. The project contains the skeleton for the application that draws lines and figures in a grid. The application has an interface that allows the user to select the color we want to draw with, the color of the background of the grid, the figure you want to draw (for example, circle or square) and the size of the figure. The selected figure is drawn when the user clicks a cell in the grid.
110
 
110
 
111
 
111
 
112
 You will be working with the archive called `tools.cpp`. Your first task is to implement the functions `RowMajorFill`, `ColMajorFill`, `DiagonalLeft` and `DiagonalRight` that make the buttons that draw lines work. The function `RowMajorFill` is already implemented for you to use as an example. The functions should work as indicated below.
112
 You will be working with the archive called `tools.cpp`. Your first task is to implement the functions `RowMajorFill`, `ColMajorFill`, `DiagonalLeft` and `DiagonalRight` that make the buttons that draw lines work. The function `RowMajorFill` is already implemented for you to use as an example. The functions should work as indicated below.
114
 
114
 
115
 ##### `RowMajorFill`
115
 ##### `RowMajorFill`
116
 
116
 
117
-When you select the horizontal line figure in the interface, a horizontal line will be drawn on the grid on the row the user clicked. The line will expand to the right and left of the clicked cell until if finds a cell (pixel) with a different color as the background color, or until the grid ends. Figure 2 illustrates this behavior.
117
+When you select the horizontal line figure in the interface, a horizontal line will be drawn on the row of the grid the user clicked. The line will expand to the right and left of the clicked cell until it finds a cell (pixel) with a different color as the background color, or until the grid ends. Figure 2 illustrates this behavior.
118
 
118
 
119
 
119
 
120
 
120
 
154
 
154
 
155
 ##### `DiagonalRight`
155
 ##### `DiagonalRight`
156
 
156
 
157
-This function should work similarly as the `DiagonalLeft` function but produce a diagonal line from the superior right corner to the inferior left corner. Figure 5 ilustrates its behavior.
157
+This function should work similarly as the `DiagonalLeft` function but produces a diagonal line from the superior right corner to the inferior left corner. Figure 5 illustrates its behavior.
158
 
158
 
159
 
159
 
160
 | (a) | (b) | (c) | 
160
 | (a) | (b) | (c) | 
165
 **Figure 5** - (a) A drawing with a white background and red dots. (b) When the user clicks on the right diagonal line button (`DiagonalRight`) and clicks the cell shown, (c) a right diagonal line that expands towards the top to the right and towards the bottom to the left of the cell clicked is drawn, until it finds a cell with a different color from the color of the background. 
165
 **Figure 5** - (a) A drawing with a white background and red dots. (b) When the user clicks on the right diagonal line button (`DiagonalRight`) and clicks the cell shown, (c) a right diagonal line that expands towards the top to the right and towards the bottom to the left of the cell clicked is drawn, until it finds a cell with a different color from the color of the background. 
166
 
166
 
167
 
167
 
168
-### Exercise 2: Implement the functions that operate the buttons for drawing square, triangles and circles. 
168
+### Exercise 2: Implement the functions that operate the buttons for drawing squares, triangles and circles. 
169
 
169
 
170
-Now, you will implement the functionality so that you can draw squares, circles and triangles. The **size** of the figure drawn will depend on the size select with sliding bar in the interface.
170
+Now, you will implement the functionality to draw squares, circles and triangles. The **size** of the figure drawn will depend on the size selected on sliding bar in the interface.
171
 
171
 
172
 
172
 
173
 #### 2a: Squares 
173
 #### 2a: Squares 
192
 
192
 
193
 #### 2c: Círculos
193
 #### 2c: Círculos
194
 
194
 
195
-¡Congratulations! ¡You got to the most difficult part: circles! Here you’ll need to use your mathematical skills… we hope that you did well on your pre-calculus class...
195
+Congratulations! You got to the most difficult part: circles! Here you’ll need to use your mathematical skills… we hope that you did well on your pre-calculus class...
196
 
196
 
197
 
197
 
198
 ![](images/circles.png)
198
 ![](images/circles.png)
203
 
203
 
204
 First of all, you need to understand that the terms associated with a circle that has an equation: $x^2+y^2=r^2$. For example, consider a circle with radius $r=1$. The equation $x^2+y^2=1$ tells us that every point $(x,y)$ that satisfies the equation is a point in the circle’s *circumference*. The expression for a *filled* circle is : $x^2 + y^2 <=r^2$. A filled circle, of radius $r=1$ has the expression  $x^2 + y^2 <= 1$, which says that every point $(x,y)$ that satisfies $x^2 + y^2 <= 1$ is a point in a filled circle.
204
 First of all, you need to understand that the terms associated with a circle that has an equation: $x^2+y^2=r^2$. For example, consider a circle with radius $r=1$. The equation $x^2+y^2=1$ tells us that every point $(x,y)$ that satisfies the equation is a point in the circle’s *circumference*. The expression for a *filled* circle is : $x^2 + y^2 <=r^2$. A filled circle, of radius $r=1$ has the expression  $x^2 + y^2 <= 1$, which says that every point $(x,y)$ that satisfies $x^2 + y^2 <= 1$ is a point in a filled circle.
205
 
205
 
206
-How do we produce a circle? A way would be generating all of the *nearby* points to the center of the circle and determine if those satisfy the expression $x^2 + y^2 <= r^2$. For example, we can try all of the points that are in the square of size $2r+1$. For the circle of radius $r=2$ we would have to generate the following points and prove them in the expression $x^2 + y^2 <=4$:
206
+How do we produce a circle? One way would be to generate all the points near the center of the circle and determine if those satisfy the expression $x^2 + y^2 <= r^2$. For example, we can try all of the points that are in the square of size $2r+1$. For the circle of radius $r=2$ we would have to generate the following points and prove them in the expression $x^2 + y^2 <=4$:
207
 
207
 
208
 
208
 
209
 ````
209
 ````
229
 
229
 
230
 ### Exercise 3: Implement the function that fills the figures using recursion. 
230
 ### Exercise 3: Implement the function that fills the figures using recursion. 
231
 
231
 
232
-In this exercise you will implement the functionality to fill the color of the figures.One of the more convinient ways to express the algorithm to fill the figures is using recursion. A basic recursive algortithm (but it’s pretty weak) is found in Wikipedia:
232
+In this exercise you will implement the functionality to fill the color of the figures.One of the more convinient ways to express the algorithm to fill the figures is using recursion. A basic recursive algorithm (but it’s pretty weak) is found in Wikipedia:
233
 
233
 
234
 
234
 
235
 ```
235
 ```