Course Knowledge Map
graph TD
Unit1[Unit 1: Fundamentals] -- Provides Hardware --> Unit2[Unit 2: Drawing Algorithms]
Unit2 -- Creates Shapes --> Unit3[Unit 3: Transformations]
Unit3 -- Manipulates --> Unit4[Unit 4: Clipping & Projections]
Unit4 -- Prepares View --> Unit5[Unit 5: VSD & Animation]
style Unit1 fill:#e1f5fe,stroke:#01579b,stroke-width:2px
style Unit2 fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style Unit3 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
style Unit4 fill:#fce4ec,stroke:#880e4f,stroke-width:2px
style Unit5 fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
How the 5 course units connect to form the Graphics Pipeline.
1. Introduction to Computer Graphics
Computer Graphics is a domain of computer science concerned with how computers generate, manipulate, and display visual information. Its fundamental purpose is to convert abstract data and mathematical descriptions into visual representations that humans can perceive and understand.
1.1 Definition of Computer Graphics
Computer Graphics deals with the creation, manipulation, and representation of visual images using computers. It focuses on transforming numerical or symbolic data into visual form, typically as pixels on a display device.
At a conceptual level, Computer Graphics acts as a translator between machines (which understand numbers) and humans (who understand images).
1.2 Importance of Computer Graphics
The importance of Computer Graphics arises from the human brain’s ability to process visual information faster and more intuitively than textual or numerical data.
- Intuitive Interaction: Graphical interfaces allow users to interact naturally with computers through visual elements.
- Enhanced Communication: Visuals simplify the explanation of complex ideas and improve clarity in presentations.
- Scientific Visualization: Large and complex datasets can be understood through graphs, models, and simulations.
- Realism in Media: Realistic movies and games rely on accurate visual rendering.
- Simulation and Training: Flight simulators and training tools use graphics to safely replicate real-world scenarios.
1.3 Applications of Computer Graphics
Computer Graphics finds application wherever visual interpretation improves understanding, realism, or interaction.
1.3.1 Entertainment
Used in animation films, 3D modeling, and special effects to create visually rich and believable content.
1.3.2 Education
Visual aids and simulation-based learning help learners grasp abstract and dynamic concepts effectively.
1.3.3 Medical Imaging
Graphics techniques convert medical scan data such as MRI and CT into interpretable images for diagnosis.
1.3.4 Scientific Visualization
Complex scientific data, such as climate models, is visualized to identify patterns and behaviors.
1.3.5 CAD/CAM
Computer-Aided Design and Manufacturing enable precise engineering design and architectural planning.
1.3.6 Virtual Reality and Gaming
Immersive environments are created by continuously rendering scenes based on user interaction.
2. Graphics Hardware
Graphics hardware consists of physical components that enable input, processing, and output of visual data.
2.1 Input Devices
Input devices allow users to provide data and commands to the graphics system.
- Mouse: Used for pointing, selecting, and drawing.
- Keyboard: Provides textual and command-based input.
- Light Pen: Enables direct interaction with the screen.
- Graphic Tablet: Allows precise drawing and design input.
- Scanner: Converts physical images into digital form.
2.2 Output Devices
Output devices display or produce the final visual result generated by the computer.
- CRT: Uses electron beams to display images.
- LCD / LED Monitors: Flat-panel displays using liquid crystals and light-emitting diodes.
- Plotters: Produce large-scale vector drawings.
- Printers: Generate hard copies of images.
2.3 Frame Buffer
The frame buffer is a dedicated memory area that stores the color information of each pixel on the screen.
Each pixel’s color is represented using a fixed number of bits.
For a screen resolution of $1024 \times 768$ with 24-bit color depth:
$$1024 \times 768 \times 24 \text{ bits} \approx 18 \text{ MB}$$
This memory is continuously read by the display hardware to refresh the screen.
2.4 Graphics Pipeline
The graphics pipeline is an ordered sequence of processing stages that convert 3D objects into a 2D image displayed on the screen.
2.4.1 Stages of the Graphics Pipeline
- Modeling: Creation of 3D objects using geometric descriptions.
- Transformation: Positions objects into a common coordinate system.
- Lighting: Calculates color and brightness based on light sources.
- Projection: Converts 3D coordinates into 2D screen coordinates.
- Clipping: Removes parts of objects outside the viewing area.
- Rasterization: Converts geometric primitives into pixels.
- Display: Final image is rendered on the output device.
TWEENING – DETAILED NOTES
1. Introduction
Tweening comes from the word in-betweening. It is a technique used in animation to create smooth movement by automatically generating frames between two important frames.
Instead of drawing every single frame manually, the animator defines only the important moments, and the computer fills the gap.
Tweening is widely used in 2D animation, 3D animation, motion graphics, user interface animations, and computer games.
What is "Tweening" short for, and what does it do?
A: Short for "In-betweening". It automatically generates intermediate frames between two keyframes to create smooth movement.
2. What Are Keyframes?
A keyframe is an important frame in animation where something significant happens.
It defines the starting state and the ending state of an object.
Think of keyframes as checkpoints.
Example:
- Keyframe 1: A ball is on the left side of the screen
- Keyframe 2: A ball is on the right side of the screen
The animator does not draw the ball moving step by step. Tweening creates those middle steps automatically.
3. What Is Tweening?
Tweening is the process of generating intermediate frames between two keyframes to create smooth transitions.
It interpolates (calculates values in between) different properties of an object such as:
- Position
- Size
- Rotation
- Color
- Transparency
- Shape
Main purpose: To reduce manual effort and make motion look smooth and natural.
4. How Tweening Works
Tweening works using simple mathematics. The computer calculates small changes between two values and applies them frame by frame.
Example:
Keyframe 1: Object at $x = 0$
Keyframe 2: Object at $x = 100$
If 10 frames are needed in between, the position changes evenly.
Each frame moves the object by:
$$\frac{100 - 0}{10} = 10$$
So the object moves 10 units per frame until it reaches the final position.
If Frame 1 is at x=0 and Frame 10 is at x=100, how much does the object move per frame?
A: $\frac{100-0}{10} = 10$ units per frame.
5. Morphing
Morphing is a special and more advanced type of tweening.
In morphing, one shape smoothly transforms into another shape by blending intermediate forms.
Example:
- A circle gradually turning into a square
- One face changing into another face
This requires matching points carefully to avoid distortion.
How does Morphing differ from standard Tweening?
A: Morphing transforms one shape into another (e.g., circle to square), whereas typical tweening moves/rotates/scales an object.
6. Advantages of Tweening
- Saves time: No need to draw every frame manually
- Smooth motion: Movement looks natural and continuous
- Precise control: Animators can control speed and direction
- Works in 2D and 3D: Used across animation types
- Reduces workload: Less repetitive work for animators
7. Disadvantages of Tweening
- Unnatural motion: Poor easing can make animation look robotic
- Shape distortion: Incorrect point mapping causes visual errors
- Complex actions: Advanced motion often needs manual correction
8. Real-Life Examples of Tweening
Mobile and UI Animations:
- Buttons expanding or shrinking
- Screen transitions
Cartoons and Animation:
- Character walking cycles
- Facial expressions changing
Games:
- Camera movement
- Character motion
Web Animations (CSS / JavaScript):
- Fade-in and fade-out effects
- Sliding menus
PANNING – DETAILED NOTES
1. Introduction
Panning is a camera movement technique used in computer graphics, animation, and cinematography. In panning, the camera moves or rotates horizontally across a scene.
The important idea is that the camera stays at the same place but changes the direction it is facing.
This creates the feeling that the viewer is “looking around” the scene.
Panning is widely used in:
- 2D and 3D animation
- User interfaces
- Video games
- Virtual tours
- Cinematic scenes
2. What is Panning?
Definition:
Panning is the horizontal movement of the camera view across a scene from a fixed position. The camera rotates left or right, which shifts what is visible on the screen without moving the camera forward or backward.
Key idea: The camera position does not change, only the viewing direction changes.
Simple Example:
Imagine you are standing at one place and you turn your head to the left or right. Your feet stay in the same position, but your view changes. This action is called panning.
In Panning, does the camera move position?
A: No. The camera stays fixed but rotates (changes direction) to scan the scene.
3. Purpose of Panning
Panning is used to control what the viewer sees and where their attention goes.
- Follow moving objects: Keeps a moving object (like a running character) in view
- Reveal the environment: Shows different parts of a scene gradually
- Connect subjects: Moves the viewer’s focus from one object to another
- Create cinematic effect: Adds drama and smooth visual flow
- Enhance storytelling: Helps explain context by showing surroundings
- Guide user attention: Directs focus in games and user interfaces
4. Panning in Computer Graphics
In computer graphics, panning is achieved by changing the camera’s viewing parameters instead of moving objects.
The scene remains the same, but the visible portion of the scene shifts horizontally.
This is computationally efficient because only the view changes, not the actual object positions.
5. Real-Life Examples of Panning
Animation and Movies:
- Camera moving across a landscape
- Following a character walking across the screen
Video Games:
- Side-scrolling games where the screen moves horizontally
- Camera tracking a player’s movement
User Interfaces:
- Horizontal scrolling screens
- Image galleries sliding left or right
Virtual Tours:
- Looking left or right inside a 360° environment
TRANSFORMATIONS – DETAILED NOTES
1. Introduction
In computer graphics, a transformation means changing an object’s position, size, orientation, or shape.
In simple words, transformations answer questions like:
- Where is the object?
- How big is the object?
- In which direction is it facing?
- How is its shape altered?
Transformations are applied in both 2D and 3D graphics to move, resize, rotate, or distort objects.
All transformations are performed mathematically using matrix multiplication.
2. Why Matrices Are Used
Computers are good at numbers, not shapes. Matrices provide a uniform and efficient way to represent all transformations.
By multiplying a point with a transformation matrix, the new transformed point is obtained.
3. Types of Transformations
3.1 Translation
Translation moves an object from one position to another without changing its size or orientation.
Think of sliding an object on the screen.
If a point $P(x, y)$ is translated by $T_x$ in the x-direction and $T_y$ in the y-direction:
$$x' = x + T_x$$
$$y' = y + T_y$$
Matrix form (2D):
$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} T_x \\ T_y \end{bmatrix} $$
Use: Moving objects on the screen.
3.2 Scaling
Scaling changes the size of an object.
Think of zooming in or zooming out.
If a point $P(x, y)$ is scaled by factors $S_x$ and $S_y$:
$$x' = x \cdot S_x$$
$$y' = y \cdot S_y$$
Matrix form:
$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} S_x & 0 \\ 0 & S_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} $$
Types of Scaling:
- Uniform scaling: $S_x = S_y$ (shape remains same)
- Non-uniform scaling: $S_x \neq S_y$ (shape may stretch)
3.3 Rotation
Rotation turns an object around a fixed point, usually the origin.
Think of rotating a book on a table.
If a point $P(x, y)$ is rotated by angle $\theta$:
$$x' = x\cos\theta - y\sin\theta$$
$$y' = x\sin\theta + y\cos\theta$$
Matrix form:
$$ \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} $$
Types of Rotation:
- Counterclockwise: Positive angle
- Clockwise: Negative angle
3.4 Reflection
Reflection creates a mirror image of an object.
Think of seeing yourself in a mirror.
Reflection about X-axis:
$$ \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} $$
Reflection about Y-axis:
$$ \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} $$
Reflection about Origin:
$$ \begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix} $$
3.5 Shearing
Shearing slants or skews the shape of an object.
Think of pushing the top of a rectangle sideways.
Shear in X-direction:
$$ \begin{bmatrix} 1 & Sh_x \\ 0 & 1 \end{bmatrix} $$
Shear in Y-direction:
$$ \begin{bmatrix} 1 & 0 \\ Sh_y & 1 \end{bmatrix} $$
4. Homogeneous Coordinates
Homogeneous coordinates are used to represent translation using matrix multiplication.
A 2D point $(x, y)$ is written as:
$$(x, y, 1)$$
This allows all transformations (translation, scaling, rotation) to be represented using a single matrix format.
5. Composite Transformation
Composite transformation means applying more than one transformation to an object.
Example: Rotate an object, then translate it.
$$ P' = T \cdot R \cdot P $$
Important Rule:
Matrix multiplication is not commutative.
$$A \cdot B \neq B \cdot A$$
This means the order of transformations matters and changes the final result.
Is the order of matrix multiplication important? Why?
A: Yes. Matrix multiplication is not commutative ($A \cdot B \neq B \cdot A$). Rotating then translating gives a different result than translating then rotating.
3D TRANSFORMATIONS, PROJECTION AND VISIBLE SURFACE DETECTION
1. 3D Transformations
3D transformations change the position, size, or orientation of objects in three-dimensional space. Unlike 2D, each point has three coordinates: $(x, y, z)$.
All 3D transformations are performed using 4×4 matrices with homogeneous coordinates.
What size matrix is used for 3D transformations with homogeneous coordinates?
A: A 4×4 Matrix.
1.1 Translation in 3D
Translation moves an object from one position to another in 3D space.
Think of shifting an object left–right, up–down, and forward–backward.
If a point $P(x, y, z)$ is translated by $(T_x, T_y, T_z)$:
$$x' = x + T_x$$
$$y' = y + T_y$$
$$z' = z + T_z$$
1.2 Scaling in 3D
Scaling changes the size of a 3D object.
Think of enlarging or shrinking a 3D model.
If a point $P(x, y, z)$ is scaled by $(S_x, S_y, S_z)$:
$$x' = x \cdot S_x$$
$$y' = y \cdot S_y$$
$$z' = z \cdot S_z$$
1.3 Rotation in 3D
Rotation in 3D is performed around one of the coordinate axes.
Rotation about X-axis:
The object rotates around the X-axis; X remains unchanged.
Rotation about Y-axis:
The object rotates around the Y-axis; Y remains unchanged.
Rotation about Z-axis:
The object rotates in the XY-plane.
Example: Rotation about Z-axis by angle $\theta$
$$ \begin{bmatrix} x' \\ y' \\ z' \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} $$
1.4 Reflection in 3D
Reflection creates a mirror image of a 3D object about a plane.
Reflection about XY-plane:
Only Z-coordinate changes sign.
$$(x, y, -z)$$
Reflection about YZ-plane:
Only X-coordinate changes sign.
$$( -x, y, z )$$
Reflection about ZX-plane:
Only Y-coordinate changes sign.
$$( x, -y, z )$$
1.5 Shearing in 3D
Shearing slants a 3D object along one or more axes.
3D shearing is more complex and is represented using 4×4 matrices.
It is used in advanced modeling and special visual effects.
2. Projection in Computer Graphics
Projection is the process of displaying a 3D object on a 2D screen.
It converts 3D coordinates $(x, y, z)$ into 2D coordinates $(x', y')$.
This step is essential because screens are two-dimensional.
2.1 Parallel Projection
In parallel projection, all projection lines are parallel to each other.
Features:
- No perspective effect
- Object size does not change with distance
- Used in engineering drawings and CAD
2.2 Perspective Projection
In perspective projection, all projection lines meet at a single point called the center of projection.
This matches how human eyes see the real world.
Features:
- Creates depth
- Distant objects appear smaller
- Produces realistic images
Basic Concept:
Objects farther from the viewer have smaller projected coordinates.
3. Visible Surface Detection
Visible Surface Detection determines which surfaces of 3D objects are visible from a given viewpoint and which are hidden.
The computer must draw only the visible surfaces to create a realistic image.
3.1 Why Visible Surface Detection is Needed
- To remove hidden lines and surfaces
- To generate realistic images
- To reduce unnecessary drawing
- To correctly handle overlapping objects
Key Idea: When two objects overlap, the one closer to the viewer hides the one behind it.
Z-BUFFER AND A-BUFFER ALGORITHMS & PROJECTION
1. Z-Buffer Algorithm (Depth Buffer)
The Z-Buffer algorithm is one of the most common methods used to determine which surfaces are visible in a 3D scene.
Core idea: For every pixel on the screen, store how far that pixel is from the viewer.
The letter Z represents depth. Smaller Z means the object is closer to the viewer.
2. What is a Z-Buffer?
A Z-buffer is a special memory area that stores the depth (z-value) of every pixel on the screen.
There are two buffers involved:
- Frame Buffer: Stores the color of pixels
- Z-Buffer: Stores the depth of pixels
Only the closest surface at each pixel is displayed.
3. How Z-Buffer Works
The Z-buffer algorithm works in a very systematic way.
Step 1: Initialization
- Z-buffer is initialized with a very large value $(+\infty)$
- Frame buffer is filled with background color
Step 2: Process Each Polygon
- For every polygon in the scene
- For every pixel covered by that polygon
Step 3: Depth Comparison
- Compute the pixel’s depth value $z$
- Compare it with stored Z-buffer value
Decision Rule:
- If $z_{\text{new}} < z_{\text{stored}}$ → pixel is visible
- If $z_{\text{new}} \ge z_{\text{stored}}$ → pixel is hidden
Update Rule:
- Update Z-buffer with new z-value
- Update frame buffer with pixel color
4. Why Z-Buffer Works
At each pixel location, only the closest object matters.
The Z-buffer ensures that farther objects never overwrite nearer ones.
This matches how visibility works in the real world.
5. Advantages of Z-Buffer
- Simple: Easy to understand and implement
- Fast: Suitable for real-time rendering
- General: Works with any scene complexity
- Hardware support: Used in OpenGL and DirectX
- Ideal for games: Real-time performance
6. Disadvantages of Z-Buffer
- Extra memory: Requires a depth value per pixel
- Transparency issues: Cannot handle transparent surfaces properly
- Aliasing: Jagged edges may appear
7. A-Buffer Algorithm (Anti-Aliased Buffer)
The A-buffer is an advanced version of the Z-buffer.
Key idea: Instead of storing only one surface per pixel, store all surfaces that pass through that pixel.
It is also called the Accumulation Buffer.
8. How A-Buffer Works
Each pixel stores a list of fragments instead of a single value.
Each fragment stores:
- Depth $(z)$
- Color
- Opacity $(\alpha)$
- Surface ID
- Coverage value (how much of the pixel is covered)
After all fragments are collected, the final pixel color is computed using alpha blending.
9. Why A-Buffer is Better than Z-Buffer
The A-buffer does not discard hidden surfaces immediately.
Instead, it combines them correctly based on transparency and coverage.
This results in smoother edges and realistic transparency.
10. Advantages of A-Buffer
- Supports transparency
- Better anti-aliasing
- Handles multiple surfaces per pixel
- More realistic images
11. Disadvantages of A-Buffer
- High memory usage
- Slower than Z-buffer
- Complex implementation
12. Projection in Computer Graphics
Projection is the process of converting a 3D object into a 2D image.
This is required because computer screens are two-dimensional.
Projection converts coordinates:
$$(x, y, z) \rightarrow (x', y')$$
13. Why Projection is Needed
- To display 3D scenes on 2D screens
- To create realistic depth perception
- To produce technical drawings and CAD views
Projection defines how 3D space is viewed and interpreted on the screen.
TYPES OF PROJECTION
1. Introduction
Projection is the method used to display a three-dimensional object on a two-dimensional screen.
Since screens are flat, projection decides how depth is represented and how objects appear to the viewer.
Based on how projection lines behave, projection is divided into two major categories.
2. Classification of Projection
Projection is broadly classified into:
- Parallel Projection
- Perspective Projection
3. Parallel Projection
In parallel projection, all projection lines are parallel to each other.
These lines hit the view plane in the same direction.
Key idea: Distance from the viewer does not affect the size of the object.
Easy way to imagine:
Think of sunlight falling on objects. The rays are parallel, so shadows do not shrink or expand with distance.
Main Features:
- No perspective or depth effect
- Object size remains constant regardless of distance
- Used in engineering and CAD drawings
- Shapes and dimensions are preserved accurately
Use Case:
When accurate measurements matter more than realism.
4. Perspective Projection
In perspective projection, all projection lines meet at a single point.
This point is called the Center of Projection (COP).
This method closely matches how the human eye sees the real world.
Easy way to imagine:
Stand on a straight road. The road appears to narrow and meet at a distant point. That point is a vanishing point.
Main Features:
- Produces realistic images
- Objects farther away appear smaller
- Creates depth perception
- Uses vanishing points
Use Case:
Used in games, movies, simulations, and virtual reality where realism is important.
ANIMATION – DETAILED NOTES
1. Introduction to Animation
Animation is the technique of creating the illusion of motion by displaying a sequence of images, called frames, one after another at high speed.
The human eye cannot distinguish individual frames when they change rapidly, so the brain perceives continuous motion.
In computer graphics, animation is created by changing an object’s properties over time, such as:
- Position
- Size
- Color
- Orientation
Key idea: Motion = change over time.
2. Frame-by-Frame Animation
Definition:
In frame-by-frame animation, every single frame is drawn or designed manually.
When these frames are played continuously, smooth motion is created.
Easy way to understand:
Like drawing slightly different pictures on each page of a notebook and flipping it quickly.
Examples:
- Traditional 2D cartoons
- Flipbooks
- Hand-drawn animation
Pros:
- Full creative control
- Very expressive and smooth motion
Cons:
- Extremely time-consuming
- Requires high artistic skill
3. Keyframe Animation
Definition:
In keyframe animation, the animator defines only the important frames (keyframes).
The computer automatically generates the in-between frames.
Easy way to understand:
You decide where an object starts and ends. The computer fills the steps in between.
Examples:
- Character animation in Blender
- Motion graphics in After Effects
Pros:
- Much faster than frame-by-frame animation
- Easy to change timing and motion
Cons:
- In-between motion may look artificial
- Requires understanding of timing and easing
4. Procedural Animation
Definition:
Procedural animation generates motion automatically using mathematics, algorithms, or physics rules.
The animator defines rules, not individual movements.
Easy way to understand:
You tell the computer “how things behave,” and it creates the motion.
Examples:
- Fire and smoke
- Water waves
- Automatic walking cycles
Pros:
- Saves a lot of manual effort
- Produces natural-looking motion
Cons:
- Difficult to control exact appearance
- Requires programming or physics knowledge
5. Behavioral Animation
Definition:
Behavioral animation uses rule-based or AI-like logic.
Objects or characters react automatically to their environment and other objects.
Easy way to understand:
Characters make decisions instead of following fixed paths.
Examples:
- Flocking birds
- Fish swimming in groups
- Crowd simulations
Pros:
- Very realistic group movement
- Reduces manual animation work
Cons:
- Complex setup
- Behavior can be unpredictable
6. Motion Capture (MoCap)
Definition:
Motion capture records real human movement using cameras or sensors.
The captured motion is applied to digital characters.
Easy way to understand:
A real person moves, and the computer copies that movement to a character.
Examples:
- Movies like Avatar
- Games like FIFA and GTA
Pros:
- Extremely realistic motion
- Saves effort for complex animations
Cons:
- Expensive equipment
- Captured data needs cleanup
7. Dynamics Animation
Definition:
Dynamics animation is based on physical laws such as gravity, wind, collisions, and friction.
Motion is calculated using physics simulations.
Easy way to understand:
The computer follows real-world physics to move objects.
Examples:
- Cloth simulation
- Hair movement
- Water splashes
- Breaking objects
Pros:
- Highly realistic physical motion
- Best for natural effects
Cons:
- Heavy computation
- Difficult to control exact artistic outcome
DDA, BRESENHAM & TRANSFORMATION — SOLVED PRACTICE NUMERICALS
1. DDA LINE DRAWING — SOLUTIONS
Q1. Line from (3,2) to (11,7) using DDA
Step 1: Identify start and end points
Start: $(x_1,y_1)=(3,2)$
End: $(x_2,y_2)=(11,7)$
Step 2: Compute differences
$\Delta x = 11 - 3 = 8$
$\Delta y = 7 - 2 = 5$
Step 3: Number of steps
Steps = max$(|\Delta x|, |\Delta y|) = 8$
Step 4: Increment values
$x_{inc} = \frac{8}{8} = 1$
$y_{inc} = \frac{5}{8} = 0.625$
Step 5: Generate points
- (3, 2)
- (4, 2.63)
- (5, 3.25)
- (6, 3.88)
- (7, 4.50)
- (8, 5.13)
- (9, 5.75)
- (10, 6.38)
- (11, 7)
Q2. Line from (1,1) to (4,9) using DDA
Step 1: Differences
$\Delta x = 3$, $\Delta y = 8$
Step 2: Steps
Steps = 8
Step 3: Increments
$x_{inc} = \frac{3}{8} = 0.375$
$y_{inc} = \frac{8}{8} = 1$
Step 4: Points
- (1,1)
- (1.38,2)
- (1.75,3)
- (2.13,4)
- (2.50,5)
- (2.88,6)
- (3.25,7)
- (3.63,8)
- (4,9)
2. BRESENHAM LINE DRAWING — SOLUTION
Q3. Line from (2,3) to (12,8)
Step 1: Differences
$\Delta x = 10$, $\Delta y = 5$
Step 2: Initial decision parameter
$p_0 = 2\Delta y - \Delta x = 2(5) - 10 = 0$
Step 3: Plot points
- (2,3)
- (3,4)
- (4,4)
- (5,5)
- (6,5)
- (7,6)
- (8,6)
- (9,7)
- (10,7)
- (11,8)
- (12,8)
3. BRESENHAM CIRCLE DRAWING — SOLUTIONS
Q4. First 8 symmetric points for r = 6
Initial values: $(x,y) = (0,6)$
Symmetric points:
- (0,6)
- (6,0)
- (0,-6)
- (-6,0)
- (4,4)
- (-4,4)
- (4,-4)
- (-4,-4)
Q5. Circle with r = 10 — first 5 points
- (0,10)
- (1,10)
- (2,10)
- (3,9)
- (4,9)
4. TRANSFORMATION NUMERICALS — SOLUTIONS
Q6. Translation of Triangle by $T_x=2$, $T_y=5$
Formula: $(x',y') = (x+T_x, y+T_y)$
- A(1,2) → A′(3,7)
- B(4,3) → B′(6,8)
- C(6,1) → C′(8,6)
Q7. Scaling Rectangle by $S_x=2$, $S_y=3$
Formula: $(x',y') = (xS_x, yS_y)$
- P(2,2) → (4,6)
- Q(4,2) → (8,6)
- R(4,5) → (8,15)
- S(2,5) → (4,15)
Q8. Rotate point (5,2) by 90° about origin
Formula:
$x' = -y$, $y' = x$
Result: $(-2,5)$
Q9. Rotate triangle by 45°
Rotation formulas:
$x' = x\cos45° - y\sin45°$
$y' = x\sin45° + y\cos45°$
Using $\cos45°=\sin45°=\frac{1}{\sqrt2}$
- A(1,1) → (0,1.41)
- B(2,3) → (-0.71,3.54)
- C(3,1) → (1.41,2.83)
Q10. Reflect point (4,5) in Y-axis
Rule: $(x,y) → (-x,y)$
Result: $(-4,5)$
COHEN–SUTHERLAND LINE CLIPPING — SOLVED NUMERICAL
Problem Statement
Line Endpoints:
$P_1 = (2, 8)$, $P_2 = (18, 20)$
Clipping Window:
$x_{min}=5,\; y_{min}=10,\; x_{max}=15,\; y_{max}=25$
(a) Finding Region Codes
Cohen–Sutherland assigns a 4-bit code to each point:
- Left = 0001 (1)
- Right = 0010 (2)
- Bottom = 0100 (4)
- Top = 1000 (8)
For $P_1(2,8)$:
- $x < 5$ → Left=1
- $y < 10$ → Bottom=4
Region code = $0101_2 = 5$
For $P_2(18,20)$:
- $x > 15$ → Right = 2
- $y$ is within bounds
Region code = $0010_2 = 2$
Slope Calculation
The slope of the line is:
$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{20 - 8}{18 - 2} = \frac{12}{16} = \frac{3}{4} $$
(b) Step-by-Step Clipping
Step 1: $P_1$ has code 5 (Left + Bottom).
We clip against the Left boundary first: $x = 5$.
Intersection formula:
$$ y = y_1 + m(x_{clip} - x_1) $$
$$ y = 8 + \frac{3}{4}(5 - 2) = 8 + \frac{3}{4} \cdot 3 = 8 + 2.25 = 10.25 $$
New point:
$P_1' = (5, 10.25)$
This point lies inside the window → region code = 0.
Step 2: $P_2$ has code 2 (Right).
Clip against the Right boundary: $x = 15$.
$$ y = 10.25 + \frac{3}{4}(15 - 5) = 10.25 + \frac{3}{4} \cdot 10 = 10.25 + 7.5 = 17.75 $$
New point:
$P_2' = (15, 17.75)$
This point also lies inside the window → region code = 0.
(c) Intersection Points
- With left boundary ($x=5$): $(5, 10.25)$
- With right boundary ($x=15$): $(15, 17.75)$
(d) Final Clipped Line Segment
Final visible line segment:
$[(5,\;10.25)\;\text{to}\;(15,\;17.75)]$
COHEN–SUTHERLAND LINE CLIPPING — SOLVED NUMERICAL (Q2)
Problem Statement
Line Endpoints:
$P_1 = (6, 2)$, $P_2 = (16, 32)$
Clipping Window:
$x_{min}=4,\; y_{min}=6,\; x_{max}=20,\; y_{max}=28$
(a) Finding Region Codes
Cohen–Sutherland region codes:
- Left = 0001 (1)
- Right = 0010 (2)
- Bottom = 0100 (4)
- Top = 1000 (8)
For $P_1(6,2)$:
- $y < 6$ → Bottom=4
Region code = $0100_2 = 4$
For $P_2(16,32)$:
- $y > 28$ → Top = 8
Region code = $1000_2 = 8$
Slope Calculation
$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{32 - 2}{16 - 6} = \frac{30}{10} = 3 $$
(b) Step-by-Step Clipping
Step 1: $P_1$ has code 4 (Bottom).
Clip against the Bottom boundary: $y = 6$.
Intersection formula:
$$ x = x_1 + \frac{y_{clip} - y_1}{m} $$
$$ x = 6 + \frac{6 - 2}{3} = 6 + \frac{4}{3} = 7.3333 $$
New point:
$P_1' = (7.3333, 6)$
This point lies inside the window → region code = 0.
Step 2: $P_2$ has code 8 (Top).
Clip against the Top boundary: $y = 28$.
$$ x = 16 + \frac{28 - 32}{3} = 16 - \frac{4}{3} = 14.6667 $$
New point:
$P_2' = (14.6667, 28)$
This point also lies inside the window → region code = 0.
(c) Intersection with Top / Bottom Boundary
- Bottom boundary ($y=6$): $(7.3333,\;6)$
- Top boundary ($y=28$): $(14.6667,\;28)$
(d) Final Visible Portion
Final clipped line segment:
$[(7.3333,\;6)\;\text{to}\;(14.6667,\;28)]$
Exact fractional form:
$\left[\left(\frac{22}{3},\,6\right)\;\text{to}\;\left(\frac{44}{3},\,28\right)\right]$
COHEN–SUTHERLAND LINE CLIPPING — SOLVED NUMERICAL (Q3)
Problem Statement
Line Segment:
$P_1 = (12, 5),\; P_2 = (40, 15)$
Clipping Window:
$x_{min}=10,\; y_{min}=10,\; x_{max}=30,\; y_{max}=20$
(a) Region Codes
Cohen–Sutherland outcode bit convention:
- Left = 0001 (1)
- Right = 0010 (2)
- Bottom = 0100 (4)
- Top = 1000 (8)
For $P_1(12,5)$:
- $y < 10$ → Bottom=4
Region code = $0100_2 = 4$
For $P_2(40,15)$:
- $x > 30$ → Right = 2
Region code = $0010_2 = 2$
Slope Calculation
$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{15 - 5}{40 - 12} = \frac{10}{28} = \frac{5}{14} $$
(b) Step-by-Step Clipping
Step 1: $P_1$ has code 4 (Bottom).
Clip against the Bottom boundary: $y = 10$.
Intersection formula:
$$ x = x_1 + \frac{y_{clip} - y_1}{m} $$
$$ x = 12 + \frac{10 - 5}{5/14} = 12 + \frac{5 \times 14}{5} = 12 + 14 = 26 $$
New point:
$P_1' = (26, 10)$
This point lies inside the window → region code = 0.
Step 2: $P_2$ has code 2 (Right).
Clip against the Right boundary: $x = 30$.
Intersection formula:
$$ y = y_1' + m(x_{clip} - x_1') $$
$$ y = 10 + \frac{5}{14}(30 - 26) = 10 + \frac{20}{14} = 10 + \frac{10}{7} = 11.4286 $$
New point:
$P_2' = (30, 11.4286)$
This point lies inside the window → region code = 0.
(c) Intersection Points
- With bottom boundary ($y=10$): $(26, 10)$
- With right boundary ($x=30$): $(30, 11.4286)$
(d) Final Clipped Coordinates
Final visible line segment:
$[(26,\;10)\;\text{to}\;(30,\;11.4286)]$
Exact fractional form:
$\left[(26,\;10)\;\text{to}\;\left(30,\;\frac{80}{7}\right)\right]$
COHEN–SUTHERLAND LINE CLIPPING — SOLVED NUMERICAL (Q4)
Problem Statement
Line Segment:
$P_1 = (0,0),\; P_2 = (25,35)$
Clipping Window:
$x_{min}=5,\; y_{min}=5,\; x_{max}=20,\; y_{max}=30$
(a) Region Codes
Cohen–Sutherland outcode convention:
- Left = 0001 (1)
- Right = 0010 (2)
- Bottom = 0100 (4)
- Top = 1000 (8)
For $P_1(0,0)$:
- $x < 5$ → Left=1
- $y < 5$ → Bottom=4
Region code = $0101_2 = 5$
For $P_2(25,35)$:
- $x > 20$ → Right = 2
- $y > 30$ → Top = 8
Region code = $1010_2 = 10$
Slope Calculation
$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{35 - 0}{25 - 0} = \frac{35}{25} = 1.4 $$
(b) Cohen–Sutherland Clipping Steps
Step 1: $P_1$ has code 5 (Left + Bottom).
Clip against the Left boundary first: $x = 5$.
Intersection formula:
$$ y = y_1 + m(x_{clip} - x_1) $$
$$ y = 0 + 1.4(5 - 0) = 7 $$
New point:
$P_1' = (5, 7)$
This point lies inside the window → region code = 0.
Step 2: $P_2$ has code 10 (Top + Right).
First try clipping against the Top boundary: $y = 30$.
$$ x = x_2 + \frac{y_{clip} - y_2}{m} = 25 + \frac{30 - 35}{1.4} = 25 - 3.5714 = 21.4286 $$
This $x$ value is outside the window $(>20)$, so clipping with Top is invalid.
Now clip against the Right boundary: $x = 20$.
$$ y = y_2 + m(x_{clip} - x_2) = 35 + 1.4(20 - 25) = 35 - 7 = 28 $$
New point:
$P_2' = (20, 28)$
This point lies inside the window → region code = 0.
(c) Intersection Points
- With left boundary ($x=5$): $(5, 7)$
- With right boundary ($x=20$): $(20, 28)$
(d) Final Accepted Line
Final clipped line segment:
$[(5,\;7)\;\text{to}\;(20,\;28)]$
COHEN–SUTHERLAND LINE CLIPPING — SOLVED NUMERICAL (Q5)
Problem Statement
Line Segment:
$P_1 = (8,25),\; P_2 = (40,5)$
Clipping Window:
$x_{min}=10,\; y_{min}=10,\; x_{max}=30,\; y_{max}=20$
(a) Region Codes
Cohen–Sutherland outcode bit convention:
- Left = 0001 (1)
- Right = 0010 (2)
- Bottom = 0100 (4)
- Top = 1000 (8)
For $P_1(8,25)$:
- $x < 10$ → Left=1
- $y > 20$ → Top = 8
Region code = $1001_2 = 9$
For $P_2(40,5)$:
- $x > 30$ → Right = 2
- $y < 10$ → Bottom=4
Region code = $0110_2 = 6$
Slope Calculation
$$ m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{5 - 25}{40 - 8} = \frac{-20}{32} = -\frac{5}{8} = -0.625 $$
(b) Step-by-Step Clipping
Step 1: $P_1$ has code 9 (Left + Top).
Clip against the Left boundary first: $x = 10$.
$$ y = y_1 + m(x_{clip} - x_1) = 25 + (-0.625)(10 - 8) = 25 - 1.25 = 23.75 $$
New point:
$P_1' = (10, 23.75)$
This point is still above the window ($y > 20$) → new code = $1000_2$ (Top).
Step 2: Clip this point against the Top boundary: $y = 20$.
$$ x = x_1' + \frac{y_{clip} - y_1'}{m} = 10 + \frac{20 - 23.75}{-0.625} = 10 + \frac{-3.75}{-0.625} = 10 + 6 = 16 $$
New point:
$P_1'' = (16, 20)$
This point lies inside the window → region code = 0.
Step 3: $P_2$ has code 6 (Right + Bottom).
Clip against the Right boundary first: $x = 30$.
$$ y = y_2 + m(x_{clip} - x_2) = 5 + (-0.625)(30 - 40) = 5 + 6.25 = 11.25 $$
New point:
$P_2' = (30, 11.25)$
This point lies inside the window → region code = 0.
(c) Intersection with Right & Bottom Boundaries
- Right boundary ($x=30$): $(30, 11.25)$
- Bottom boundary: Not required in final result (right clipping produced valid point)
(d) Final Clipped Segment
Final visible line segment:
$[(16,\;20)\;\text{to}\;(30,\;11.25)]$
Semester Recap
- Graphics Pipeline Stages: Modeling \(\rightarrow\) Transformation \(\rightarrow\) Lighting \(\rightarrow\) Projection \(\rightarrow\) Clipping \(\rightarrow\) Rasterization \(\rightarrow\) Display.
- Tweening: Automatically generating intermediate frames between keyframes to create smooth motion (in-betweening).
- Homogeneous Coordinates: Using \((x, y, 1)\) for 2D and \((x, y, z, 1)\) for 3D to represent translation as matrix multiplication.
- Matrix Multiplication Rule: Non-commutative (\(A \cdot B \ne B \cdot A\)); order matters (apply Right-to-Left: \(T \cdot R \cdot S\)).
- Z-Buffer (Depth Buffer): Stores depth (\(z\)) of each pixel; if \(z_{\text{new}} < z_{\text{stored}}\), pixel is updated (closer object obscures farther).
- A-Buffer: Stores a list of fragments per pixel to handle transparency and anti-aliasing.
- Perspective Projection: All projectors meet at a Center of Projection (COP); creates depth (objects shrink with distance).
- Parallel Projection: Projectors are parallel (e.g., Orthographic); preserves exact dimensions/scale interactions.
- Cohen-Sutherland Codes: Top (1000), Bottom (0100), Right (0010), Left (0001); used for trivial accept/reject tests.
- Animation Types: Keyframe (interpolation), Procedural (physics/rules), Motion Capture (real-world sensors).
