Pertemuan 8 - Transformasi Geometri 2D
Transformasi Geometri 2D
Transformasi geometri adalah operasi untuk memodifikasi objek tanpa merusaknya, termasuk translasi (pergeseran) dan rotasi (perputaran).
Bentuk Objek
Translasi (Pergeseran)
Rotasi (Perputaran)
Matriks Transformasi
| 1 | 0 | tx |
| 0 | 1 | ty |
| 0 | 0 | 1 |
| cosθ | -sinθ | 0 |
| sinθ | cosθ | 0 |
| 0 | 0 | 1 |
Rumus Translasi: x' = x + tx, y' = y + ty
Rumus Rotasi (terhadap origin): x' = x·cosθ - y·sinθ, y' = x·sinθ + y·cosθ
Rumus Rotasi (terhadap titik pivot (xp, yp)): x' = xp + (x - xp)·cosθ - (y - yp)·sinθ, y' = yp + (x - xp)·sinθ + (y - yp)·cosθ
Contoh Transformasi
Contoh Translasi
Objek segitiga dengan titik A(10,10), B(30,10), C(10,30)
Translasi: tx = 10, ty = 20
A' = (10+10, 10+20) = (20,30)
B' = (30+10, 10+20) = (40,30)
C' = (10+10, 30+20) = (20,50)
Contoh Rotasi
Objek segitiga dengan titik A(10,10), B(30,10), C(10,30)
Rotasi: θ = 30°, pivot (10,10)
A' = (10,10) [tidak berubah]
B' = (10 + (30-10)·cos30 - (10-10)·sin30, 10 + (30-10)·sin30 + (10-10)·cos30)
B' = (10 + 20·0.866 - 0, 10 + 20·0.5 + 0) ≈ (27.32, 20)