You are on page 1of 87

Komputer Grafik

Kuliah 1: Prinsip Dasar Komputer Grafik


Dr. Trias Aditya
Rute
Computer Graphic Pipeline
Proses Operasi Komputer Grafik
Teknik Geodesi & Geomatika & Komputer Grafik
Contoh Aplikasi
Geometri 2D & Geometri 3D
Sistem Koordinat
Transformasi Koordinat
Proyeksi
Computer Graphics Pipeline
Definisi 101
Komputer Grafik: mencakup tampilan,
manipulasi dan penyimpanan gambar dan
data eksperimental untuk penyajian
menarik memanfaatkan komputer
Komputer grafik terdiri dari komputer,
memori dan: monitor berwarna, piranti
keras penunjang pemgolahan data dan
tampilan serta piranti lunak data grafis
Definisi 101
Komputer Grafik: mencakup tampilan,
manipulasi dan penyimpanan gambar dan
data eksperimental untuk penyajian
menarik memanfaatkan komputer
Komputer grafik terdiri dari komputer,
memori dan: monitor berwarna, piranti
keras penunjang pemgolahan data dan
tampilan serta piranti lunak data grafis
Proses memproduksi gambar atau citra
menggunakan komputer
proses menulis program untuk
menghasilkan/mengolah grafik
gambar yang dihasilkan tertayang di
layar komputer sebagai element grafik
disebut pixel
Object
Specification
Scene
Description
Model
Transformation
Scene
Description
Clipping &
Hidden Surface
Removal
View
Transformation
View & Light
Specification
Shading
Image
Image
Display
Transformation
Output
MODELING
RENDERING
DISPLAY
McConnell 2006
Komputer Grafik untuk Teknik
Geodesi & Geomatika
Ragam Aplikasi
Komputer Grafik:
- 3D object modeliing
- animation
- visualization
3D surface model
Depth image Triangle mesh Texture image
Textured 3D
Wireframe model
intermap_harrier2.avi
gallery_30.mpeg
Supporting Disciplines
Computer science (algorithms, data
structures, software engineering, )
Mathematics (geometry, numerical, )
Physics (Optics, mechanics, )
Psychology (Colour, perception)
Art and design
Applications
Computer Aided Design (CAD)
Computer Aided Geometric Design
(CAGD)
Entertainment (animation, games, )
Geographic Information Systems (GIS)
Visualization (Scientific Vis., Inform. Vis.)
Medical Visualization

