Transformations & Windowing and Clipping
Basic Transformations
Transformations are operations that change the position, size, or orientation of objects.
Types of Basic Transformations:
1. Translation (Shifting)
- Moves object from one position to another
Example: Move a shape 5 units right, 3 units up
2. Scaling (Resizing)
- Changes size of object
👉 : enlarge, : shrink
3. Rotation (Turning)
- Rotates object around origin
👉 Angle measured anticlockwise
Matrix Representation & Homogeneous Coordinates
Why Matrix?
- Makes transformations easy and consistent
- Allows combining multiple transformations
Matrix Forms
Translation
Scaling
Rotation
Homogeneous Coordinates:
- Add extra coordinate (w = 1)
- Represent point as (x, y, 1)
Benefits
- Enables translation using matrix multiplication
- Simplifies combining transformations
Composite Transformations
Combining multiple transformations into a single transformation matrix.
Key Concept
Order matters!
👉 Example:
- Rotate → Translate ≠ Translate → Rotate
Process
- Multiply transformation matrices
- Apply final matrix to object
Advantages:
- Faster computation
- Efficient rendering
Reflection
Creates a mirror image of an object.
Types
1. Reflection about X-axis:
2. Reflection about Y-axis:
3. Reflection about Origin:
4. Reflection about line :
Shearing
Shearing distorts the shape of an object by shifting one coordinate.
Types:
1. X-Shear:
👉 Object shifts horizontally
2. Y-Shear:
👉 Object shifts vertically
Effect
- Rectangle → Parallelogram
Final Summary Table
| Transformation | Purpose | Key Effect |
|---|---|---|
| Translation | Move object | Position change |
| Scaling | Resize | Size change |
| Rotation | Turn object | Orientation change |
| Reflection | Mirror image | Flip |
| Shearing | Distort shape | Skew |
Concept Flow
Basic Transformations → Matrix Form → Homogeneous Coordinates → Composite Transformations → Advanced (Reflection & Shearing)
Viewing Pipeline
The viewing pipeline is the sequence of steps that converts objects from world coordinates to screen coordinates.
Stages:
-
Modeling Transformation
- Object → world coordinates
-
Viewing Transformation
- Select portion of scene (camera view)
-
Clipping
- Remove unwanted parts
-
Normalization
- Map to standard coordinate system
-
Viewport Transformation
- Map to screen/display
Purpose:
- Display only the visible portion
- Improve efficiency
Viewing Transformations
Transformations used to map world coordinates to viewing coordinates.
Key Concepts:
1. Window
- Area of world we want to see
2. Viewport
- Area on screen where it is displayed
Window → Viewport Mapping:
(Similarly for y)
Importance
- Controls zooming and panning
- Maintains aspect ratio
2D Clipping Algorithms
Clipping removes parts of objects that lie outside the viewing window.
Line Clipping Algorithms
A. Cohen-Sutherland Line Clipping
Idea
- Divide space into 9 regions
- Assign 4-bit region codes
Steps
- Assign region codes to endpoints
- If both inside → accept
- If both outside (same region) → reject
- Else → find intersection
Advantages
- Simple
- Efficient for trivial cases
Disadvantages
- More calculations for complex cases
B. Liang-Barsky Algorithm
Idea
- Uses parametric line equations
- Avoids repeated intersection calculations
Equation:
Advantages
- Faster than Cohen-Sutherland
- More efficient
Disadvantages:
- Slightly complex
C. Line Clipping Against Non-Rectangular Windows
- Clip lines against arbitrary shapes (polygon, circle)
Methods:
- Intersection with each boundary
- Use polygon clipping techniques
Polygon Clipping
A. Sutherland-Hodgman Polygon Clipping
Idea
- Clip polygon edge by edge against window
Steps:
- Take one boundary
- Process all edges
- Generate new polygon
- Repeat for all boundaries
Advantages:
- Simple
- Works well for convex polygons
Disadvantages
- Not suitable for concave polygons
B. Weiler-Atherton Polygon Clipping
- Handles complex and concave polygons
Key Concept
- Uses entry and exit points
- Traverses polygon and window alternately
Advantages
- Works for all polygon types
Disadvantages
- Complex implementation
Curve Clipping
Clipping curves (circle, ellipse, spline) against a window.
Methods
- Approximate curve with line segments
- Clip each segment
- Or use mathematical boundary checks
Challenge
- More complex than line clipping
Text Clipping
Clipping text based on its position relative to window.
Types
1. All-or-None String Clipping
- Entire text shown or removed
2. All-or-None Character Clipping
- Individual characters shown/hidden
3. Component Clipping
- Clip individual character shapes
Final Summary Table
| Topic | Key Idea | Best For |
|---|---|---|
| Cohen-Sutherland | Region codes | Simple cases |
| Liang-Barsky | Parametric | Efficient |
| Sutherland-Hodgman | Edge clipping | Convex polygons |
| Weiler-Atherton | Entry/exit | Complex polygons |
| Curve Clipping | Segment approximation | Curves |
| Text Clipping | Character/string level | Text rendering |
Concept Flow
Viewing Pipeline → Window & Viewport → Clipping → Line → Polygon → Curve → Text