Transformasi Obyek (Kasus 2D)

dokumen-dokumen yang mirip
Transformasi Obyek (Lanjutan)

Esther Wibowo

Pengertian. Transformasi geometric transformation. koordinat dari objek Transformasi dasar: Translasi Rotasi Penskalaan

BAB V TRANSFORMASI 2D

Tutorial 04 Modeling & Transformasi Proyeksi

Grafika Komputer. Evangs Mailoa

Transformasi Geometri Sederhana

Gambar 1. Viewport pada layar

BAB-7 TRANSFORMASI 2D

Gasal 2011/2012 KOMPUTER GRAFIK (3SKS)

Transformasi Datum dan Koordinat

TRANSFORMASI. Tujuan transfomasi adalah:

Gambar 1. Viewport pada layar

Transformasi Geometri Sederhana. Farah Zakiyah Rahmanti 2014

PETEMUAN KE-5 TRANSFORMASI-PANDANGAN (Viewing)

Pengenalan OpenGL. Sintax Perintah OpenGL. Library yang Berhubungan dengan OpenGL

LAMPIRAN SOURCE CODE

Tabel 1 Perintah-perintah OpenGL yang telah dipraktekan

PENGANTAR GRAFIKA KOMPUTER

Aljabar Linear. & Matriks. Evangs Mailoa. Pert. 7-8

OPENGL DALAM MICROSOFT VISUAL STUDIO EXPRESS Created by: Gideon

Line VS Bezier Curve. Kurva Bezier. Other Curves. Drawing the Curve (1) Pertemuan: 06. Dosen Pembina Danang Junaedi Sriyani Violina IF-UTAMA 2

Tutorial 09. Lighting

Jawab: Titik awal (x 1, y 1 ) = A(2,1) dan Titik akhir (x 2, y 2 ) = B(8,5) dx = x 2 x 1 = 8 2 = 6 dan dy = y 2 y 1 = 5 1 = 4

Bab 2 Output Primitif

Tabel 1 Perintah-perintah OpenGL yang telah dipraktekan

Grafika Komputer. Evangs Mailoa

PETEMUAN KE-3 PRIMITIVE DRAWING 2

apa yang terjadi?. Kemudian lakukan pengantian beberapa bagian seperti sintak

BAB II LINGKUNGAN PEMROGRAMAN GRAFIK DENGAN OPEN GL

Geometri, Koordinat Homogen, dan Transformasi Affine. Computer Graphics #03#04#05

Screw Theory and Reciprocity

Euclidean n & Vector Spaces. Matrices & Vector Spaces

TE Teknik Numerik Sistem Linear

Pengenalan OpenGL. Sintax Perintah OpenGL. Library yang Berhubungan dengan OpenGL

TE Teknik Numerik Sistem Linear. Bidang Studi Teknik Sistem Pengaturan Jurusan Teknik Elektro - FTI Institut Teknologi Sepuluh Nopember

SEBUAH TELAAH ELIPS DAN LINGKARAN MELALUI SEBUAH PENDEKATAN ALJABAR MATRIKS

BAB IV IMPLEMENTASI DAN PENGUJIAN

Computer Graphics PENGANTAR GRAFIKA 3D

Pengantar Grafika 3D E D I T A N

20. TRANSFORMASI. A. Translasi (Pergeseran) ; T = b. a y. a y. x atau. = b. = b

Mata Kuliah: Geometri Analitik (3 SKS)

Keseimbangan Torsi Coulomb

PRIMITIVE DRAWING. Achmad Basuki Nana Ramadijanti

Topik bahasan: 1. Membuat objek mudah dan kompleks dengan jaring poligon 2. Merender jaring poligon sebagai wireframe dan atau pejal dengan OpenGL

Dosen Pengampu : Puji Andayani, S.Si, M.Si, M.Sc

Tutorial 06. Texture Mapping & Blending

BAB IV IMPLEMENTASI DAN PENGUJIAN SISTEM

Simulasi Transformasi Linier pada Bidang 2D Dengan Menggunakan OpenGL API

