A geometric transformation is an operation that changes the position,
orientation, size or shape of a graphical object.
Computer graphics systems use transformations to move, rotate, resize,
mirror and distort objects. Transformations are also used for animation,
viewing and conversion between coordinate systems.
Major Types
Translation
Rotation
Scaling
Reflection
Shearing
Composite transformation
Original Object
|
v
Transformation Matrix
|
v
Transformed Object
2. Two-Dimensional Transformations
A two-dimensional point is written as P(x,y). After transformation,
the new point becomes P′(x′,y′).
Matrix representation is preferred because it provides a systematic and
efficient method for transforming multiple points.
3. Translation
Translation moves an object from one position to another without changing its size,
shape or orientation.
x′ = x + Tx
y′ = y + Ty
Tx and Ty are translation distances along the x and y directions.
The bits generally represent Top, Bottom, Right and Left.
Cases
If both endpoint codes are 0000, accept the line.
If bitwise AND of both codes is non-zero, reject the line.
Otherwise, calculate an intersection and repeat.
Step 1: Compute region codes for both endpoints.
Step 2: If both codes are 0000, accept the line.
Step 3: If logical AND is not 0000, reject the line.
Step 4: Otherwise choose an endpoint outside the window.
Step 5: Find its intersection with a window boundary.
Step 6: Replace the endpoint and repeat.
Advantages
Simple and efficient for obvious acceptance or rejection.
Uses bit operations.
Suitable for rectangular clipping windows.
Disadvantages
May require repeated intersection calculations.
Less efficient for lines crossing many boundaries.
15. Liang-Barsky Line Clipping Algorithm
Liang-Barsky algorithm uses the parametric equation of a line and calculates the entering
and leaving parameter values.
x = x₁ + u(x₂ − x₁)
y = y₁ + u(y₂ − y₁)
0 ≤ u ≤ 1
Four inequalities are formed for the clipping boundaries. Parameter values are classified
as potentially entering or leaving.
Advantages
Requires fewer intersection calculations.
More efficient than Cohen-Sutherland for many cases.
Uses direct parameter range calculation.
Disadvantages
Mathematical derivation is more complex.
Less intuitive for beginners.
Cohen-Sutherland vs Liang-Barsky
Basis
Cohen-Sutherland
Liang-Barsky
Main concept
Region codes
Parametric line equation
Computation
May calculate several intersections
Calculates parameter limits
Ease
Easy to understand
More mathematical
Efficiency
Good
Generally better
16. Polygon Clipping
Polygon clipping removes the portions of a polygon that lie outside the clipping window.
Sutherland-Hodgman Polygon Clipping
The polygon is clipped successively against the left, right, bottom and top boundaries.
For each polygon edge, four cases are considered.
Start Point
End Point
Output
Inside
Inside
Output endpoint
Inside
Outside
Output intersection
Outside
Inside
Output intersection and endpoint
Outside
Outside
No output
Advantages
Simple for convex clipping windows.
Processes one boundary at a time.
Easy to implement.
Limitation
It may not directly handle complex concave clipping windows.
Complete Unit Summary
Transformations modify object position, size, orientation and shape.
Translation moves an object.
Rotation changes orientation.
Scaling changes size.
Reflection creates a mirror image.
Shearing slants the object.
Homogeneous coordinates provide a uniform matrix form.