87
Komputer Grafik Kuliah 1: Prinsip Dasar Komputer Grafik Dr. Trias Aditya

Komfik_Geometri

Embed Size (px)

Citation preview

Page 1: Komfik_Geometri

Komputer GrafikKuliah 1: Prinsip Dasar Komputer Grafik

Dr. Trias Aditya

Page 2: Komfik_Geometri

Rute• Computer Graphic Pipeline Proses Operasi Komputer Grafik Teknik Geodesi & Geomatika & Komputer Grafik Contoh Aplikasi

• Geometri 2D & Geometri 3D Sistem Koordinat Transformasi Koordinat Proyeksi

Page 3: Komfik_Geometri

Computer Graphics Pipeline

Page 4: Komfik_Geometri

Definisi 101

• Komputer Grafik: mencakup tampilan,manipulasi dan penyimpanan gambar dandata eksperimental untuk penyajianmenarik memanfaatkan komputer

• Komputer grafik terdiri dari komputer,memori dan: monitor berwarna, pirantikeras penunjang pemgolahan data dantampilan serta piranti lunak data grafis

Page 5: Komfik_Geometri

Definisi 101

• Komputer Grafik: mencakup tampilan,manipulasi dan penyimpanan gambar dandata eksperimental untuk penyajianmenarik memanfaatkan komputer

• Komputer grafik terdiri dari komputer,memori dan: monitor berwarna, pirantikeras penunjang pemgolahan data dantampilan serta piranti lunak data grafis

Page 6: Komfik_Geometri

• Proses memproduksi gambar atau citramenggunakan komputer proses menulis program untukmenghasilkan/mengolah grafik gambar yang dihasilkan tertayang dilayar komputer sebagai element grafikdisebut “pixel”

Page 7: Komfik_Geometri

ObjectSpecification

SceneDescription

ModelTransformation

SceneDescription

Clipping &Hidden Surface

Removal

ViewTransformation

View & LightSpecification

Shading Image

Image DisplayTransformation

Output

MODELING

RENDERING

DISPLAY

McConnell 2006

Page 8: Komfik_Geometri
Page 9: Komfik_Geometri

Komputer Grafik untuk TeknikGeodesi & Geomatika

• Ragam AplikasiKomputer Grafik:- 3D object modeliing- animation- visualization

3D surface model

Depth image Triangle mesh Texture image

Textured 3DWireframe model

Page 10: Komfik_Geometri

• intermap_harrier2.avigallery_30.mpeg

Page 11: Komfik_Geometri

Supporting Disciplines

• Computer science (algorithms, datastructures, software engineering, …)

• Mathematics (geometry, numerical, …)• Physics (Optics, mechanics, …)• Psychology (Colour, perception)• Art and design

Page 12: Komfik_Geometri

Applications

• Computer Aided Design (CAD)• Computer Aided Geometric Design

(CAGD)• Entertainment (animation, games, …)• Geographic Information Systems (GIS)• Visualization (Scientific Vis., Inform. Vis.)• Medical Visualization• …

Page 13: Komfik_Geometri

Interactive Computer Graphics

User

Application

Screen

input

image

Page 14: Komfik_Geometri
Page 15: Komfik_Geometri

A detailedpolygonmesh(thank

you, WetaDigital)

Page 16: Komfik_Geometri

Graphics pipeline

User

Screen

Model

Geometry, colour

Map

Display

Edit

Page 17: Komfik_Geometri

Manipulation of geometry andcolor…

Monsters, Inc

Page 18: Komfik_Geometri

Manipulation of geometry andcolor…

Page 19: Komfik_Geometri

Manipulation of geometry andcolor…

Page 20: Komfik_Geometri

Manipulation of geometry andcolor…

Page 21: Komfik_Geometri

Manipulation of geometry andcolor…

Page 22: Komfik_Geometri

Representations in graphics

Vector Graphics• Image is represented by continuous

geometric objects: lines, curves, etc.

Raster Graphics• Image is represented as an rectangular

grid of coloured squares

Page 23: Komfik_Geometri

Vector graphics

• Graphics objects: geometry + colour• Complexity ~ O(number of objects)• Geometric transformation possible without

loss of information (zoom, rotate, …)• Diagrams, schemes, ...• Examples: PowerPoint, CorelDraw, ...