BAB III ANALISIS DAN PERANCANGAN SISTEM PROGRAM SIMULASI PERAMBATAN GETARAN MENGGUNAKAN FRAKTAL 3D

Swakalibrasi Kamera Menggunakan Matriks Fundamental

PERANCANGAN DAN PEMBUATAN APLIKASI UNTUK MENDESAIN KARTU UCAPAN

Simetri. Operasi Simetri 13/03/2015. Pertemuan ke-5 Kristalografi (Simetri: Simbol & Operasinya) Nurun Nayiroh, M.Si

Melakukan Operasi Logika

Matriks Sebagai Representasi Orientasi Objek 3D

Materi Aljabar Linear Lanjut

MENGGAMBAR GRAFIK DENGAN MICROSOFT MATHEMATICS 4.0 1

LINEAR PROGRAMMING-1

DAFTAR PUSTAKA. (diakses 1 maret 2016)

PENENTUAN RUTE TERPENDEK DENGAN METODE FLOYD WARSHALL PADA PETA DIGITAL UNIVERSITAS SUMATERA UTARA SKRIPSI DHYMAS EKO PRASETYO

FAKULTAS TEKNIK UNIVERSITAS NEGERI YOGYAKARTA LAB. SHEET PRAKTIKUM GRAFIKA KOMPUTER

Program 1 /* Menampilkan Bayangan sebuah obyek sumber file */

ORIENTASI PADA PRA PLOTTING PETA BERSISTEM KOORDINAT LOKAL TERHADAP SISTEM KOORDINAT FIX (TETAP)

Vektor-Vektor. Ruang Berdimensi-2. Ruang Berdimensi-3

/*Bismillahirrohmanirrohim _Fatimah_Rombel 2_Projek_Akhir_Komgraf*/ #include <stdio.h> #include <stdlib.h> #include <string.

WATERMARKING CITRA DIGITAL YANG TAHAN TERHADAP GEOMETRIC ATTACKS

TUGAS AKHIR DESAIN DAN IMPLEMENTASI GRAPHIC USER INTERFACE UNTUK MESIN CNC DENGAN TAMPILAN 3-D MENGGUNAKAN WPF DAN VISUAL BASIC 2008

1. Pendahuluan Latar Belakang

FAKULTAS TEKNIK UNIVERSITAS NEGERI YOGYAKARTA LAB. SHEET PRAKTIKUM GRAFIKA KOMPUTER

Penerapan Transformasi Geometri pada Karya Seni Indonesia

GRAFIKA GAME. Aditya Wikan Mahastama. Rangkuman Transformasi Dua Dimensi UNIV KRISTEN DUTA WACANA TEKNIK INFORMATIKA GENAP 1213

DIAN PRATIWI. ST, MTI

Penerapan Transformasi Lanjar pada Proses Pengolahan Gambar

SATUAN ACARA PERKULIAHAN

UNIVERSITAS BINA NUSANTARA SIMULASI KINEMATIKA LENGAN ROBOT INDUSTRI DENGAN 6 DERAJAT KEBEBASAN

LAYOUT OBYEK MODUL 3 MENYUSUN, MENATA, MENGATUR, MENGUBAH OBYEK

ABSTRAK. PDF created with FinePrint pdffactory Pro trial version

Aplikasi Quartenion pada Game Engine

Chapter 5 GENERAL VECTOR SPACE 5.1. REAL VECTOR SPACES 5.2. SUB SPACES

TRANSFORMASI SUMBU KOORDINAT

Drawing, Viewport, dan Transformasi. Pertemuan - 02

TUGAS PENGANTAR GRAFIK KOMPUTER DAN OLAH CITRA

Grafika Komputer. Evangs Mailoa

19. TRANSFORMASI A. Translasi (Pergeseran) B. Refleksi (Pencerminan) C. Rotasi (Perputaran)

SATUAN PERKULIAHAN. 10 menit -apersepsi -motivasi Diberikan dalam bahasa Inggris 100% 2 Kegiatan inti:

