168 471 Computer Graphics, KKU. Lecture 41 The Computer Programming Laws Any given program, when...

Post on 18-Jan-2016

216 views 0 download

Tags:

Transcript of 168 471 Computer Graphics, KKU. Lecture 41 The Computer Programming Laws Any given program, when...

168 471 Computer Graphics, KKU. Lecture 4

1

The Computer Programming Laws

• Any given program, when running, is obsolete.

• Any given program costs more and takes longer.

• If a program is useful, it will have to be changed.

• If a program is useless, it will have to be documented.

• Any given program will expand to fill all available memory.

• The value of a program is proportional to the weight of its output.

• Program complexity grows until it exceeds the capability of the programmer who must maintain it.

168 471 Computer Graphics, KKU. Lecture 4

2

Points

• 3One of the fundamental objects in D space th athas posi t i on.

• TTT TTTTT TTT TTT TTTTTTTTT TT TTTTTTTT TTTTTTcs.

• Distinguishedf r omeach ot her wi t h i t s posi t i on.• Drawn as dots.• TTTTTTT TT TTTTTTTTTTT TTTT TTTTTTT TTTT TT

P TTT Q.

• TTT TTTTTTTTT TTTTTTTTTT TTTTTT TT TTTTTTT TT TTTTTTTTT , points componentwise by utilizing parenthesis

e.g(x,y,z).

168 471 Computer Graphics, KKU. Lecture 4

3

Trigonometry

168 471 Computer Graphics, KKU. Lecture 4

4

Polar Coordinates

168 471 Computer Graphics, KKU. Lecture 4

5

Parametric Functions

168 471 Computer Graphics, KKU. Lecture 4

6

Parametric Lines

168 471 Computer Graphics, KKU. Lecture 4

7

Parametric Circles

168 471 Computer Graphics, KKU. Lecture 4

8

Plotting Parametric Functions

168 471 Computer Graphics, KKU. Lecture 4

9

• The fundamental 3D space objects like points.• Hasbot h magni t ude and di r ect i on.• Butposi t i onl ess.• Drawn as lines segments with arrow.• Denoted by lower case letters with an arrow ab

TTT TTTT TT • we represent vectors componentwise by utilizin

TTT T.< u,v,w>.• TTT TTTT TTTT TT TTTTT P TTT Q TTTTT TTTTTT ,

T TTTTTT TTTTTT TTTT TTTT

Vectors

v

v w

and

v P - Q

v

168 471 Computer Graphics, KKU. Lecture 4

10

Vectors

168 471 Computer Graphics, KKU. Lecture 4

11

Properties of Vectors

168 471 Computer Graphics, KKU. Lecture 4

12

Properties of Vectors (Cont.)

168 471 Computer Graphics, KKU. Lecture 4

13

“Multiplying” Vectors

168 471 Computer Graphics, KKU. Lecture 4

14

Vector Projection

168 471 Computer Graphics, KKU. Lecture 4

15

Planes

168 471 Computer Graphics, KKU. Lecture 4

16

Planes (Cont.)

168 471 Computer Graphics, KKU. Lecture 4

17

Matrices

168 471 Computer Graphics, KKU. Lecture 4

18

Matrix Multiplication

168 471 Computer Graphics, KKU. Lecture 4

19

Matrices (Cont.)

168 471 Computer Graphics, KKU. Lecture 4

20

Matrix Inversion

168 471 Computer Graphics, KKU. Lecture 4

21

• Cartesian coordinate system• Frame-based coordinate system• Device space• Screen Space• Image Space• Object Space• World Space

Coordinate Systems

168 471 Computer Graphics, KKU. Lecture 4

22

Cartesian coordinate system

Right-hand system

z

x y

Right-hand system

x

z

y

168 471 Computer Graphics, KKU. Lecture 4

23

Cartesian coordinate system(Cont.)

• In the computer graphics community• In computer graphics

Right-hand system

z

x

y

Right-hand system

x

z

y

168 471 Computer Graphics, KKU. Lecture 4

24

Frame-based coordinate system

• Consists of an origin and linearly independent vectors