Interactive Computer Graphics
User
Application
Screen
input
image
A detailed
polygon
mesh
(thank
you, Weta
Digital)
Graphics pipeline
User
Screen
Model
Geometry, colour
Map
Display
Edit
Manipulation of geometry and
color
Monsters, Inc
Manipulation of geometry and
color
Manipulation of geometry and
color
Manipulation of geometry and
color
Manipulation of geometry and
color
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
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, ...
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, ...
Conversion
Vector graphics
Rasterization, Pattern recognition
Scan conversion
Raster graphics
Hardware
Vector graphics
Raster graphics
Colour lookup table
3D rendering hardware
I/O Devices
3D Scanner 2D Scanner
CCD
Charge couple device
Vector Graphics Hardware
V E C T O R
Display Controller
move 10 20
line 20 40
...
char O
char R
Display list
continuous & smooth
lines
no filled objects
random scan
refresh speed depends
on complexity of the
scene
Raster Graphics Hardware
Video Controller
jaggies (stair casing)
filled objects
(anti)aliasing
R A S T E R
refresh speed independent of
scene complexity
pixel
scan conversion
resolution
bit planes
0 0 0 0 0 0
0 7 7 7 6
0 7 7 7
0 0 0
0 0
0
Frame buffer
Colour Lookup Table
0 0 0 0 0 0
0 7 7 7 6
0 7 7 7
0 0 0
0 0
0
Frame buffer
0 0 0
102 255 53
255 255 204
255 102 153
102 0 51
R R G G B B
0
1
2
4
7
...
colour
index
CLUT:
pixel = code
True colour:
pixel = R,G,B
Geometri Komputer Grafik
2D geometric modelling
Coordinates
Transformations
Coordinates
Point: position on plane
p = (p
x
, p
y
)
x = (x, y)
x = (x
1
, x
2
)
x = x
1
e
1
+ x
2
e
2
, e
1
= (1, 0), e
2
= (0, 1)
Vector: direction and magnitude
v = (v
x
, v
y
), etc.
x
y
p
v
Vector arithmetic
Addition of two vectors:
v +w = (v
x
+ w
x
, v
y
+ w
y
)
Multiplication vector-scalar:
ov= (ov
x
, ov
y
)
x
y
w
v
v+w
x
y
v
2v
Coordinate systems
image
wheel
train
world
vanwijk@win.tue.nl
Why??
Pendefinisian Sistem Koordinat
penting karena.
Terdapat banyak sistem koordinat pada
proses/operasi komputer grafik: World
Coordinates, Model Coordinates, View
Coordinates
Perlu kerangka referensi untuk
memposisikan obyek dalam dunia nyata,
model maupun dalam tampilan.
Contoh
Penggambaran obyek 2D pada komputer:
x
y
x
y
Koordinat Peta
Koordinat Layar
Transformasi Geometri
Transformasi Geometri pada
Komputer Grafik
Transformasi geometri memegang peranan
penting di komputer grafik karena : obyek
dipindah, diperbesar untuk menghasilkan
efek/modifikasi
Graphics API (Application Programming
Interface) melakukan transformasi untuk
menempatkan/merepresentasikan obyek
sebagai tampilan
Perlu dilakukan transformasi 3D ke 2D (obyek
dengan geometri 3D ke layar 2D)
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
World Transformation
Translation
Rotation
Scaling
+x
+z
+y
World origin
World Coordinates
Local model coordinates
Local model coordinates
View Transformation
+x
+z
+y
World origin
World Coordinates
+y
+x
+z
Camera
position
Look vector
Perbesaran (scaling), Rotation (rotasi) dan
translasi (translation) merupakan jenis
transformasi yang penting pada komputer
grafik.
Skala
Rotasi
Pemotongan (Shear)
Translasi (Translation)
NOT LINEAR!!!
Perkalian matrix tidak dapat digunakan
Homogeneous Coordinates
Pada komputer grafik, transformasi yang
kompleks (menggunakan matrix)
diperlukan.
Dengan pendekatan Kartesian, translasi
dan rotasi, perbesaran tidak dapat
digabung menjadi satu proses
Xn
Yn
=
X
Y
T *
Koordinat Homogen
Untuk merepresentasikan transformasi
sebagai matrix diperlukan sistem koordinat
yang mampu mewadahi rotasi, perbesaran
dan translasi sebagai matrix multiplikasi.
X,y,z pada koord. Homogen = x/z, y/z
pada koord. Kartesian
(X0, y0) pada koord. Kartesian = (x0,y0,1)
pada koord. Homogen = (z.x0, z.y0, z)
dimana z # 0
Koord. Homogen
Translasi pada Koord. Homogen
Frank Klawonn, Intro to Computer Graphics
Koordinat Homogen
Kartu grafis pada komputer bisa bekerja
cepat karena komposisi matrix utuk
transformasi dapat dirangkai menjadi satu
urutan transformasi penting!
secara default dari kanan ke kiri
contoh
Aplikasi Transformasi (contoh)
Frank Klawonn, Intro to Computer Graphics
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
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
f
g
h
i
j
k
l
Koordinat Homogen
Melibatkan tidak hanya koordinat x,y dan z
tetapi 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)
Terms and definitions
C
x
y
z
A
B
A
B
screen
z extent
x extent
y extent
view volume
centre of projection
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 (hopefully
small) alterations to work in 3d.
3D Points
|
|
|
|
|
.
|