Variable. Variable (cont) Variable (cont) Tipe Data

Gambar 1. Contoh tekstur makrostruktur

BAB 3 PERANCANGAN DAN PEMBUATAN. Engine akan dirancang agar memenuhi syarat maintainability, reusability dan

APLIKASI MENGUBAH POLARISASI FRAME GAMBAR 2 DIMENSI MENJADI 3 DIMENSI

Linear Discrimant Model

PEMODELAN OBYEK DENGAN METODE KURVA PARAMETRIK

ALJABAR LINEAR SUMANANG MUHTAR GOZALI KBK ANALISIS

Titik hasil transformasi dapat diperoleh melalui rumus affine transformation.

Pewarnaan dan Perputaran Polygon Untuk Objek Gambar Segi Tiga dan Segi Empat Menggunakan Program OPENGL 32

Nama Soal Pembagian Ring Road Batas Waktu 1 detik Nama Berkas Ringroad[1..10].out Batas Memori 32 MB Tipe [output only] Sumber Brian Marshal

04-Ruang Vektor dan Subruang

Muhammad Zidny Naf an, M.Kom. Gasal 2015/2016

BAHAN PRAKTIKUM GEOGEBRA

Perspective & Imaging Transformation

T DAR INTEGRAL TAK MUTLAK

Transkripsi:

Transformasi Obek (Kasus 2D) Grafika Komputer Semester Ganjil 28 Teknik Informatika ITS Ann Yuniarti - 28

Kompetensi. Mampu membangun tool untuk mentransformasi obek 2. Mampu memahami konsep transformasi affine ang merupakan kombinasi dari rotasi, penskalaan, dan translasi 3. Mampu mengimplementasikan konsep transformasi dalam sebuah program OpenGL Teknik Informatika ITS Ann Yuniarti - 28 2

Referensi Computer Graphics using OpenGL, 3rd Edition, b: F.S. Hill, Jr. and Stephen M. Kelle Chapter 5 Computer Graphics with OpenGL, 3rd Edition, b: Donald Hearn and M.Pauline Baker Chapter 5 http://www.cs.virginia.edu Teknik Informatika ITS Ann Yuniarti - 28 3

Pokok Bahasan. Transformasi 2D Dasar. Translasi 2. Rotasi 3. Penskalaan 2. Kombinasi Transformasi 3. Transformasi Affine Teknik Informatika ITS Ann Yuniarti - 28 4

Kegunaan Transformasi Me-reposisi ataupun me-resize obek Pada proses viewing, untuk mengubah worldcoordinate menjadi displa untuk suatu output device Untuk aplikasi-aplikasi tertentu: CAD mengatur orientasi dan ukuran suatu komponen pada suatu rancangan Animasi menggerakkan letak kamera atau obek pada sebuah laar sesuai path tertentu Teknik Informatika ITS Ann Yuniarti - 28 5

Jenis-jenis Transformasi Transformasi Geometri Diterapkan pada deskripsi geometri suatu obek Gunana untuk mengubah posisi, orientasi, atau ukuran suatu obek Transformasi modeling Digunakan untuk membentuk sebuah laar atau membuat deskripsi hierarki suatu obek kompleks ang terdiri dari beberapa bagian Contoh: pesawat terdiri dari saap, ekor, mesin, dan lain-lain, dimana masing-masing dapat dispesifikasikan dalam komponen-komponen level ke-2 dan seterusna. Transformasi modeling mendeskripsikan bagaimana setiap komponen disusun untuk rancangan keseluruhan Teknik Informatika ITS Ann Yuniarti - 28 6

2D Modeling Transformations Modeling Coordinates Scale Translate Scale Rotate Translate World Coordinates Teknik Informatika ITS Ann Yuniarti - 28 7

2D Modeling Transformations Modeling Coordinates Let s look at this in detail World Coordinates Teknik Informatika ITS Ann Yuniarti - 28 8

2D Modeling Transformations Modeling Coordinates Initial location at (, ) with - and -aes aligned Teknik Informatika ITS Ann Yuniarti - 28 9

