Docsity

Lecture 4: 2D Geometry and Transformations in Computer Graphics, Assignments of Introduction to Sociology

Partial preview of the text

Download Lecture 4: 2D Geometry and Transformations in Computer Graphics and more Assignments Introduction to Sociology in PDF only on Docsity!

Introduction to

Computer GraphicsFarhana Bandukwala, PhD

Lecture 4: 2D Geometry and

Transformations

Outline

• Assignment 1 clarifications• Coordinate System• Geometric objects and

operations

(Angel,chapter 4)

• Homogeneous coordinates• Transformations

Coordinate System

Image maps toscreen coordinatesystem

(glRasterPos())

Differs from worldcoordinate system

2D transformations &clipping to switchbetween them

y

x y’

x’

Geometric Objects

• Points: location in two dimensional space• Vectors: direction and magnitude• Scalars: real (and complex) numbers

which act on points and vectors accordingto a set of rules

Q

A

B

= A

C

= (.5)B

Transformations: translation

A

Q

Translate 1 point:P = Q + A

P

P =

x’ y’

Q =

x y

A

d

x d

y

Define column vectors:

x’ y’

x’ y’

d

x d

y

Vector notation for translation:

Translate objectconsisting ofmultiple points

Transformations: scale (shear)

B

Shear 1 vector:B

= S

.^

A

Shear object

A

B

x

y’

A

x y

Define column vectors:

x’ y’

s

x

s

y

x y

Scale equation:x’ = s Matrix notation for scale:

x

x , y’ = s

y

y

Homogeneous coordinates

Goal: translation expressed in same form as rotation & scale (matrixmultiplication)

Solution: represent points as homogeneous coordinates (three-tuples)

P=(x,y,W) is the same as Q=(x’,y’,W’) if differ by a multiple (2,3,6) &(4,6,12)

If W is non-zero (x/W,y/W,1) is same point as (x,y,W)

When W is zero -> point at infinity

x

y’ 1

d

x

d

y

x y 1

Matrix notation for translationusing homogeneous coordinates

Homogeneous coordinates (contd.)

x

y’ 1

s

x

s

y

x y 1

Matrix notation for scale

x’ y’ 1

cos

T

-sin

T

sin

T

cos

T

x y 1

Matrix notation for rotation

Affine Transformation

Product of arbitrary rotation,translation,scaling

Preserves parallel lines

Does NOT preserve angles and lengths

square

Rotation by 45 degrees

Non-uniform scaling