# AFFINE TRANSFORMATION

Although a linear transformation, applied to vectors by multiplication of the vectors by a matrix, can be used to rotate, scale, shear, and reflect a set of points in an image, a linear transformation cannot be used to translate a set of points. To translate a set of points, we need to use an affine transformation. An affine transformation multiplies a vector by a matrix, just as in a linear transformation, and then adds a vector to the result. Simply put, an affine transformation from Rn to Rn is a linear transformation followed by a translation. In our project, we are tasked to transform some given points using affine maps of the form ; f(x) = Lx + b. This transformation will be iterated and images will be created. Fractals are images of infinite complexity, characterized by being "similar" to themselves in some sense at all scales of magnification. Iterated function systems are a method of generating fractals using self-similarity. An IFS image is defined as being the sum of geometric transforms of itself. The functions are normally contractive, which means they bring points closer together and make shapes smaller. Hence, the shape of an IFS fractal is made up of several possibly-overlapping smaller copies of itself, each of which is also made up of copies of itself

```
Populating the interactive namespace from numpy and matplotlib
```

## QUESTION 3A

Conforming to the rule of our transformation, we are to begin with X[A(0)] the boundaries of a unit square which are (0,0), (1,0), (1,1) and (0,1),however since it is an iteration the starting point also becomes the end point .With the help of the NumPy module, we created an array which will contain X in the given affine transformation given in the preamble .Arrays were also created for our given matrix(Lj) and the given translation vectors(b1,b2,b3,b4,b5) using NumPy as well.

The need for the use of the for loop was inevitable at this point . We started by first defining a function name (A) which takes (num) as the parameter. An empty list is created assigned the name X_new. Going ahead with the transformation, we made use of the Matrix multiplication(matmul)function which helps multiplication of two arrays(Lj and X).Having placed all our given vectors in a list(b_list), the for loop comes in handy as we use it to add each vector to the results we got earlier thus LX, in effect generating f(x). Finally, our results are copied into X and then they are plotted using the plot function. The results obtained are powers of five be it the number of squares produced or the coordinates produced .Thus we will be generating squares in powers of 5.Thus for num=0,1,2,3.... we produce 5^(num) squares =5^(0),5^(1),5^(2),5^(3)... squares.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 5^(num+1) coordinates and 5^(num) squares in effect and plot them. We get a square for A(0).

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 5 squares for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 125 squares in total for A(3).

A(6)=L[A(5)]+ b, we generate 15,625 squares for A(6).

A(10) = L[A(9)] +b: 9,765,625 squares will be produced for A(10).

## QUESTION 3B

In Question 3b we are tasked to use the same affine transformation function given. But in this case we are expected to take X as the half of the unit square below the diagonal off the origin. We chose to assign X as X_half[(0,0),(1,0),(1,1)]. NumPy helps us create arrays for X_half, the L's and translational vectors(b's).Creating lists that would contain the L's and b's was a necessity so we did that and named them L_list and b_list respectively.

After creating the arrays and lists with the help of NumPy, we proceeded to use the for loop to generate the triangles and their respective coordinates. Then of course plotted our results.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 4^(num+1) coordinates and 4^(num) triangles in effect and plot them. For A(0) we are getting a triangle for A(0) thus half of the unit square below the diagonal off the origin.

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 4 triangles for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 64 triangles in total for A(3).

A(6)=L[A(5)]+ b, we generate 4,096 triangles for A(6).

A(10) = L[A(9)] +b: 1,048,576 triangles for A(10).

## QUESTION 3C

Conforming to the rule of our transformation, we are to begin with X the boundaries of a unit square which are (0,0), (1,0), (1,1) and (0,1),however since it is an iteration the starting point also becomes the end point .With the help of the NumPy module, we created an array which will contain X in the given affine transformation given in the preamble .Arrays were also created for our given matrices(L1,L2,L3,L4) and the given translation vectors(b1,b2,b3,b4) using NumPy as well. Then we created a list to contain the Ls and bs.

After creating the arrays and lists with the help of NumPy, we proceeded to use the for loop to generate the rectangles and their respective coordinates. Then of course plotted our results.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 4^(num+1) coordinates and 4^(num) rectangles in effect and plot them. For A(0), a rectangle will be generated.

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 4 rectangles for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 64 rectangles in total for A(3).