2D Modeling Transformations Modeling Coordinates Scale.3,.3 Rotate -9 Translate 5, 3 Teknik Informatika ITS Ann Yuniarti - 28

2D Modeling Transformations Modeling Coordinates Scale.3,.3 Rotate -9 Translate 5, 3 Teknik Informatika ITS Ann Yuniarti - 28

2D Modeling Transformations Modeling Coordinates Scale.3,.3 Rotate -9 Translate 5, 3 World Coordinates Teknik Informatika ITS Ann Yuniarti - 28 2

Transformasi Geometri 2D Translasi 2D = + t, = + t (t, t ) disebut vektor translasi atau pergeseran Dalam bentuk matriks: ' P P' ' Persamaan translasi 2D: P = P + T Line, polgon translasi titik endpoints, render Untuk menghapus obek ang asli displa it in background color before translating it Circle, ellipse, spline curve translasi titik-titik ang mendefinisikan (misalna koordinat titik pusat), render obek hasil translasi di posisi ang baru T t t Teknik Informatika ITS Ann Yuniarti - 28 3

Transformasi Geometri 2D Scaling 2D = s, = s Dalam bentuk matriks: ' ' s s Uniform scaling berarti skalar pengali sama untuk semua komponen: 2 Teknik Informatika ITS Ann Yuniarti - 28 4

Transformasi Geometri 2D Non-uniform scaling: skalar ang berbeda untuk tiap komponen: X 2, Y.5 Teknik Informatika ITS Ann Yuniarti - 28 5

Transformasi Geometri 2D ' ' r (, ) r (, ) cos sin sin cos Rotasi 2D = r cos (Φ + ) = r sin (Φ + ) Trig Identit = r cos(f) cos( ) r sin(f) sin( ) = r sin(f) cos( ) + r cos(f) sin( ) Original point = r cos (f) = r sin (f) Hasil substitusi = cos( ) - sin( ) = sin( ) + cos( ) Teknik Informatika ITS Ann Yuniarti - 28 6

Transformasi Geometri 2D Shear 2D Shear pada arah relatif terhadap sumbu : = + sh, = Parameter sh dapat berupa bilangan real Dalam bentuk matriks: ' ' Shear pada arah relatif terhadap sumbu : =, = + sh Dalam bentuk matriks: ' ' sh sh Teknik Informatika ITS Ann Yuniarti - 28 7

Transformasi Geometri 2D Reflection 2D Pencerminan terhadap garis = (sumbu ): =, = - Dalam bentuk matriks: ' ' Pencerminan terhadap garis = (sumbu ): = -, = Dalam bentuk matriks: ' Pencerminan terhadap titik pusat (, ): = -, = - Dalam bentuk matriks: ' ' ' Teknik Informatika ITS Ann Yuniarti - 28 8

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) Transformations can be combined (with simple algebra) Teknik Informatika ITS Ann Yuniarti - 28 9

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) Teknik Informatika ITS Ann Yuniarti - 28 2

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) (, ) = *s = *s (,) Teknik Informatika ITS Ann Yuniarti - 28 2

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) (, ) = (*s )*cos θ) - (*s )*sin(θ) = (*s )*sin(θ) + (*s )*cos(θ) Teknik Informatika ITS Ann Yuniarti - 28 22

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) (, ) = ((*s )*cos(θ) - (*s )*sin(θ)) + t = ((*s )*sin(θ) + (*s )*cos(θ)) + t Teknik Informatika ITS Ann Yuniarti - 28 23

Basic 2D Transformations Translation: = + t = + t Scale: = * s = * s Rotation: = *cos(θ) - *sin(θ) = *sin(θ) + *cos(θ) = ((*s )*cos(θ) - (*s )*sin(θ)) + t = ((*s )*sin(θ) + (*s )*cos(θ)) + t Teknik Informatika ITS Ann Yuniarti - 28 24

Matri Representation Represent 2D transformation b a matri a c b d Multipl matri b column vector appl transformation to point ' ' a c b d ' ' a c b d Teknik Informatika ITS Ann Yuniarti - 28 25