\
|
1
z
y
x
Still using homogenous
coordinates
Need 4 coords
) 1 , , , ( z y x
3D Transformations
Since we now have an additional coordinate
to cope with, our transformation matrices
must also expand to cope.
each transformation matrix with require an
extra row and an extra column to become
4x4 matrices.
Scaling
x
y
z
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
'
'
'
1
.
1 0 0 0
0 0 0
0 0 0
0 0 0
1
z
y
x
S
S
S
z
y
x
z
y
x
Translation
x
y
z
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
'
'
'
1
.
1 0 0 0
1 0 0
0 1 0
0 0 1
1
z
y
x
T
T
T
z
y
x
z
y
x
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
u +ve
u
+ve
u +ve
Rotation (about axes)
x
y
z
u
=-90
-90 about x axis
Rotation
x-axis
y-axis
z-axis
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|

=
|
|
|
|
|
.
|

\
|
'
'
'
1
.
1 0 0 0
0 cos sin 0
0 sin cos 0
0 0 0 1
1
z
y
x
z
y
x
u u
u u
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|

=
|
|
|
|
|
.
|

\
|
'
'
'
1
.
1 0 0 0
0 cos 0 sin
0 0 1 0
0 sin 0 cos
1
z
y
x
z
y
x
u u
u u
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|

=
|
|
|
|
|
.
|

\
|
'
'
'
1
.
1 0 0 0
0 1 0 0
0 0 cos sin
0 0 sin cos
1
z
y
x
z
y
x
u u
u u
Local Rotation
translate the object to
be rotated to the
origin, perform the
rotation and translate
it back to where it
started from
x
y
z
u =-90
Proyeksi
Representasi object 3D di atas layar 2D
Asal muasalnya dan seringnya digunakan
oleh juru gambar dan arsitek dalam
menggambar desain
Several different projections exist
Bergantung dari arah penglihatan
pengamat
Terms and definitions
C
x
y
z
A
B
A
B
screen
z extent
x extent
y extent
view volume
centre of projection
(also called plane)
Macam Proyeksi
so?
We need to calculate the screen coordinates
(x
s
y
s
) of each projected point from the 3d
coordinates
(theyre not the same!)
Usually!
Fortunately we can consider this calculation
as a transformation.
Can use matrices to represent the various
ways of doing it.
Parallel Projection
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
1
.
1 0 0 0
0 0 0 0
0 0 1 0
0 0 0 1
1
0 z
y
x
y
x
s
s
Perspective Projection
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
+
1
.
1 / 1 0 0
0 0 0 0
0 0 1 0
0 0 0 1
1
0
z
y
x
d
d
z
y
x
s
s
Perspective Projection
p (x,y,z)
z
x
screen
p
s
(x
s
,y
s
)
C
d
By similar triangles:
d
x
d z
x
s
=
+
d
z
x
x
s
+
=
1
d
z
y
y
s
+
=
1
Perspective Projection
|
|
|
|
|
|
|
|
|
.
|

\
|
+
+
=
1
0
1
1
.
d
z
y
d
z
x
want
So.
Divide by
d
z
+ 1
Perspective Projection
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
+
1
.
1 / 1 0 0
0 0 0 0
0 0 1 0
0 0 0 1
1
0
z
y
x
d
d
z
y
x
s
s
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 in
question is viewed from the side - unlike the (plain)
parallel projection.
The z axis is drawn at some angle (o) to the x axis
A number of standard oblique parallel
projections are used in engineering drawing:
cavalier
cabinet
orthogonal
Cavalier Projection
The length of a line on
the screen is equal to its
length in the model.
This causes a distortion
by over emphasising the
z-axis
o
Cabinet Projection
The foreshortening of the z
axis is increased to provide a
more realistic view.
Orthogonal Projection
The orthogonal projection is
just the simple parallel
projection
Oblique Parallel Projections
x
y

o
(x
s
,y
s
)
(0,0,1)
P
Consider the point P:
P can be represented in 3D
space - (0,0,1)
P can be represented in 2D
(screen coords) - (x
s
,y
s
)
P can be represented in 2D
via polar coordinates - (o,)
Oblique Parallel Projections
At (0,0,1)
x
s
= cos o
y
s
= sin o
Generally
multiply by z and allow for (non-zero) x and y
x
s
= x + z..cos o
y
s
= y + z..sin o
Oblique Parallel Projection
x
y

o z
(0,0,1)
|
Cavalier cabinet
and orthogonal
projections can all
be specified in
terms of (o,|)
-or (o,) since
tan | = 1/
Oblique Parallel Projection
o = 0 360 Orthogonal projection | = 90 =0
o = 0 360 Cabinet projection | = 63.4 =0.5
o = 0 - 360 Cavalier projection | = 45 =1
Oblique Parallel Projection
as a matrix
|
|
|
|
|
.
|

\
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
.
|

\
|
1
.
1 0 0 0
0 0 0 0
0 sin 1 0
0 cos 0 1
1
0 z
y
x
y
x
s
s
o
o
Isometric Projection
|
|
|
|
|
.
|

\
|


1 0 0 0
0 60 cos 0 60 sin
0 0 1 0
0 60 cos 0 60 sin
All 3 axes are equally foreshortened allowing
measurements along the axes to made with the same scale.

You might also like