Page 24: Komfik_Geometri

Raster graphics• Generic• Image processing techniques• Geometric Transformation: loss of

information• Complexity ~ O(number of pixels)• Jagged edges, anti-aliasing• Realistic images, textures, ...• Examples: Paint, PhotoShop, ...

Page 25: Komfik_Geometri

Conversion

Vector graphics

Rasterization, Pattern recognition

Scan conversion

Raster graphics

Page 26: Komfik_Geometri

Hardware

• Vector graphics• Raster graphics• Colour lookup table• 3D rendering hardware

Page 27: Komfik_Geometri

I/O Devices

3D Scanner 2D ScannerCCDCharge couple device

Page 28: Komfik_Geometri

Vector Graphics Hardware

V E C T O R

Display Controller

move 10 20

line 20 40

...

char O

char R

Display list

continuous & smoothlines

no filled objects

random scan

refresh speed dependson complexity of thescene

Page 29: Komfik_Geometri

Raster Graphics Hardware

Video Controller

jaggies (stair casing)

filled objects

(anti)aliasing

R A S T E R

refresh speed independent ofscene complexity

pixel

scan conversion

resolution

bit planes

0 0 0 0 0 00 7 7 7 60 7 7 70 0 00 00

Frame buffer

Page 30: Komfik_Geometri

Colour Lookup Table

0 0 0 0 0 00 7 7 7 6

0 7 7 70 0 0

0 00

Frame buffer

0 0 0

102 255 53

255 255 204

255 102 153

102 0 51

RR GG BB

0

1

2

4

7

...

colourindex

CLUT:

pixel = code

True colour:

pixel = R,G,B

Page 31: Komfik_Geometri
Page 32: Komfik_Geometri

Geometri Komputer Grafik

Page 33: Komfik_Geometri

2D geometric modelling

• Coordinates• Transformations

Page 34: Komfik_Geometri

Coordinates

• Point: position on planep = (px , py)x = (x, y)x = (x1 , x2)x = x1 e1 + x2 e2, e1 = (1, 0), e2 = (0, 1)

• Vector: direction and magnitudev = (vx , vy), etc.

x

yp

v

Page 35: Komfik_Geometri

Vector arithmetic

• Addition of two vectors:v + w = (vx + wx , vy + wy)

• Multiplication vector-scalar:v = (vx , vy)

x

yw

v

v+w

x

y

v

2v

Page 36: Komfik_Geometri

Coordinate systems

imagewheel

train

world

[email protected]

Page 37: Komfik_Geometri

Why??

Page 38: Komfik_Geometri

Pendefinisian Sistem Koordinatpenting karena….

• Terdapat banyak sistem koordinat padaproses/operasi komputer grafik: WorldCoordinates, Model Coordinates, ViewCoordinates

• Perlu kerangka referensi untukmemposisikan obyek dalam dunia nyata,model maupun dalam tampilan.

Page 39: Komfik_Geometri

Contoh

• Penggambaran obyek 2D pada komputer:

x

y

x

y

Koordinat Peta

Koordinat Layar

Page 40: Komfik_Geometri

Transformasi Geometri

Page 41: Komfik_Geometri

Transformasi Geometri padaKomputer Grafik

• Transformasi geometri memegang perananpenting di komputer grafik karena : obyekdipindah, diperbesar untuk menghasilkanefek/modifikasi

• Graphics API (Application ProgrammingInterface) melakukan transformasi untukmenempatkan/merepresentasikan obyeksebagai tampilan

• Perlu dilakukan transformasi 3D ke 2D (obyekdengan geometri 3D ke layar 2D)

Page 42: Komfik_Geometri

Transformation Pipeline

• World Transformation– Model coordinates World coordinates

• View Transformation– World coordinates Camera space

• Projection Transformation– Camera space View Plane

• These are a series of matrix multiplications

Page 43: Komfik_Geometri

World Transformation

• Translation• Rotation• Scaling

+x

+z

+y

World origin

World Coordinates

Local model coordinates

Local model coordinates

Page 44: Komfik_Geometri

View Transformation

+x

+z

+y

World origin

World Coordinates

+y

+x

+z

• Cameraposition

• Look vector

