Top Banner
Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim
31

Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Jan 11, 2016

Download

Documents

Blaise Harmon
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Geometric Objects

2001. 7. 6Computer Graphics Lab.Sun-Jeong Kim

Page 2: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-2-

PointsSingle Coordinate Position

Set the bit value(color code) corresponding to a specified screen position within the frame buffer

x

ysetPixel (x, y)

Page 3: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-3-

Lines Intermediate Positions between Two End

points DDA, Bresenham’s line algorithms

Jaggies= Aliasing

Page 4: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-4-

DDA Algorithm Digital Differential Analyzer

Slope >= 1 Unit x interval = 1

0 < Slope < 1 Unit y interval = 1

Slope <= -1 Unit x interval = -1

-1 < Slope < 0 Unit y interval = -1

x1

y1

x2

y2

myy kk 1

x1

y1

x2

y2

mxx kk

11

x1

y1

x2

y2

myy kk 1

x1

y1

x2

y2

mxx kk

11

Page 5: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-5-

Bresenham’s Line AlgorithmMidpoint Line Algorithm

Decision variable

NE

MQ

cybxa

yxF

MFd

pp

pp

2

11

2

1,1

d > 0 : choose NE : dnew= dold+a

d <= 0 : choose E : dnew= dold+a+b

2

1,2 ppnew yxFd

2

3,2 ppnew yxFd

P(xp, yp) E

Page 6: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-6-

Bresenham’s Algorithm(cont.) Initial Value of d

Update d

bayxF

cybxayxF

2

1,

2

11

2

1,1

00

0000

cbyaxyxF 2,

bad 2

2

,

,

then ,0 if

bad

y

x

d 2

, then ,0 if

ad

xd

0, cbyaxyxF

Bxdx

dyy

0, dxBydxxdyyxF

dxBcdxbdya , ,

Page 7: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-7-

PolygonsFilling Polygons

Scan-line fill algorithm Inside-Outside tests

Boundary fill algorithm

Page 8: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-8-

Scan-Line Polygon Fill Topological Difference between 2 Scan

lines y : intersection edges are opposite sides y’ : intersection edges are same side

y

y’

Page 9: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-9-

Scan-Line Polygon Fill (cont.)Edge Sorted Table

C

C’

B

D

E

A

01

yA

yD

yC

Scan-Line Number

yE xA1/mAE yB xA

1/mAB

yC’ xD1/mDC yE xD

1/mDE

yB xC1/mCB

Page 10: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-10-

Inside-Outside TestsSelf-Intersections

Odd-Even ruleNonzero winding number rule

exterior

interior

Page 11: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-11-

Boundary-Fill AlgorithmProceed to Neighboring Pixels

4-Connected8-Connected

Page 12: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-12-

AntialiasingAliasing

Undersampling: Low-frequency sampling

Nyquist sampling frequency:Nyquist sampling interval: max2 ff s

2cyclex

xs

Page 13: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-13-

Antialiasing (cont.)Supersampling (Postfiltering)

Pixel-weighting masksArea Sampling (Prefiltering)Pixel Phasing

Shift the display location of pixel areasMicropositioning the electron beam in relati

on to object geometry

Page 14: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-14-

SupersamplingSubpixels

Increase resolution

10 11 12

20

21

22

(10, 20): Maximum Intensity

(11, 21): Next Highest Intensity

(11, 20): Lowest Intensity

Page 15: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-15-

Pixel-Weighting MasksGive More Weight to Supixels Near the C

enter of a Pixel Area

1 2 1

2 4 4

1 2 1

Page 16: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-16-

Area SamplingSet Each Pixel Intensity

Proportional to the Area of Overlap of Pixel2 Adjacent vertical (or horizontal)

screen grid lines trapezoid

10 11 12

20

21

22

(10, 20): 90%

(10, 21): 15%

Page 17: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-17-

Filtering TechniquesFilter Functions (Weighting

Surface)

Box Filter Cone Filter Gaussian Filter

Page 18: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Mathematics for CG

Page 19: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-19-

Coordinate Reference Frames2D Cartesian Reference Frames

x

y

x

y

Page 20: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-20-

2D Polar Coordinate Reference Frame

r

r

x

y

x

yyxr

ryrx

122 tan,

sin,cos

s

rP

radianr

rr

sradian

22

360

Page 21: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-21-

3D Cartesian Reference FrameRight-Handed v.s. Left-Handed

y

xz

Right-handed Left-handed

y

x

z

Page 22: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-22-

3D Curvilinear Coordinate SystemsGeneral Curvilinear Reference

FrameOrthogonal coordinate system

Each coordinate surfaces intersects at right angles

axisX1

axisX 2

axisX 3

33 constX11 constX

22 constX

Page 23: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-23-

Cylindrical-Coordinate

: radius of vertical cylinder

: vertical plane containing z-axis

: horizontal plane parallel to xy-plane

z

constant

zz

y

x

sin

cos

Transform to Cartesian coordinator

z

x axis

y axis

z axis

),,( zP

Page 24: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-24-

Spherical-Coordinate

: radius of sphere

: vertical plane containing z-axis

: cone with the apex at the origin

constant

cos

sinsin

sincos

rz

ry

rx

Transform to Cartesian coordinator

z

x axis

y axis

z axis

),,( rP

r

Page 25: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-25-

Solid Angle3D Angle Defined on a Sphere

Steradian

r

A2r

ASteradian :

Total solid angle :

44

2

2

2

r

r

r

Asteradian

Page 26: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-26-

Points & VectorsPoint

Position in some reference frameDistance from the origin depends on

the reference frame

PFrame B

Frame Ax

y

AO

BO

Page 27: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-27-

Points & Vectors (cont.)Vector

Difference between two point positions

Properties : Magnitude & direction Same properties within a single

coordinate system Magnitude is independent from

coordinate frames

yx VV

yyxx

PP

,

, 1212

12

V 22yx VV VMagnitude :

x

y

V

V1tanDirection :

Page 28: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-28-

3D VectorMagnitude

Directional angle

222zyx VVV V

x

y

z

VVVzyx VVV

cos,cos,cos

1coscoscos 222

Page 29: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-29-

Vector Addition &Scalar MultiplicationAddition

Scalar multiplication

),,( 21212121 zzyyxx VVVVVV VV

1V

2V 2V

1V

21 VV

),,( zyx aVaVaVa V

Page 30: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-30-

Vector MultiplicationScalar Product(Inner Product)

zzyyxx VVVVVV 212121

2121 cos

VVVV Commutative :

Distributive :

1221 VVVV

3121321 )( VVVVVVV Orthogonal : 021 VV

1V

2V

cos2V

Page 31: Geometric Objects 2001. 7. 6 Computer Graphics Lab. Sun-Jeong Kim.

Korea UniversityComputer Graphics-31-

Vector Multiplication (cont.)Vector Product(Cross Product)

zyx

zyx

zyx

xyyxzxxzyzzy

VVV

VVV

VVVVVVVVVVVV

222

111

212121212121

2121

,,

sin

uuu

VVuVV

Noncommutative :

Nonassociative :

Distributive :

1221 VVVV

3121321 )( VVVVVVV

321321 )()( VVVVVV

21 VV 2V

1V

uRight-handed rule!