( , , , )F u v w O

u

v

w

O

168 471 Computer Graphics, KKU. Lecture 4

25

• The actual coordinate system by which points are plotted on the graphics device.

• Measured in pixels• On SGI machines

– (0,0) is the lower left corner of a window.– X value increases to the right.– Y value increases upward.

• On Window platform– (0,0) is the upper left corner of a window.– X value increases to the right.– Y value increase downward.

Device Space

x

x

y

y

168 471 Computer Graphics, KKU. Lecture 4

26

Screen Space

• Defined to be the square on the xy plane.

• TTTTTT TT TTTTTT TTTTT TT TTTT TTTTTTT TTT T peci fi c gr aphi cs devi ces

1 , 1x y

168 471 Computer Graphics, KKU. Lecture 4

27

Image Space

• Used in 3-D system to allow for depth calculations.

• Defined by• Points in this space are mapped onto screen

space by projecting them onto the plane .• For example, any point in image space

will be protected to the center of the display screen.

1 , , 1x y z

0z (0,0, )z

168 471 Computer Graphics, KKU. Lecture 4

28

World Space

• The coordinate system of the scene • Must be projected into image space for

viewing.

168 471 Computer Graphics, KKU. Lecture 4

29

Object Space

• Localized system of an object being created.• After objects are created, about the world

space they can be– transformed– duplicated– moved– .etc

168 471 Computer Graphics, KKU. Lecture 4

30

Affine Space

• Made up of points and vectors• In affine space,

168 471 Computer Graphics, KKU. Lecture 4

31

Affine Space (Cont.)

• Vectors can be added, but points cannot.• Vectors can be scaled, but point cannot.

That is

168 471 Computer Graphics, KKU. Lecture 4

32

What is Affine Combination?

If are points and are scalars such that

then

is defined to be the point

168 471 Computer Graphics, KKU. Lecture 4

33

Affine Combination of 2 Points

TTT P1

TTT P2

TTTTTT TT TT TTTTTT TTTTTT TTTTTTTT, the expression

This P point represents a point on the line that passes

through P1 and P2

T TTT TTTT TT then P is somewhere on the line

segment joining P1 and P2 .

168 471 Computer Graphics, KKU. Lecture 4

34

Affine Combination of 3 Points

Consider three points P1 P2 and P3 that form a triangle,a point P can be defined by

or

then the point will be within (or on the boundary) of the triangle.

If

168 471 Computer Graphics, KKU. Lecture 4

35

Convex VS Non-Convex

Convex Set Non-Convex Set

168 471 Computer Graphics, KKU. Lecture 4

36

Coordinates of a point in the frame

Given a frame , a point P can be written

as Where O is an origin of the frame and

so the point can be written uniquely as

The set of values are the coordinates TT P relative to the frame .

168 471 Computer Graphics, KKU. Lecture 4

37

Cartesian Frames

The 2D standard Cartesian frame, denoted as , has A point P = will has the coordinate (x,y) relative to this frame

A Cartesian frame with any dimension consists of(0,0,…..,0) as an origin<1,0,…,0>, <0,1,…,0>,…, <0,0,…,1> as

basis vectors

168 471 Computer Graphics, KKU. Lecture 4

38

Examples

Given the frame which has the origin (0,0) and the vectors u = <1,0> and v = <1,1>, the point P that has its coordinate (5,3) in this frame, can be written as

which is the Cartesian coordinate (8,3).

or

168 471 Computer Graphics, KKU. Lecture 4

39

Matrix Representation of Points

T TTTT T TT TT TTTTTT TTTTT T T T , can write a point P uniquely as

or

168 471 Computer Graphics, KKU. Lecture 4

40

Matrix Representation of Vectors

Given a frame in an affine space , we can write a vector v uniquely as

or

168 471 Computer Graphics, KKU. Lecture 4

41

Converting between Frames

Suppose that we have the point P , with coordinates (3,2) in the frame

. What are the coordinates o

f the point in the frame ?

Consider the two frames and _ where

168 471 Computer Graphics, KKU. Lecture 4

42