Page 45: Komfik_Geometri

• Perbesaran (scaling), Rotation (rotasi) dantranslasi (translation) merupakan jenistransformasi yang penting pada komputergrafik.

Page 46: Komfik_Geometri

Skala

Page 47: Komfik_Geometri

Rotasi

Page 48: Komfik_Geometri

Pemotongan (Shear)

Page 49: Komfik_Geometri

Translasi (Translation)

NOT LINEAR!!!Perkalian matrix tidak dapat digunakan

Page 50: Komfik_Geometri

Homogeneous Coordinates

• Pada komputer grafik, transformasi yangkompleks (menggunakan matrix)diperlukan.

• Dengan pendekatan Kartesian, translasidan rotasi, perbesaran tidak dapatdigabung menjadi satu proses

Xn

Yn=

X

YT *

Page 51: Komfik_Geometri

Koordinat Homogen

• Untuk merepresentasikan transformasisebagai matrix diperlukan sistem koordinatyang mampu mewadahi rotasi, perbesarandan translasi sebagai matrix multiplikasi.

• X,y,z pada koord. Homogen = x/z, y/zpada koord. Kartesian

• (X0, y0) pada koord. Kartesian = (x0,y0,1)pada koord. Homogen = (z.x0, z.y0, z)dimana z # 0

Page 52: Komfik_Geometri

Koord. Homogen

Page 53: Komfik_Geometri

Translasi pada Koord. Homogen

Frank Klawonn, Intro to Computer Graphics

Page 54: Komfik_Geometri

Koordinat Homogen• Kartu grafis pada komputer bisa bekerja

cepat karena komposisi matrix utuktransformasi dapat dirangkai menjadi satu

• urutan transformasi penting!• secara default dari kanan ke kiri

contoh

Page 55: Komfik_Geometri

Aplikasi Transformasi (contoh)

Frank Klawonn, Intro to Computer Graphics

Page 56: Komfik_Geometri

3D coordinate system

• Pada koordinat 2D : semua datar• Untuk merepresentasikan kedalaman

diperlukan koordinat z• 3 sumbu koordinat!!• Semua titik pada ruang 3D dapat

dinyatakan sebagai x,y,z

Page 57: Komfik_Geometri

3D coordinate system

x

y

z

(5,0,0)

(5,5,0)

(5,5,5)

(0,0,0)

(0,0,5)

(0,5,5)

(5,0,5)

(0,5,5)

a

b

c

d

e

fg

h

i

j

k

l

Page 58: Komfik_Geometri

Koordinat Homogen

• Melibatkan tidak hanya koordinat x,y dan ztetapi juga nilai w (matrix 4 x 4)

• Titik 3D (x,y,z) direpresentasikan sebagai(x,y,z,1).

• Jika nilai w tidak 1 (x/w, y/w, z/w, 1)

Page 59: Komfik_Geometri

Terms and definitions

C

x

y

z A

B

A’

B’

screenz extent

x extent

y extent

view volume

centre of projection

Page 60: Komfik_Geometri

2D -> 3D• good news is that we can still use our drawing, shape, line

and point classes.

• bad news is that they are all going to require some (hopefullysmall) alterations to work in 3d.

Page 61: Komfik_Geometri

3D Points

1zyx•Still using homogenous

coordinates

