0% found this document useful (0 votes)
47 views20 pages

Matrices in Computer Graphics

Uploaded by

Ayushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views20 pages

Matrices in Computer Graphics

Uploaded by

Ayushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

MATRICES IN

COMPUTER
GRAPHICS
SUBMITTED BY
BADAL SINGH(19BSM02)

DEPARTMENT OF BASIC AND APPLIED SCIENCES


ABSTRACT
In this project , 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 calculus.
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.

should be noted that for any point 𝑇(𝑥,𝑦) in a 2D plane, a


Before considering the abovementioned transformations, it

this article, column vector representation is used, i.e. point 𝑇


column vector or row vector representation can be used. In

is represented as 𝑇=.
TRANSLATION

moves the current point 𝑇= to the point 𝑇= for a


Translation is a geometric transformation that

given vector =+Translation is shown in figure.


Therefore , point T’ can be written as :
…..(1)

and in matrix notation as:

. …….(2)

ROTATION

around the point 𝑂(0,0) by the angle 𝜃 is a transformation that maps


Let O(0,0) and be a point and an angle given respectively. Rotation

every point 𝑇 in the plane to the point 𝑇′ in such a manner that the
following properties are true :

and ∠𝑇O𝑇′=𝜃
By convention, rotation by the positive angle 𝜃 goes counter-
clockwise in fig 1 , while rotation by the negative angle 𝜃 goes

Rotation of the point 𝑇(𝑥,𝑦) located at the angle 𝜙 from the


clockwise in fig 2.

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

𝑥=𝑟cos𝜙 ……..(3)
expressed as:

𝑦=𝑟sin𝜙 …..(4)

Similarly, coordinates of the point 𝑇′(𝑥′,𝑦′) can be

𝑥′=𝑟cos(𝜙+𝜃) ….(5)
expressed as:

𝑦′=𝑟sin(𝜙+𝜃) ….(6)
By using the equations (3) and (4), as well as addition formulas,

𝑥′= 𝑟cos𝜙cos𝜃−𝑟sin𝜙sin𝜃= 𝑥cos𝜃−𝑦sin𝜃


the following formulas can be obtained:

𝑦′= 𝑟cos𝜙sin𝜃+𝑟sin𝜙cos𝜃 = 𝑥sin𝜃+𝑦cos𝜃


……(7)
……(8)
which can be, in a matrix form, written as:
……(9)

SCALING
Scaling is a mapping that expands or compresses each point

the scaling factor 𝑆. If the scaling factors for each


coordinate. The scaling of each coordinate is determined by

coordinate are different, scaling is disproportionate. If the

proportional. For the point 𝑇(𝑥,𝑦) and the scaling factor


scaling factors are the same for all coordinates, scaling is

and that scales the point 𝑇(𝑥,𝑦) in the 𝑥 and 𝑦 direction


respectively, the following coordinates of the point T’ are
obtained:
….(10)
…..(11)
In the matrix form , equations (10) and (11) can be
written as :
……(12)
For example, for the scaling factors =2, the scaling process of the
square is shown in Figure
REFLECTION
Reflection is a special case of a scaling where the size of the

reflecting is about the 𝑦 axis. If the scaling factors are =1 and =


object does not change. For the scaling factors = −1 and = 1,

−1, there is a reflection about the 𝑥 axis. For the scaling factors
== −1, reflection is about the 𝑥 and 𝑦 axes. In Fig. , reflections
about the 𝑥 and 𝑦 axes of Super Mario, the main character in
the Super Mario video games as an original object, are shown.
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.
Coordinates of the point 𝑇′(𝑥′,𝑦′) can be defined as:
𝑥′=𝑥 + 𝑦 ∙tan 𝛽
𝑦′=𝑦 + 𝑥 ∙tan 𝛼
…… (13)

In the matrix form, point 𝑇′ can be represented as:


……. (14)

. …….(15)

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,

are introduced. Thus, each Cartesian point 𝑇(𝑥,𝑦) can be converted


i.e. to reduce them to matrix multiplication, homogeneous coordinates

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

sets of homogeneous coordinates, (𝑥,𝑦,𝑤) and (𝑥′,𝑦′,𝑤′),


space, here they represent a point in the plane or 2D point. Two

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

one point in the plane (), where 𝑡 ≠ 0, actually represents a line


in the plane. This class of triples of coordinates which represent

in the 3D space. It should be noted that at least one

that the point (0,0,0) is not allowed. If the coordinate 𝑤≠0, each
homogeneous coordinate must be different from zero, meaning

of them can be divided by 𝑤, which is why the point 𝑇 can be

𝑇(𝑥,𝑦,𝑤) =
written as:
……….(16)
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:
……(17)
where translation is reduced to a matrix multiplication:
……..(18)
Furthermore, the homogeneous translation matrix is:
……(19)
homogeneous rotation matrix:
……..(20)
homogeneous scaling matrix :
………(21)
And homogeneous shear matrix :
………(22)
In order to conduct several sequences of the transforms, all
these transformations must be compound. After the

rotation and translation over the point 𝑇 in this original order,


implementation of all transformations, for example scaling,

and the coordinates of the point 𝑇′ could be calculated in the


following way :

…..(23)
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

application software is written in 𝐶#, an object-oriented


interface for studying 2D graphics is created. This

programming language. One can find more about 𝐶#, for


example, in [5,7].

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,

of the drawn object with respect to the 𝑥𝑥 or 𝑦𝑦 axis in


or to directly insert only the rotation angle or shear angles

the two lower matrices as shown in Fig.

You might also like