MATRICES IN COMPUTER GRAPHICS

: In this article, the usage of matrices and matrix operations in computer graphics is shown. A brief overview of geometric transformations in computer graphics is given. The "Matrix - Computer Graphics" application software is created for the representation and easier understanding of relations between geometric transformations and matrix


INTRODUCTION
Computer graphics is a computing field that involves the creating, storing and processing of image content via computer. It has a wide application in science, engineering, art and especially in the field of entertainment, movies and video games. [3,2] Computer graphics began to progress in the 1960s when the first interactive creation of graphic content was enabled, and since then it has been developing incredibly quickly [6]. It is important to note that computer graphics applications are used for various educational purposes. For example, computer graphics applications can, in the education process, help people with learning difficulties [10], assist students in understanding computer science algorithms [4], as well as increasing students' interest in programming and computer graphics [1].

2D TRANSFORMATIONS
The fundamental part of computer graphics are geometric transformations that can change the position, size, orientation and shape of an object. Basic geometric transformations in a 2D plane are called 2D transformations and those are translation, rotation, scaling, reflection and shear. Furthermore, each of the well-known transformations is briefly explained in [11], [9].
Before considering the abovementioned transformations, it should be noted that for any point ( , ) in a 2D plane, a column vector or row vector representation can be used. In this article, column vector representation is used, i.e. point is represented as = � �.

Translation
Translation is a geometric transformation that moves the current point = � � to the point ′ = � ′ ′ � for a given vector ⃗ = ⃗ + ⃗ = � �. Translation is shown in Fig. 1.

Figure 1 Translation
Therefore, point ′ can be written as: and in matrix notation as:

Rotation
Let (0,0) and be a point and an angle given respectively. Rotation around the point (0,0) by the angle is a transformation that maps every point in the plane to the point ′ in such a manner that the following properties are true: | | = | ′ | and ∠ ′ =

Figure 2 Rotation
By convention, rotation by the positive angle goes counter-clockwise (Fig. 2a), while rotation by the negative angle goes clockwise (Fig. 2b).
Rotation of the point ( , ) located at the angle from the horizontal coordinate with a distance from the origin of the coordinate system leads to a new point ′ ( ′ , ′ ). By using standard trigonometry, coordinates of the point ( , ) can be expressed as: Similarly, coordinates of the point ′ ( ′ , ′ ) can be expressed as: By using the equations (3) and (4), as well as addition formulas, the following formulas can be obtained: ′ = cos cos − sin sin = cos − sin , (7) ′ = cos sin + sin cos = sin + cos , (8) which can be, in a matrix form, written as:

Scaling
Scaling is a mapping that expands or compresses each point coordinate. The scaling of each coordinate is determined by the scaling factor . If the scaling factors for each coordinate are different, scaling is disproportionate. If the scaling factors are the same for all coordinates, scaling is proportional. For the point ( , ) and the scaling factor and that scales the point ( , ) in the and direction respectively, the following coordinates of the point ′ are obtained: In the matrix form, equations (10) and (11) can be written as: For example, for the scaling factors = = 2, the scaling process of the square is shown in Fig. 3.

Shear
Skewing the object with respect to the or axis is called shear transformation. Skewing by the angle with respect to the axis and by the angle with respect to the axis is illustrated in Fig. 5.

Figure 5 Shear
Coordinates of the point ′ ( ′ , ′ ) can be defined as: In the matrix form, point ′ can be represented as:

Homogeneous Coordinate System
The process of implementing several successive transformations is, by using Cartesian coordinates, computationally more extensive. Namely, it can be noticed that to perform translation, matrix addition is carried out, while to perform other transformations, only matrix multiplication is carried out. In order to treat all transformations in the same manner, i.e. to reduce them to matrix multiplication, homogeneous coordinates are introduced. Thus, each Cartesian point ( , ) can be converted into homogeneous coordinates ( , , ), and a coordinate system with this point representation is called a homogeneous coordinate system. Although triples of coordinates commonly display a point in space, here they represent a point in the plane or 2D point. Two sets of homogeneous coordinates, ( , , ) and ( ′, ′, ′), represent the same point if one is a multiple of the other. For example, coordinates (1,2,3) and (2,4,6) represent the same point. It can be concluded that one point in homogeneous coordinates can be displayed in infinitely many ways, that is, one whole class of triples of coordinates represents the same point in the plane. This class of triples of coordinates which represent one point in the plane ( , , ), where ≠ 0, actually represents a line in the 3D space. It should be noted that at least one homogeneous coordinate must be different from zero, meaning that the point (0,0,0) is not allowed. If the coordinate ≠ 0, each of them can be divided by , which is why the point can be written as: ( , , ) = � , , 1� = ( , , 1) All such points form a plane with the equation = 1 in the 3D space. In the case of = 0, it is a point in infinity, which will not be considered in more detail.
The usage of homogeneous coordinates is of great importance in computer graphics. Homogeneous coordinates provide a uniform mathematical tool for all transformations, where matrix transformation through homogeneous coordinates must be in the 3 × 3 form [8].
In that sense, homogeneous translation matrix becomes: where translation is reduced to a matrix multiplication: Furthermore, the homogeneous translation matrix is: homogeneous rotation matrix: homogeneous scaling matrix: and homogeneous shear matrix: In order to conduct several sequences of the transforms, all these transformations must be compound. After the implementation of all transformations, for example scaling, rotation and translation over the point in this original order, and the coordinates of the point ′ could be calculated in the following way: i.e. they could be calculated by multiplying the homogeneous scaling matrix, homogeneous rotation matrix and homogeneous translation matrix, respectively, into a single matrix.

"MATRIX -COMPUTER GRAPHICS"
In high school or at the faculty level education, matrix calculus is an integral and significant part of the mathematics curriculum for students. One of the possible ways of matrix operation implementation is computer graphics.
In order to better illustrate the relations between geometric transformations and the matrix calculus described in the previous section, the "Matrix -Computer Graphics" application software that provides a simple interface for studying 2D graphics is created. This application software is written in #, an object-oriented programming language. One can find more about #, for example, in [5,7]. The "Matrix -Computer Graphics" application is available at: http://www.mediafire.com/file/pgv2jkrpr0gqg47/Matrix_-_Computer_Graphics.exe or http://www.mediafire.com/file/84b4dhwonqcb78c/Matrix_-_Computer_Graphics.zip Using the "Matrix -Computer Graphics" application you can easily apply one of the abovementioned transformations on the desired object. Students can easily draw the desired object in the coordinate system and optionally, by using the determined matrices, apply the corresponding geometric transformations. One of the possibilities is to optionally enter data in the upper matrices for the corresponding transformation (translation, rotation, scaling or shear) of the drawn object, or to directly insert only the rotation angle or shear angles of the drawn object with respect to the or axis in the two lower matrices as shown in Fig. 6.

CONCLUSION
Computer graphics is an unavoidable part of everyday life. As it is widely known, computer graphics is present in computer games, films, television commercials, as well as in various branches of the industry. In this paper, authors tried to get closer to the students who are dealing with computer science, especially computer graphics, the mathematical background of computer graphics in which the term matrix is in the center. Although computer graphics is nowadays usually 3D, in this paper the authors looked only at 2D transformations in order to show, in a simpler way, the relationship between the matrix calculus and geometric transformations used in computer graphics. For this purpose, the "Matrix -Computer Graphics" application gives a contribution in the visualization and easier learning of relationships between the matrices and their applications on display and positioning, as well as on transforming different objects on a computer.