Matri Representation Transformations combined b multiplication ' ' a c b d e g f h i k j l Matrices are a convenient and efficient wa to represent a sequence of transformations! Teknik Informatika ITS Ann Yuniarti - 28 26

Teknik Informatika ITS 27 Ann Yuniarti - 28 22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Identit? ' ' ' ' 2D Scale around (,)? s s * ' * ' s s ' '

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Rotate around (,)? ' ' cos sin * * sin cos * * ' ' cos sin sin cos 2D Shear? ' ' sh sh * * Teknik Informatika ITS Ann Yuniarti - 28 28 ' ' sh sh

Teknik Informatika ITS 29 Ann Yuniarti - 28 22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Mirror about Y ais? ' ' ' ' 2D Mirror over (,)? ' ' ' '

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Translation? ' t ' t NO! Onl linear 2D transformations can be represented with a 22 matri Teknik Informatika ITS Ann Yuniarti - 28 3

Linear Transformations Linear transformations are combinations of Scale, Rotation, Shear, and Mirror Properties of linear transformations: Satisfies: ' ' T( sp s2p2) st ( p) s2t ( p2) Origin maps to origin Lines map to lines Parallel lines remain parallel Ratios are preserved a c b d Teknik Informatika ITS Ann Yuniarti - 28 3

Homogeneous Coordinates Q: How can we represent translation as a 33 matri? ' ' t t Teknik Informatika ITS Ann Yuniarti - 28 32

Homogeneous Coordinates Homogeneous coordinates represent coordinates in 2 dimensions with a 3- vector homogeneous coords Homogeneous coordinates seem unintuitive, but the make graphics operations much easier Teknik Informatika ITS Ann Yuniarti - 28 33

Homogeneous Coordinates Q: How can we represent translation as a 33 matri? ' ' A: Using the rightmost column: t t Translation t t Teknik Informatika ITS Ann Yuniarti - 28 34

Translation Eample of translation Homogeneous Coordinates ' ' t t t t t = 2 t = Teknik Informatika ITS Ann Yuniarti - 28 35

Homogeneous Coordinates Add a 3rd coordinate to ever 2D point (,, w) represents a point at location (/w, /w) (,, ) represents a point at infinit (,, ) is not allowed Convenient coordinate sstem to represent man useful transformations 2 2 (2,,) or (4,2,2) or (6,3,3) Teknik Informatika ITS Ann Yuniarti - 28 36

Teknik Informatika ITS 37 Ann Yuniarti - 28 Basic 2D Transformations Basic 2D transformations as 33 matrices cos sin sin cos ' ' ' ' t t ' ' sh sh Translate Rotate Shear ' ' s s Scale

Affine Transformations Affine transformations are combinations of Linear transformations, and ' a b c Translations ' d e f w w Properties of affine transformations: Origin does not necessaril map to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Teknik Informatika ITS Ann Yuniarti - 28 38

Matri Composition Transformations can be combined b matri multiplication ' ' w' t t cos sin sin cos s s w p = T(t,t ) R( ) S(s,s ) p Teknik Informatika ITS Ann Yuniarti - 28 39

Matri Composition Matrices are a convenient and efficient wa to represent a sequence of transformations General purpose representation Hardware matri multipl p = (T * (R * (S*p) ) ) p = (T*R*S) * p Teknik Informatika ITS Ann Yuniarti - 28 4

Matri Composition Be aware: order of transformations matters Matri multiplication is not commutative p = T * R * S * p Global Local Teknik Informatika ITS Ann Yuniarti - 28 4

Matri Composition What if we want to rotate and translate? E: Rotate line segment b 45 degrees about endpoint a and lengthen a a Teknik Informatika ITS Ann Yuniarti - 28 42

Multiplication Order Wrong Wa Our line is defined b two endpoints Appling a rotation of 45 degrees, R(45), affects both points We could tr to translate both endpoints to return endpoint a to its original position, but b how much? a a Wrong R(45) a Correct T(-3) R(45) T(3) Teknik Informatika ITS Ann Yuniarti - 28 43

