Computer Graphics PYQs
Computer Graphics PYQs
Applications:
- Entertainment: Animation, gaming, and visual effects in movies.
- Education: Interactive educational software.
- Medical Imaging: Visualizing complex anatomy through 3D rendering.
- Simulation: Flight simulators and architectural visualization.
- Graphic Design: Designing logos, posters, and other media.
2. Describe the Digital Differential Analyzer (DDA) algorithm for line generation.
The DDA algorithm is an incremental method used for rasterizing lines between two points
in a grid. It calculates intermediate points along a line using floating-point arithmetic and
places pixels at these points.
Steps:
1. Initialize starting coordinates (x₀, y₀) and ending coordinates (x₁, y₁).
2. Calculate Δx = x₁ - x₀ and Δy = y₁ - y₀.
3. Determine the number of steps as the maximum of |Δx| or |Δy|.
4. Calculate increments x_increment = Δx / steps and y_increment = Δy / steps.
5. Starting from (x₀, y₀), repeatedly add increments to generate line points until reaching
(x₁, y₁).
Steps:
1. Divide the Clipping Region into 9 regions with a 4-bit region code.
2. Assign Region Codes for each endpoint based on position relative to the clipping window.
3. Check for Trivial Accept/Reject:
- If both endpoints are 0000, the line is accepted.
- If logical AND of endpoints' codes is non-zero, the line is rejected.
4. Iteratively clip, moving endpoints into the window as needed.
Steps:
1. Initialize circle center (h, k), radius r, starting point (0, r).
2. Calculate initial decision parameter p₀ = 1 - r.
3. Plot 8 symmetrical points for each calculated point.
4. Update p based on condition. If p < 0, use p_next = p + 2x + 1; otherwise, use p_next = p +
2x - 2y + 1.
5. Repeat until x > y.
For a cubic Bezier curve with control points (P₀, P₁, P₂, P₃):
P(t) = (1 - t)³P₀ + 3t(1 - t)²P₁ + 3t²(1 - t)P₂ + t³P₃, where t ∈ [0, 1]
For each pixel, Z-values are compared. If the new Z-value is less than the current buffer, the
color and Z-buffer are updated; otherwise, the pixel is discarded.
- Flat Shading: Single color per polygon; fast but less realistic.
- Gouraud Shading: Interpolates colors across vertices for gradients.
- Phong Shading: Interpolates normals for smoother highlights, offering better quality.