Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Mathematics Background

for Computer Graphics(1)


353 ‫ﻋﺎل‬

Dr. Majdi Abdellatief


Software Engineering, PhD
January 2018
Lecture outline
1. Point, scalar and Vectors
2. Vector Notations
3. Adding Vectors Geometrically
4. Unit Vectors
5. Multiplying Vectors (dot product and cross product)
6. Matrix Algebra
7. Matrix Operation
• 7.1 Matrix Addition
• 7.2 Matrix Subtracting
• 7.3 Matrix multiplication
• 7.4 Matrix scale
8. Matrix Types
What is a point ? Vector? and Scalar?
• A quantity that has both
– Size
– Direction Terminal point
– No position
• Examples
– Wind
– Boat or aircraft travel
– Forces in physics Initial point
• Geometrically
– A directed line segment
– Points, vectors defined relative to a coordinate
system
– Computer Graphics: 2 ,3, 4 dimensions ?
– In computer graphics scalar quantities include color, height, 3
width, depth, brightness, number of frames, etc.
What is a point ? Vector? and Scalar?
• A scalar is a single number. e.g. 7
• A vector is a group of scalars. e.g. [4 5 6]
• Scalar addition 7 + 8 = 15
• Vector addition [1 2 3] + [4 5 6] = [5 7 9]
• Scalar product 7×8 = 56
• Scalar product of two vectors
[1 2 3]•[2 4 6] = [1×2 + 2×4 + 3×6] = 28
Vector product of vectors (for later)
Multiplying a vector [3,4,5] by a scalar 2, = [6,8,10]
What is a point ? Vector? and Scalar?

• Magnitude of a scalar
The magnitude of 6 is 6.
The magnitude of a vector is computed as
follows:
Vector Notation
ur
• An arrow over a letter V V

– or a letter in bold face V uuur


B
– An arrow over two letters AB
A
The initial and terminal points
– or both letters in bold face AB

6
Vector Notation
Adding Vectors Graphically
r r r
s a b
General procedure for adding two vectors
graphically:
rar
• (1) On paper, sketch vector a to some
convenient scale and at the proper angle.
r
• (2) Sketch vector b to the same scale,
with its tail at the head of vector , again at
the proper angle.
r
• (3) The vector sum s is the vector that r
r
extends from the tail of a to the head of b
.
Examples of Graphical addition
Addition of Vectors by Means of
Components
r r r
C A B

q
=
Subtraction
r r r r r
d a b a ( b)
Adding and subtracting vectors
Two important properties of vector additions

(1) Commutative law:


r r r r
a b b a
(2) Associative law:
r r r r r r
(a b ) c a (b c )
Vector subtraction is not commutative s −r ≠ r −s
Unit Vectors
A unit vector has a magnitude of 1.
i = [1,0,0] , i=1
j = [0,1,0] , j=1
k= [0,0,1] ,k=1
• Unit vectors are extremely useful in vector
multiplication.
• In computer graphics applications vectors are
used to specify the orientation of surfaces and
the direction of light sources.

Unit victor = Victor / length of Victor


Example: Unit vectors
• Find the magnitude of vector R and the
unit vector.

• R = [1,2,3]
How to describe a two-dimension vector?

Vector Components:The projection of a vector on an axis


is called its component .

If the head of a vector is (x2, y2) and its tail (x1, y1) , Its components are
x2-x1, and y2-y1 , for example (0,1), (3,3)
Matrix Algebra
A matrix is a rectangular array of numbers. By convention we say that an
(n×m) matrix has n rows and m columns; i.e. we write (height × width).
examples:

In the following section we will see


Matrix-Operations and Matrix-Types
Matrix Addition
Matrices can be added, if they are of the same size. To add two matrices:
add the numbers in the matching positions.
This is identical to vector addition
Subtracting
To subtract two matrices: subtract the numbers in
the matching positions:

Note: subtracting is actually


defined as the addition of a
negative matrix: A + (−B)
Matrix Scaling
Matrices can also be scaled by multiplying each element in the matrix by a
scale factor. Again, this is identical to vector scaling
Matrix Multiplication
To multiply a matrix by another matrix we need to multiply the 1st
row and 1st column

(1, 2, 3) • (7, 9, 11) = 1×7 + 2×9 + 3×11 = 58


Check your progress, discuss the results
The Type of Matrix:
1) Identity Matrix:

The identity matrix I is a special matrix that behaves like the number 1
when multiplying scalars (i.e. it has no numerical effect):
IA = A
The identity matrix has zeroes everywhere except the leading diagonal
which is set to 1,
2) Transpose Matricx

To "transpose" a matrix, swap the rows and columns.


We put a "T" in the top right-hand corner to mean transpose:

Note that the order of a matrix is reversed after it has been


transposed. Matrix A is a 3 x 2 matrix, but matrix A' is a 2 x 3 matrix.
3) Vectors Matrix
Vectors are a type of matrix having only one column or one row.
For example, matrix a is a column vector, and matrix a' is a row vector.
4) Square Matrices

A square matrix is an n x n matrix; that is, a matrix with the same


number of rows as columns. In this section, we describe several
special kinds of square matrix.

4-1) Symmetric matrix.


If the transpose of a matrix is equal to
itself, that matrix is said to be
symmetric. Two examples of symmetric matrices

4-2) Diagonal matrix.


A diagonal matrix is a special kind
of symmetric matrix. It is a
symmetric matrix with zeros in the
off-diagonal elements. Two
diagonal matrices are shown below. Two examples of diagonal matrices
4-3) Scalar matrix.
A scalar matrix is a special kind of
diagonal matrix. It is a diagonal
matrix with equal-valued elements
along the diagonal. Two examples of Scalar matrices

5) Rectangular Matrix
A rectangular matrix is an N x M matrix; that is, a
matrix with the different number of rows as columns
Check your progress

Consider the matrics a, A, b and c Which of the following


statements are true?
I. a is a row matrix
II. A = B'
III. C is a symmetric matrix
(A) I and II
(B) I and III
(C) II and III
(D) None of the above
(E) All of the above

You might also like