Multiplication Order - Correct Isolate endpoint a from rotation effects a First translate line so a is at origin: T (-3) a Then rotate line 45 degrees: R(45) a Then translate back so a is where it was: T(3) a Teknik Informatika ITS Ann Yuniarti - 28 44

Matri Composition Will this sequence of operations work? 3 cos(45) sin(45) sin(45) cos(45) 3 a a a' a' Teknik Informatika ITS Ann Yuniarti - 28 45

Matri Composition After correctl ordering the matrices Multipl matrices together What results is one matri store it (on stack)! Multipl this matri b the vector of each verte All vertices easil transformed with one matri multipl Teknik Informatika ITS Ann Yuniarti - 28 46

Reverse Rotations Q: How do ou undo a rotation of R( )? A: Appl the inverse of the rotation R - ( ) = R(- ) How to construct R-( ) = R(- ) Inside the rotation matri: cos( ) = cos(- ) The cosine elements of the inverse rotation matri are unchanged The sign of the sine elements will flip Therefore R - ( ) = R(- ) = R T ( ) Teknik Informatika ITS Ann Yuniarti - 28 47

Teknik Informatika ITS Ann Yuniarti - 28 48

#include <windows.h> #include <GL/glut.h> #include <stdlib.h> #include <math.h> GLsizei winwidth=6, winheight=6; //set initial displa window size GLfloat wcmin=.,wcma=225.; //set range for world coordinates GLfloat wcmin=.,wcma=225.; class wcpt2d { public: GLfloat,; }; tpedef GLfloat Matri33 [3][3]; Matri33 matcomposite; const GLdouble pi=3.459; void init(void) { glclearcolor(.,.,.,.); //set color of displa window to white } /* Construct the 3 b 3 identit matri */ void matri33setidentit (Matri33 matident33){ GLint row, col; for(row=;row<3;row++) for(col=;col<3;col++) matident33[row][col]=(row==col); } /* Premultipl matri m times matri m2, store result in m2. */ void matri33premultipl (Matri33 m, Matri33 m2) { GLint row, col; Matri33 mattemp; for(row=;row<3;row++) for(col=;col<3;col++) mattemp[row][col]=m[row][]*m2[][col]+m[row][]*m2[][col]+m[row][2]*m2[2][col]; for(row=;row<3;row++) for(col=;col<3;col++) m2[row][col]=mattemp[row][col];