•Need 4 coords )1,,,( zyx

Page 62: Komfik_Geometri

3D Transformations

– Since we now have an additional coordinateto cope with, our transformation matricesmust also expand to cope.

– each transformation matrix with require anextra row and an extra column to become4x4 matrices.

Page 63: Komfik_Geometri

Scaling

x

y

z

1

.

1000000000000

1zyx

SS

S

zyx

z

y

x

Page 64: Komfik_Geometri

Translation

x

y

z

1

.

1000100010001

1zyx

TTT

zyx

z

y

x

Page 65: Komfik_Geometri

Rotation (about axes)• In 2 dimensions, rotation were defined to take place about

some stationary point - the centre of rotation.

• In 3d, all rotation take place about one of the axes.

x

y

z

x

y

z

x

y

z

+ve

+ve

+ve

Page 66: Komfik_Geometri

Rotation (about axes)‏

x

y

z

=-90°

-90 about x axis

Page 67: Komfik_Geometri

Rotation

• x-axis

• y-axis

• z-axis

1

.

10000cossin0

0sincos00001

1z

yx

z

yx

1

.

10000cos0sin

00100sin0cos

1z

yx

z

yx

1

.

10000100

00cossin00sincos

1z

yx

z

yx

Page 68: Komfik_Geometri

Local Rotation

• translate the object tobe rotated to theorigin, perform therotation and translateit back to where itstarted from

x

y

z

=-90°

Page 69: Komfik_Geometri

Proyeksi

• Representasi object 3D di atas layar 2D• Asal muasalnya dan seringnya digunakan

oleh juru gambar dan arsitek dalammenggambar desain

• Several different projections existBergantung dari arah penglihatanpengamat

Page 70: Komfik_Geometri

Terms and definitions

C

x

y

z A

B

A’

B’

screenz extent

x extent

y extent

view volume

centre of projection

(also called plane)

Page 71: Komfik_Geometri

Macam Proyeksi

Page 72: Komfik_Geometri

…so?

• We need to calculate the screen coordinates(xsys) of each projected point from the 3dcoordinates– (they’re not the same!)‏

• Usually!

• Fortunately – we can consider this calculationas a transformation.

• Can use matrices to represent the variousways of doing it.

Page 73: Komfik_Geometri

Parallel Projection

1

.

10000000

00100001

10 z

yx

yx

s

s

Page 74: Komfik_Geometri

Perspective Projection

1

.

1/100000000100001

1

0 zyx

ddz

yx

s

s

Page 75: Komfik_Geometri

Perspective Projection

p (x,y,z)‏

z

x

screen

ps (xs,ys)‏C

d

By similar triangles:

dx

dzx s

dz

xxs

1

dz

yys

1

Page 76: Komfik_Geometri

Perspective Projection

10

1

1

.

dz

ydz

x

want So….Divide by

dz

1

Page 77: Komfik_Geometri

Perspective Projection

1

.

1/100000000100001

1

0 zyx

ddz

yx

s

s

Page 78: Komfik_Geometri

Oblique Parallel Projections• A parallel projection is one where all the lines that are

parallel in 3d space remain parallel when projected.

• An oblique parallel projection is one where the object inquestion is viewed “from the side” - unlike the (plain)parallel projection.

• The z axis is drawn at some angle () to the x axis

• A number of standard oblique parallelprojections are used in engineering drawing:

– cavalier

– cabinet

– orthogonal

Page 79: Komfik_Geometri

Cavalier Projection

The length of a line onthe screen is equal to itslength in the model.

This causes a distortionby over emphasising thez-axis

Page 80: Komfik_Geometri

Cabinet Projection

The foreshortening of the zaxis is increased to provide amore “realistic” view.

Page 81: Komfik_Geometri

Orthogonal Projection

The orthogonal projection isjust the simple parallelprojection

Page 82: Komfik_Geometri

Oblique Parallel Projections

x

y

(xs,ys)‏

‏(0,0,1)P

Consider the point P:

P can be represented in 3Dspace - ‏(0,0,1)

P can be represented in 2D(screen coords) - (xs,ys)‏

P can be represented in 2Dvia polar coordinates - (,)‏

Page 83: Komfik_Geometri

Oblique Parallel Projections

• At ‏(0,0,1)xs = cos ys = sin

• Generally– multiply by z and allow for (non-zero) x and y

xs= x + z..cos ys = y + z..sin

Page 84: Komfik_Geometri

Oblique Parallel Projection

x

y

z

(0,0,1)

Cavalier cabinetand orthogonalprojections can allbe specified interms of ()

-or () since

tan = 1/

Page 85: Komfik_Geometri

Oblique Parallel Projection

= 0 – 360Orthogonal projection= 90=0

= 0 – 360Cabinet projection= 63.4=0.5

= 0 - 360Cavalier projection= 45=1

Page 86: Komfik_Geometri

Oblique Parallel Projectionas a matrix

1

.

100000000sin100cos01

10 z

yx

yx

s

s

Page 87: Komfik_Geometri

Isometric Projection

1000060cos060sin0010060cos060sin

All 3 axes are equally foreshortened allowingmeasurements along the axes to made with the same scale.