Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
23 views

Computer Graphics - Lecture 2

Computer Graphics

Uploaded by

alcinialbob1234
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Computer Graphics - Lecture 2

Computer Graphics

Uploaded by

alcinialbob1234
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter II

Mathematics: Basics

All class materials including this PowerPoint file are available at


https://github.com/medialab-ku/openGLESbook

Introduction to Computer Graphics with OpenGL ES (J. Han)


Matrices and Vectors
▪ This chapter delivers an explicit presentation of the basic mathematical
techniques, which are needed throughout this book.
▪ m×n matrix

▪ If m = n, the matrix is called square.


▪ Matrix-matrix multiplication

▪ If A’s dimension is l×m and B’s dimension is m×n, AB is an l×n matrix.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-2


Matrices and Vectors (cont’d)
▪ The typical representation of a 2D vector, (x,y), or a 3D vector, (x,y,z), is called
a row vector. Instead, we can use a column vector:
▪ Matrix-vector multiplication

▪ Transpose denoted by MT

▪ A different way of matrix-vector multiplication

▪ Whereas OpenGL uses the column vectors and the vector-on-the-right


representation for matrix-vector multiplication, Direct3D uses the row vectors
and the vector-on-the-left representation.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-3


Matrices and Vectors (cont’d)
▪ Identity matrix denoted by I

▪ For any matrix M, MI = IM = M.

▪ If two square matrices A and B are multiplied to return an identity matrix, i.e.,
AB = I, B is called the inverse of A and is denoted by A-1. By the same token, A
is the inverse of B.
▪ Theorems
▪ (AB)-1 = B-1A-1 
▪ (AB)T = BTAT (Revisit Mv and vTMT presented in the previous page.)
Introduction to Computer Graphics with OpenGL ES (J. Han) 2-4
Matrices and Vectors (cont’d)
▪ Consider the coordinates of a 2D or 3D vector, v:

▪ Its length denoted by ||v||

▪ Dividing a vector by its length is called normalization.

▪ Such a normalized vector is called the unit vector since its length is 1.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-5


Coordinate System and Basis
▪ Coordinate system = origin + basis
▪ Throughout this book, we use the terms, coordinate system and space,
interchangeably.
▪ In the 2D space, every vector can be defined as a linear combination of basis
vectors. Consider (3,5) for the following three examples.

orthonormal non-orthonormal orthonormal


standard non-standard non-standard

▪ An orthonormal basis is an orthogonal set of unit vectors.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-6


Coordinate System and Basis (cont’d)
▪ 3D standard basis, {e1, e2, e3}, where e1=(1,0,0), e2=(0,1,0), and e3=(0,0,1).

▪ It is also orthonormal.
▪ Of course, we can consider non-standard orthonormal bases in 3D space. You
will see soon.

▪ All 2D and 3D bases presented from now on will be orthonormal.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-7


Dot Product
▪ Given two n-dimensional vectors, a and b, whose coordinates are (a1, a2, .. , an)
and (b1, b2, .. , bn), respectively, their dot product ab is defined to be
a1b1+a2b2+ .. +anbn.
▪ Geometric interpretation of the algebraic formula: When the angle between a
and b is denoted as θ, ab can be also defined as ‖a‖‖b‖cosθ.
▪ If a and b are perpendicular to each other, ab = 0.
▪ If θ is an acute angle, ab > 0.
▪ If θ is an obtuse angle, ab < 0.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-8


Dot Product (cont’d)
▪ Note that, if v is a unit vector, v·v = 1.
▪ Every orthonormal basis has an interesting and useful feature. See two examples.
▪ 2D standard basis, {e1, e2}
▪ e1·e1=1 and e2·e2=1
▪ e1·e2=0 and e2·e1=0.

▪ 3D standard basis, {e1, e2, e3}


▪ If i=j, ei·ej=1.
▪ Otherwise, ei·ej=0.

▪ This feature applies to non-standard orthonormal bases.


Introduction to Computer Graphics with OpenGL ES (J. Han) 2-9
Cross Product
▪ The cross product takes as input two 3D vectors, a and b, and returns another
3D vector which is perpendicular to both a and b. It’s denoted by a×b and its
direction is defined by the right-hand rule.

▪ The length of a×b equals the area of the parallelogram that a and b span:
‖a‖‖b‖sinθ.
▪ If a=b, a×b returns the zero vector, often denoted as 0.
▪ The right-hand rule implies that the direction of b×a is opposite to that of a×b,
i.e., b×a = -a×b, but their lengths are the same.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-10


Cross Product (cont’d)
▪ In the book, [Note: Derivation of cross product] shows how the coordinates of
a×b are derived from those of a and b. See below for an intuitive derivation.
▪ If a=(ax, ay, az) and b=(bx, by, bz), a×b=(aybz-azby, azbx-axbz, axby-aybx).

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-11


Line, Ray, and Linear Interpolation
▪ A line defined by two end points, p0 and p1: p(t) = p0 + t(p1 - p0)

▪ If t is in [-,], p(t) is an infinite line. If [0,], p(t) is a ray, which starts from
p0 and is infinitely extended along the direction vector, p1 - p0 .
▪ When t is restricted to [0,1], p(t) represents the line segment, which
corresponds to the linear interpolation of p0 and p1.
▪ It is a weighted sum of p0 and p1.

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-12


Line, Ray, and Linear Interpolation (cont’d)
▪ Linear interpolation in 3D space

▪ Whatever attributes are associated with the end points, they can be linearly
interpolated. Suppose that the endpoints are associated with colors c0 and c1,
respectively, where c0 = (R0, G0, B0) and c1 = (R1, G1, B1). Then, the color c(t)
is defined as follows:

Introduction to Computer Graphics with OpenGL ES (J. Han) 2-13

You might also like