Show Menu
Cheatography

Computer Graphics 2 Cheat Sheet (DRAFT) by

Unit 2 CG cheat sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

UNIT 2

PART A
homoge­neous coordi­nates - represent all transf­orm­ations as a uniform matrix multip­lic­ation; easy compos­ition
viewing pipeline - mapping world coordinate system to viewport (display device)
modeling coordi­nates are local to the object and world coordi­nates are the common reference system
normal­ization transf­orm­ation - maps the world coordinate window to a standard, device­-in­dep­endent coordinate system (simplify clipping and viewport mapping)
Suther­lan­d-H­odgman:
P1 inside, P2 inside → Output P2
P1 inside, P2 outside → Output Inters­ection
P1 outside, P2 inside → Output I, then P2
P1 outside, P2 outside → Output nothing
Line clipping algori­thms: Cohen-­Sut­her­land, Liang-­Barsky (or Nichol­l–L­ee–­Nicholl (NLN), Cyrus-Beck

fig. 1

Cohen Sutherland

Transf­orm­ations

 

Homoge­neous Coordi­nates

Extension of 2D Cartesian coordi­nates (x, y) to 3D (x, y, w).
Point repres­ented as a column vector [x, y, 1]^T.
Without homoge­neous coordi­nat­es,­ tr­ans­lat­ion is vector addition (T + v), while others are matrix multip­lic­ations (M * v).
1. Unified Repres­ent­ation: 3x3 matrix multip­lic­ation
2. Efficient Concat­ena­tion: multiple transf­orm­ations
3. Elegant Handling of Transl­ation: transl­ation requires addition
4. Ability to Represent Points at Infinity: advanced graphical concepts
5. Simplified Inverse Transform: inverse of the single composite matrix,
Trade-off with Cartesian system:
1. Conceptual Complexity - unders­tanding an extended coordinate system
2. Comput­ational Complexity - slight increase (3x3 instead of 2x2) per operation; though there is a comput­ational gain through matrix concat­enation (composite matrix)
⇒ composite matrix transf­orm­ations happen right to left

Polygon tables

Vertex + Polygon Tables
Single Integrated Polygon Table
Three-­Table Model
Vertex table (8 coords) + Polygon table (6 faces)
Each face stores full vertex coordi­nates (6 faces, 3 coordi­nates)
Vertex table + Edge table + Polygon table
24 floats + 24 ints
72 floats
24 floats + 48 ints
efficient, no duplic­ation
simple
full topology, adjacency queries
no explicit edge info
high memory
more memory + complex
Data Efficiency
best
worst
moderate
Integrated = simple but wasteful | Three-­table = powerful but heavy | Vertex­+Po­lygon = best balance

2D viewing pipeline process

1. World Window Definition
a rect­angular region in the World Coordinate System (clipping boundary)
2. Viewport Definition
a rect­angular region on the Device Coordinate System
3. Window­-to­-Vi­ewport Mapping Process
linear transf­orm­ation (mapping) from window to viewport
Steps
1. Translate window → origin
2. Scale to viewport size
3. Translate to viewport position
(Addit­ion­ally) Pscreen​=Mscreen​×Mviewport​×Mzoom​×Mpan​×Pworld​
Pan: Mpan_i=Translate by (-Txi, -Tyi)
Zoom: M_zoo­m_i = Scale by (Si, Si)
Flexib­ility: Separating pan & zoom matrices allows indepe­ndent control.
Effici­ency: GPU-fr­iendly single matrix multip­lic­ation
Combined Importance
1. Separation of Concerns (decouples scene design from display specs)
2. Flexib­ility & Reuse
3. Device Indepe­ndence
 

Suther­lan­d–H­odgman

Inside test
xmin​≤x≤xmax​, ymin​≤y≤ymax​
comput­ati­onally cheap
Inters­ection Checks for Lines
point where a polygon edge crosses a clip boundary.
Use line equations to calculate inters­ection coordi­nates
inters­ection becomes a new vertex; closed and correctly shaped
Iterative Vertex Generation
processes the polygon agains­t each clip boundary (left, right, bottom, top) succes­sively.
Modular and systematic - 4 simple clipping steps
Builds final result increm­entally 

Cohen–­Sut­herland

Assign Region Codes
For both end points P1 and P2
Perform Trivial Tests
Trivial Accept­ance: (code1­​∣c­ode­2​)­=0000
Trivial Rejection: (code1­​&­cod­e2​­)≠0000
Select Outside Point
Choose endpoint with non-zero region code
Find Inters­ection
Left/Right boundary (x = constant): y=y1​+m(x−x1) Top/Bottom boundary (y = constant): x=x1​+ (y−y1​)/m ​
Repeat
Continue until: Accepted (both codes = 0000), or Rejected (AND ≠ 0)