void translate2d(glfloat t, GLfloat t){ Matri33 mattrans; matri33setidentit(mattrans); //initialize translation matri to identit mattrans[][2]=t; mattrans[][2]=t; matri33premultipl(mattrans,matcomposite);//concatenate mattrans with composite matri } void rotate2d(wcpt2d pivotpt, GLfloat theta){ Matri33 matrot; matri33setidentit(matrot); //initialize rotation matri to identit matrot[][]=cos(theta); matrot[][]=-sin(theta); matrot[][2]=pivotpt. * (-cos(theta))+pivotpt. * sin(theta); matrot[][]=sin(theta); matrot[][]=cos(theta); matrot[][2]=pivotpt. * (-cos(theta))-pivotpt. * sin(theta); matri33premultipl(matrot,matcomposite);//concatenate matrot with the composite matri } void scale2d(glfloat s, GLfloat s, wcpt2d fiedpt){ Matri33 matscale; matri33setidentit(matscale); //initialize scaling matri to identit matscale[][]=s; matscale[][2]=(-s)*fiedpt.; matscale[][]=s; matscale[][2]=(-s)*fiedpt.; matri33premultipl(matscale,matcomposite);//concatenate matscale with the composite matri } /* using the composite matri, calculate transformed coordinates. */ void transformverts2d(glint nverts, wcpt2d * verts){ GLint k; GLfloat temp; for(k=;k<nverts;k++){ temp=matcomposite[][]*verts[k].+matcomposite[][]*verts[k].+matcomposite[][2]; verts[k].=matcomposite[][]*verts[k].+matcomposite[][]*verts[k].+matcomposite[][ 2]; verts[k].=temp; } }

void triangle(wcpt2d *verts) { GLint k; glbegin(gl_triangles); for(k=;k<3;k++) glverte2f(verts[k].,verts[k].); glend(); } void displafcn(void){ GLint nverts=3; //define initial position for triangle wcpt2d verts[3]={{5.,25.},{5.,25.},{.,.}}; wcpt2d centroidpt; //calculate position of triangle centroid GLint k, Sum=, Sum=; for(k=;k<nverts;k++) { Sum+=verts[k].; Sum+=verts[k].; } centroidpt.=glfloat(sum)/glfloat(nverts); centroidpt.=glfloat(sum)/glfloat(nverts); wcpt2d pivpt,fiedpt; // set geometric transformation parameters pivpt=centroidpt; fiedpt=centroidpt; GLfloat t=., t=.; GLfloat s=.5, s=.5; GLdouble theta=pi/2.; glclear(gl_color_buffer_bit); //clear displa window glcolor3f(.,.,.); //set initial fill color to blue triangle(verts); //displa blue triangle matri33setidentit(matcomposite);//initialize composite matri to identit /* construct composite matri for transformation sequence */ scale2d(s,s,fiedpt); // first transformation: Scale. rotate2d(pivpt,theta); // second transformation: Rotate. translate2d(t,t); // final transformation: Translate. transformverts2d(nverts,verts);//appl composite matri to triangle vertices glcolor3f(.,.,.); //set color for transformed triangle triangle(verts); //displa red transformed triangle glflush(); }

void winreshapefcn(glint newwidth, GLint newheight){ glmatrimode(gl_projection); glloadidentit(); gluortho2d(wcmin,wcma,wcmin,wcma); glclear(gl_color_buffer_bit); } void main(int argc, char ** argv){ glutinit(&argc,argv); glutinitdisplamode(glut_single GLUT_RGB); glutinitwindowposition(5,5); glutinitwindowsize(winwidth,winheight); glutcreatewindow("geometric Transformation Sequence"); init(); glutdisplafunc(displafcn); glutreshapefunc(winreshapefcn); glutmainloop(); }

Some Interesting Images Teknik Informatika ITS Ann Yuniarti - 28 53

Some Interesting Images Teknik Informatika ITS Ann Yuniarti - 28 54

Tugas Kelas C Tulis sebuah program animasi ang mengimplementasikan prosedur rotasi 2D. Inputna sebuah polgon ang dirotasi terhadap sebuah pivot point menggunakan sudut ang kecil. Untuk meningkatkan kecepatan gunakan aproksimasi dari fungsi sin dan cos, dan untuk menghindari akumulasi error ang berlebihan reset nilai koordinat awal pada setiap putaran baru. Teknik Informatika ITS Ann Yuniarti - 28 55

Tugas Kelas X Modifikasi contoh program sebelumna supaa: Parameter transformasi dapat dispesifikasikan sebagai input dari user Dapat diaplikasikan pada semua polgon dengan verteks-verteksna dispesikasikan oleh input dari user Urutan transformasi geometrik ditentukan oleh input dari user Teknik Informatika ITS Ann Yuniarti - 28 56

Tugas Kelas A Implementasi program untuk membuat gambar: Untuk membuatna, buat sebuah fungsi ang menggambar polgon gambar (b) (seperlima dari bintang). Lalu transformasikan dengan rotasi untuk menggambar bintang secara keseluruhan. Teknik Informatika ITS Ann Yuniarti - 28 57

Tugas Kelas B Implementasi program untuk membuat gambar: Untuk membuatna, buat sebuah fungsi ang menggambar sebuah motif (gambar kiri). Lalu transformasikan dengan refleksi untuk mendapatkan sebuah spoke ang utuh, lalu rotasi untuk menggambar snowflake secara keseluruhan. Teknik Informatika ITS Ann Yuniarti - 28 58