A(6)=L[A(5)]+ b, we generate 4,096 rectangles for A(6).

A(10) = L[A(9)] +b: 1,048,576 rectangles for A(10).

## QUESTION 3D

In Question 3d we are tasked to use the same affine transformation function given. But in this case we are expected to take X as the half of the unit square below the diagonal off the origin. We chose to assign X as X_half[(0,0),(1,0),(1,1)]. NumPy helps us create arrays for X_half, the L's and translational vectors(b's).Creating lists that would contain the L's and b's was a necessity so we did that and named them L_list and b_list respectively.

After creating the arrays and lists with the help of NumPy, we proceeded to use the for loop to generate the triangles and their respective coordinates. Then of course plotted our results.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 3^(num+1) coordinates and 3^(num) triangles in effect and plot them. For A(0), a triangle will be generated.

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 3 triangles for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 27 triangles in total for A(3).

A(6)=L[A(5)]+ b, we generate 729 triangles for A(6).

A(10) = L[A(9)] +b: 59,049 triangles are produced for A(10).

## QUESTION 3E

Conforming to the rule of our transformation, we are to begin with X the boundaries of a unit square which are (0,0), (1,0), (1,1) and (0,1),however since it is an iteration the starting point also becomes the end point .With the help of the NumPy module, we created an array which will contain X in the given affine transformation given in the preamble .Arrays were also created for our given matrix(Lj) and the given translation vectors(b1,b2,b3,b4,b5) using NumPy as well.

After creating the arrays and lists with the help of NumPy, we proceeded to use the for loop to generate the rectangles and their respective coordinates. Then of course plotted our results.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 3^(num+1) coordinates and 3^(num) triangles in effect and plot them. For A(0), a rectangle will be generated for A(0).

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 3 rectangles for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 27 rectangles in total for A(3).

A(6)=L[A(5)]+ b, we generate 729 rectangles for A(6).

A(10) = L[A(9)] +b: 59,049 rectangles for A(10).

## QUESTION 3F

Conforming to the rule of our transformation, we are to begin with X the boundaries of a unit square which are (0,0), (1,0), (1,1) and (0,1),however since it is an iteration the starting point also becomes the end point .With the help of the NumPy module, we created an array which will contain X in the given affine transformation given in the preamble .Arrays were also created for our given matrix(Lj) and the given translation vectors(b1,b2,b3,b4,b5) using NumPy as well.

After creating the arrays and lists with the help of NumPy, we proceeded to use the for loop to generate the shapes and their respective coordinates. Then of course plotted our results.

So the output we are getting now is generated by evaluating the values of f(x) using X as the boundaries of the unit square. Thus we generate 3^(num+1) coordinates and 3^(num) shapes in effect and plot them. We are getting a unit square.

When generating A(1),we use the same Affine transformation given f(x). But in this the X used to generate the coordinates are the values of the previous iteration. Thus A(num) = L[A(num-1)]+b. Hence A(1) = L[A(0)] + b. We generate 3 shapes for A(1).

A(3) as well is generated using the general formula, A(num) = L[A(num-1)]+b. Thus A(3)= L[(A(2)] +b. We generate 27 shapes for A(3).

A(6)=L[A(5)]+ b, we generate 729 shapes for A(6).

A(10) = L[A(9)] +b: 59,049 shapes for A(10).

### GROUP MEMBERS

1. Boye Moses - 10834855 2. Brobbey Serwah Akosua - 10834266 3. Rukiatu Koteikai Neequaye-10835506 4.Azantia Doreen Kaweh - 10835205 5. Collins Amponsah- 10828908 6. Gyabeng Francis 10835854 7. Marcells Herbert 10840998 8. Bonney Samuel 10848112 9.Linda Agyemang 10816143 10. Amanda Awotwe-Nkansah 10839201 11. Incoom-Koomson Kojo - 10833089 12. Princess Tsey - 10821693 13. Phebe Naa Adjeley Okpoti - 10823874 14. Precious Boluwatife Akeredolu 10833291 15. Sylvester Quarshie - 10831359