00:00

Understanding Windowing and Clipping in Computer Graphics

This detailed text delves into the concepts of windowing and clipping in computer graphics, covering topics such as viewport mapping, transformations, and the Cohen-Sutherland clipping algorithm. It explains how to define windows in world coordinates, map them to viewports, and efficiently clip lines to fit within specified boundaries. The content also touches on the practical application of these techniques using examples and algorithms.

tamudo
Download Presentation

Understanding Windowing and Clipping in Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMPUTER GRAPHICS D10K-5C01 GK03: Windowing and Clipping Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran

  2. Model Konseptual Grafika Komputer Cahaya Nyata Mata Manusia Objek Nyata Sumber Cahaya Sintentis Kamera Sintetis Mata Manusia Model/Objek Sintetis Objek Nyata Alat Display Sistem Grafika Komputer Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  3. Viewing dalam 2D (dua dimensi) 250 45 Window dalam koordinat dunia. 250 x 250 Pixels. Viewport dalam Koordinat Alat Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  4. KONSEP WINDOWING •Window – Sebuah area pada koordinat dunia yang dipilih untuk ditampilkan pada alat display •Viewport – Sebuah area pada alat display yang merupakan hasil pemetaan dari window •Pemetaan/Mapping – Transformasi Viewing – Transformasi Windowing – Transformasi Normalisasi Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  5. Windowing •Sebuah pemandangan (scene) dalam koordinat dunia (world coordinate). World Coordinates Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  6. Windowing •Ketika pemandangan ditampilkan pada layar, maka yang kelihatan hanya yang ada di dalam window Window wymax wymin wxmax wxmin World Coordinates Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  7. Windowing •Hasil clipping Window wymax wymin wxmax wxmin World Coordinates Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  8. Transformasi Viewing Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  9. Transformasi Windows-Viewport Formula transformasi:     x x x x y y y y   min x min x  min y min y  v v w w v v w w     x x x  y y y  max  min  max x min S max  min    max y min S v v w w v v w w ( ) ( ) x x y y min min min min v v x x w w x v v w w y   x x y y y y   max min max min v v v v S S x y max min max min w w w w Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  10. Contoh •Diketahui – sebuah objek pada koordinat dunia sebagai berikut: (2,1), (1,4) dan (3,3) – Koordinat window minimum dan maksimum adalah (0,0) dan (10,10) •Tentukan koordinat objek pada viewport, jika diketahui koordinat viewport minimum dan maksimum adalah (3,3) dan (8,8) Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  11. CLIPPING •Masalah: yang bisa ditampilkan atau digambarkan adalah area atau bagian objek yang ada di dalam jendela persegi panjang (xmax, ymax) (xmax, ymax) (xmin, ymin) (xmin, ymin) Line clipping Polygon clipping Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  12. Clipping 2D Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  13. Cara Sederhana / Trivial Semua garis didalam kotak  terima. Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  14. Cara Sederhana Penolakan Semua garis diluar kotak pada sisi yang sama  tolak. Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  15. Situasi yang terjadi Situasi Solusi Contoh Kedua ujung di dalam window Don’t clip Salah satu ujung di dalam window, ujung lain di luar window Must clip Kedua ujung berada di luar window Don’t know! Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  16. Cohen-Sutherland Clipping Algorithm •An efficient line clipping algorithm •The key advantage of the algorithm is that it vastly reduces the number of line intersections that must be calculated Cohen is something of a mystery – can anybody find out who he was? Dr. Ivan E. Sutherland co- developed the Cohen- Sutherland c lipping algorithm. Sutherland is a graphics giant and includes amongst his achievements the invention of the head m o u n t e d d i s p l a y . Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  17. CLIPPING COHEN-SUTHERLAND •Membagi bidang menjadi 9 region, tiap region mengandung 4-bit code. •Setiap ujung titik (x, y) dari setiap segmen garis diberi kode yang menunjukkan posis garis tersebut Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  18. Cohen-Sutherland algorithm •Merupakan metode yang efisien untuk menerima atau menolak garis-garis yang tidak melalui sisi/tepi window. •Meng-Assign kode biner 4-bit untuk setiap verteks: – Bit pertama : atas (above top), y > ymax – Bit kedua : bawah (below bottom), y < ymin – Bit ketiga : kanan, x > xmax – Bit keempat : kiri, x < xmin •Nama lain 4-bit code : Outcode Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  19. CLIPPING GARIS CS D C I B A H G F E AD = DB + BA, DB is discarded. Only draw BA EI = EH + HI = EG + GH + HI = EF + FG + GH + HI. All but FG are discarded. Only draw FG Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  20. Cohen-Sutherland 2D outcodes 1001 1000 1010 0001 0000 0010 0101 0100 0110 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  21. Cohen-Sutherland algorithm 1001 1000 1010 0000 0001 0010 0100 0101 0110 Both endpoint codes 0000, trivial acceptance, else: Do logical AND of outcodes Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  22. Cohen-Sutherland algorithm 1001 1010 1000 1000 0001 0000 0010 0001 0000 0000 0100 0101 0110 Logical AND between codes for 2 endpoints, Reject line if non-zero – trivial rejection. Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  23. Algoritm Cohen-Sutherland Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  24. Geometry: Clipping Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  25. Jenis-jenis Clipping •Line, Area, Text •Istilah lain: Crop, Cropping, Cut Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  26. LATIHAN 1. Tentukan koordinat viewport dari titik (5,7) yang terdapat pada window, dengan spesifikasi windows=(4,5,9,11) dan viewport=(3,4,5,7). 2. Tentukan binary-region code (4-bit code menurut algoritma CS) untuk garis-garis yang ada pada gambar di bawah ini Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  27. Algoritma Cliping Lainnya • • • • Liang–Barsky Cyrus–Beck Nicholl–Lee–Nicholl Fast-clipping Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  28. Demo Program Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

  29. Tugas 03 •Modifikasi dan tingkatkan program Clipping dan Windowing sehingga bisa meng-clip POLIGON Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016 Computer Graphics Teknik Informatika-Semester Ganjil 2015-2016

More Related