Computer Graphics Notes
DSC course under University of Kerala (UoK FYUGP Regulations). Credits: 4 | 60 Hours (4 Hrs/Week).
Chapter-Wise Module Notes & PDF Downloads
Short Notes
All Modules IncludedComplete syllabus revision notes covering all modules in one single PDF
Module 1
Introduction to Computer Graphics
Module 2
Output Primitives
Module 3
Two Dimensional Transformations and Clipping
Module 4
3D Concepts and Techniques
Module 5
Flexi Module: Curves, Animation, Shading & Lab Programs
Read Module Notes Online
Module I: Introduction to Computer Graphics
Chapter 1: Foundations of Computer Graphics, Pixels, and Frame Buffers
1.1 Scope and Applications of Computer Graphics
Computer graphics is the branch of computer science concerned with generating, representing, manipulating, and displaying visual images—ranging from two-dimensional diagrams and user interfaces to photorealistic three-dimensional scenes and real-time interactive simulations—using digital hardware and mathematical algorithms. Unlike image processing, which takes an existing captured photograph and enhances or analyzes its pixel array, computer graphics synthesizes visual output from abstract geometric models, color specifications, lighting equations, and camera viewpoints. Every visual frame rendered on a screen begins as structured numerical data in memory and undergoes a deterministic transformation pipeline before emerging as light intensities on a display surface.
Modern computing relies on computer graphics across engineering, scientific visualization, entertainment, education, and commercial design. Because human visual perception processes spatial patterns, color gradients, and motion far faster than raw numerical tables, graphical systems serve as the primary interface between complex computational models and human decision-makers.
| Application Domain | Primary Graphical Techniques | Representative Real-World Uses |
|---|---|---|
| Computer-Aided Design (CAD) | Wireframe modeling, parametric curves, hidden-line removal, orthographic projections | Architectural blueprints, automotive chassis engineering, VLSI circuit layout, aerospace part tolerances |
| Graphical User Interfaces (GUI) | 2D raster primitives, window clipping, anti-aliased typography, alpha compositing | Desktop operating systems, mobile touch interfaces, web browsers, interactive dashboards |
| Scientific & Medical Visualization | Volume rendering, iso-surface extraction, false-color mapping, 3D mesh slicing | CT and MRI anatomical reconstructions, computational fluid dynamics, molecular docking, weather radar |
| Entertainment & Animation | Keyframing, morphing, Gouraud and Phong shading, ray tracing, texture mapping | Animated feature films, real-time 3D video games, visual effects (VFX), virtual production |
| Simulation & Virtual Reality | Stereoscopic rendering, head-tracked perspective projection, high-frame-rate rasterization | Flight and surgical simulators, VR architectural walkthroughs, military tactical training |
| Presentation & Data Graphics | Bar charts, scatter plots, spline-smoothed trend curves, geographic information overlays | Financial analytics, census cartography, academic reporting, business intelligence |
1.2 Pixels, Resolution, and Aspect Ratio
A pixel (short for picture element) is the smallest individually addressable discrete unit of a digital raster image or display screen. On a physical display panel, each pixel is typically composed of three closely spaced sub-pixels emitting red, green, and blue light at variable intensities. In memory, a pixel corresponds to one or more bits or bytes storing color, intensity, and optional transparency or depth attributes. Because a digital image is sampled on a discrete rectangular grid of rows and columns, continuous geometric shapes such as diagonal lines and curved arcs must be approximated by illuminating the nearest grid cells, a process known as scan conversion or rasterization.
Resolution quantifies the level of spatial detail a display device or image buffer can represent. It is expressed in two complementary ways: spatial resolution and intensity (color) resolution. Spatial resolution denotes the total number of horizontal pixels by vertical pixels arranged across the screen, written as (for example, for Full HD or for 4K UHD). Higher spatial resolution packs more pixels per physical inch (measured in Pixels Per Inch, or PPI), reducing jagged staircase artifacts (aliasing) along diagonal edges. Color resolution, or color depth, specifies the number of bits allocated per pixel (bpp), determining how many distinct colors each pixel can display simultaneously: colors for bits per pixel.
Aspect Ratio is the proportional relationship between the width and height of an image, viewport, or physical display screen. It is expressed either as a reduced integer ratio or as a single scalar quotient . Standard historical television and early CRT monitors used a aspect ratio (), whereas modern widescreen monitors and HDTVs predominantly use () or ultra-wide . Preserving aspect ratio during coordinate mapping is essential; if a graphical scene is stretched unadjusted onto a screen, circles distort into horizontal ellipses and squares stretch into rectangles. Physical pixel aspect ratio (PAR) must equal (square pixels) for geometric fidelity across devices.
1.3 Frame Buffer Organization and Bandwidth Calculations
The frame buffer (also called the refresh buffer) is a dedicated region of high-speed memory that stores the complete matrix of pixel intensity or color values for the image currently displayed on the screen. Every pixel at screen coordinate maps to a specific memory address inside the frame buffer. In a monochrome bi-level system, each pixel requires only 1 bit (0 for background, 1 for foreground), so the frame buffer is called a bitmap. In multi-bit color systems—such as 8-bit indexed color, 16-bit High Color, or 24-bit/32-bit True Color—the frame buffer is referred to as a pixmap.
Worked Numerical Example: Consider a display configured at resolution with 24-bit True Color (8 bits each for Red, Green, and Blue) operating at a refresh rate. First, compute the total pixel count: . Multiply by 24 bits per pixel and divide by 8 bits per byte: . At 60 frames per second, the display controller must read continuously just to refresh the monitor without flicker.
Chapter 2: Display Architectures, Video Controllers, and 3D Viewing
2.1 Raster Scan vs. Random Scan Systems
Display systems historically evolved along two distinct hardware architectures for sweeping an image onto a screen: raster scan and random scan (also called vector or calligraphic scan). Understanding their operational contrast explains why modern GPUs rely on frame buffers while early CAD terminals drew crisp lines directly from geometric command lists.
In a Raster Scan System, the electron beam (or digital row-column driver in flat panels) sweeps systematically across the screen one horizontal scan line at a time, starting from the top-left corner and moving left to right down to the bottom-right corner. As the beam traverses each pixel position, its intensity is modulated according to the color value stored at the corresponding address in the frame buffer. When the beam reaches the right end of a scan line, it is blanked (turned off) and rapidly deflected back to the left edge of the next lower scan line; this rapid flyback motion is called horizontal retrace. Once the beam completes the final bottom-right scan line, it is blanked and deflected diagonally back to the top-left corner to begin the next frame; this return is called vertical retrace. Standard refresh rates of 60 Hz to 144 Hz ensure that phosphor persistence or pixel hold prevents visible flicker. Raster displays may use progressive scanning (all lines drawn sequentially every frame) or interlaced scanning (odd lines drawn in one pass, even lines in the next, halving bandwidth at the risk of line-twitter).
In a Random Scan System (vector display), the electron beam is directed strictly to the regions of the screen where a line or geometric primitive needs to be drawn, rather than scanning every pixel across the entire surface. Instead of a pixel-by-pixel frame buffer, a random scan system stores a sequence of line-drawing commands—such as endpoint coordinates and stroke intensity—inside a memory area called a display list or refresh display file. A display processor reads each instruction in the display list and drives the CRT deflection plates to trace the line directly from start point to end point. Because the beam follows true continuous analog paths, random scan monitors produce extraordinarily sharp, stair-step-free lines, making them ideal for early engineering CAD drafting. However, they cannot render realistically shaded solid surfaces, photographic textures, or complex filled polygons without overloading the refresh cycle.
| Architectural Feature | Raster Scan Display | Random Scan (Vector) Display |
|---|---|---|
| Beam / Scan Path | Fixed top-to-bottom, left-to-right sweep across all scan lines | Directed solely along the endpoints of defined geometric lines |
| Refresh Memory | Frame buffer storing discrete pixel intensity/color values | Display list (refresh file) storing line-drawing commands |
| Resolution & Line Quality | Discrete grid causes aliasing (staircase effect) on diagonal lines | Smooth continuous lines with higher effective line precision |
| Shading & Realism | Excels at solid-filled polygons, gradients, textures, and photorealism | Limited to wireframe outlines; unsuitable for realistic shaded scenes |
| Refresh Complexity | Constant refresh time independent of scene complexity | Refresh rate drops and flickers if the number of lines exceeds capacity |
2.2 Video Controller, Video Adapter, and Graphics Card Architecture
A video controller (display controller) is the dedicated hardware circuit responsible for reading pixel data from the frame buffer at fixed clock intervals and generating the timing synchronization signals (HSYNC for horizontal retrace, VSYNC for vertical retrace) and analog/digital color signals sent to the monitor. Two internal registers, and , track the current screen pixel coordinates during a raster sweep. Initially, is set to the top scan line and is set to 0. For each pixel clock tick, the controller fetches the value at address , passes it through a Color Look-Up Table (CLUT) or Digital-to-Analog Converter (DAC), and increments . When reaches the horizontal boundary, it resets to 0 and advances to the next line. High-end systems employ double buffering—one front buffer for active scan-out and one back buffer for drawing—swapped during vertical retrace to eliminate screen tearing.
A video adapter is the broader interface subsystem (historically standards such as MDA, CGA, EGA, VGA, and SVGA) that standardizes how the host CPU communicates with the frame buffer, sets display resolutions, and outputs signals over connectors like VGA, DVI, HDMI, or DisplayPort. A modern graphics card (discrete GPU expansion board) integrates a massively parallel Graphics Processing Unit (GPU), dedicated high-bandwidth Video RAM (GDDR6/HBM), hardware rasterizers, programmable vertex and fragment shader cores, texture mapping units, and multi-channel display controllers on a single PCIe circuit board, offloading millions of matrix multiplications and pixel shading calculations per frame from the host CPU.
2.3 Flat-Panel and Specialized Display Devices (LCD, LED, DVST)
Liquid Crystal Display (LCD): An LCD is a non-emissive flat-panel device that modulates polarized light using nematic liquid crystal molecules sandwiched between two glass substrates with transparent Indium Tin Oxide (ITO) electrodes and crossed polarizing filters. When no voltage is applied across a pixel cell, the twisted nematic crystal structure rotates the polarization plane of light from the rear backlight by 90 degrees, allowing it to pass through the front analyzer and illuminate the pixel. Applying an electric field untwists the crystals so light polarization remains unaltered and is blocked by the front polarizer, producing a dark pixel. Active-matrix Thin-Film Transistor (TFT) LCDs place a microscopic transistor and capacitor at every sub-pixel to maintain voltage cleanly without cross-talk, supporting fast response times and sharp color reproduction through RGB micro-filters.
Light Emitting Diode (LED) Displays: The term LED display applies to two distinct technologies. First, LED-backlit LCD monitors replace legacy Cold Cathode Fluorescent Lamps (CCFL) with arrays of white or RGB light-emitting diodes behind or along the edges of an LCD panel, yielding thinner profiles, lower power draw, and local dimming contrast. Second, true emissive LED and OLED (Organic Light-Emitting Diode) panels generate light directly at every individual pixel when electric current passes through organic semiconductor layers. Because each OLED pixel can be switched completely off independently, emissive displays achieve infinite contrast ratios, ultra-fast microsecond response times, and flexible form factors without requiring a separate backlight unit.
Direct View Storage Tube (DVST): The DVST is a specialized CRT-based vector display designed to eliminate screen flicker on complex engineering drawings without requiring a high-speed refresh buffer. It employs two electron guns: a primary gun and a flood gun. The primary gun focuses a high-velocity beam to trace the picture pattern onto a fine wire-mesh storage grid coated with dielectric material located just behind the phosphor screen, depositing a positive charge pattern. The flood gun continuously showers the entire storage grid with low-velocity electrons; these electrons are repelled by uncharged regions but pass through the positively charged pattern on the grid to strike the phosphor screen and keep the image illuminated indefinitely. Because the image is stored physically on the mesh, thousands of lines can be displayed with zero flicker. However, DVSTs cannot easily display dynamic animation or selectively erase single lines—modifying any part of the drawing requires flooding the entire grid with an erase pulse, producing a brief bright flash before redrawing the whole scene.
2.4 3D Viewing Devices, Stereoscopic, and Virtual Reality Systems
Conventional monitors project three-dimensional scenes onto a flat two-dimensional plane, forcing depth perception to rely on monocular cues such as perspective foreshortening, occlusion, and shading. True 3D viewing devices and stereoscopic systems exploit human binocular disparity (stereopsis) by delivering two slightly offset perspective views—one rendered from the left eye camera position and one from the right eye camera position, separated by the interpupillary distance (approximately 63 mm).
- Varifocal Mirror Displays: A flexible aluminized membrane mirror vibrates acoustically in front of a high-speed CRT monitor. As the mirror oscillates, its focal length changes continuously; the CRT displays 2D cross-sectional slices synchronized to the mirror's instantaneous depth position, creating a true volumetric 3D image visible from multiple angles.
- Passive Polarized Stereoscopy: A dual-projector or patterned retarder screen outputs left-eye and right-eye images using orthogonal circular or linear polarization. Viewers wear inexpensive passive polarized glasses so each eye filters only its intended view.
- Active Shutter Stereoscopy: A high-refresh-rate display (120 Hz or higher) alternates left-eye and right-eye frames sequentially. Infrared or RF synchronization signals trigger LCD shutter glasses to darken the opposite lens in exact lockstep with each frame.
- Virtual Reality (VR) Systems: Head-Mounted Displays (HMDs) mount dual high-resolution micro-displays behind wide-field-of-view magnifying lenses directly in front of each eye. Integrated Inertial Measurement Units (IMUs—gyroscopes and accelerometers) and optical outside-in or inside-out tracking sensors measure 6-Degrees-of-Freedom (6DoF) head translation and orientation at sub-millisecond latency, updating both stereoscopic viewports in real time to sustain immersion and prevent motion sickness.
Chapter 3: Properties of Light and Color Models
3.1 Physical Properties of Light and Human Color Perception
Visible light is electromagnetic radiation occupying the narrow wavelength band from roughly (violet) to (deep red). Any light source emits a Spectral Power Distribution (SPD) across these wavelengths. Human vision characterizes light along three perceptual attributes: hue (dominant wavelength perceived as red, green, blue, etc.), saturation (chromatic purity, or how much white light dilutes the dominant hue), and luminance/brightness (perceived total radiant energy). The human retina contains rod cells sensitive to low-light luminance and three types of cone cells (L, M, and S cones) peaking in long (red), medium (green), and short (blue) wavelength bands. Because human color perception is trichromatic, virtually any visible color can be synthesized by combining three independent primary components—a principle known as Grassmann's law.
3.2 Additive vs. Subtractive Color Models (RGB, CMY, YIQ, HSV)
A color model (or color space) is a mathematical coordinate system that maps colors to numerical tuples for standardized storage, hardware output, and artistic selection.
1. RGB Color Model (Additive): Used by emissive hardware such as monitors, projectors, and digital cameras, RGB combines Red, Green, and Blue primaries on a black background. Normalized component values lie in , forming a unit cube. Adding full intensities yields pure white; yields black; equal components trace the main diagonal of neutral grays. Secondary colors arise from pairwise addition: Red + Green = Yellow, Green + Blue = Cyan, and Blue + Red = Magenta.
2. CMY and CMYK Color Models (Subtractive): Used by hardcopy printers and ink plotters on white paper, CMY uses Cyan, Magenta, and Yellow pigments that absorb (subtract) red, green, and blue wavelengths from incident white light. Cyan ink absorbs red light and reflects green and blue. Because real-world CMY inks produce muddy dark brown rather than crisp black when mixed equally, commercial printing adds a fourth black ink channel (Key, forming CMYK) to sharpen text and reduce ink consumption. Conversion between normalized RGB and CMY is an exact complement:
3. YIQ Color Model (Broadcast Television): Designed for the North American NTSC television standard, YIQ decouples luminance () from color information ( and ). This separation guaranteed backward compatibility: monochrome televisions decoded only the signal, while color sets decoded all three. Because human vision has lower spatial acuity for chrominance than luminance, and signals could be transmitted over narrower bandwidths without noticeable quality loss.
4. HSV Color Model (Hue, Saturation, Value): While RGB and CMY suit hardware devices, artists find it unintuitive to mix percentages of red, green, and blue to darken or desaturate a pigment. The HSV (Hexcone) model aligns directly with human color intuition: Hue () selects the pure spectral angle around a hexagonal wheel (0° Red, 60° Yellow, 120° Green, 180° Cyan, 240° Blue, 300° Magenta); Saturation () measures purity from neutral gray at the center axis () to vivid pure pigment on the perimeter (); and Value () measures brightness from black apex () to full illumination at the top hexagonal face ().
Worked Numerical Example (RGB to CMY, YIQ, and HSV): Given an RGB color :
- CMY Conversion: , , , giving .
- YIQ Conversion: ; ; .
- HSV Conversion: ; ; . Saturation . Since is maximum, . Thus HSV is .
| Color Model | Primary Axes | Model Type | Primary Application |
|---|---|---|---|
| RGB | Red, Green, Blue | Additive | Monitors, GPUs, digital cameras, web graphics |
| CMY / CMYK | Cyan, Magenta, Yellow (+ Black) | Subtractive | Inkjet/laser printers, offset publishing |
| YIQ | Luminance (Y), In-phase (I), Quadrature (Q) | Luminance-Chrominance | NTSC analog television, bandwidth compression |
| HSV | Hue, Saturation, Value | Perceptual / Hexcone | Color pickers, digital painting, image editing |
3.3 Color Look-Up Tables (CLUT), Bit Planes, and Memory Optimization
In early and embedded raster hardware, storing 24 bits per pixel across a high-resolution screen was prohibitively expensive. To reduce frame buffer memory while preserving access to a rich palette of colors, graphics adapters introduced Color Look-Up Tables (CLUT), also known as hardware color palettes. Instead of storing full 8-bit Red, 8-bit Green, and 8-bit Blue values directly inside each pixel, the frame buffer stores a smaller index—typically 4 bits (16 colors) or 8 bits (256 colors)—across 4 or 8 parallel bit planes. During raster scan-out, the pixel index addresses a fast SRAM table inside the RAMDAC (Random Access Memory Digital-to-Analog Converter) containing 24-bit RGB triplets.
Worked Numerical Example (CLUT Memory Savings): Compare a frame buffer using direct 24-bit True Color versus an 8-bit CLUT referencing a 24-bit palette of 256 colors. Under direct True Color, frame buffer size is . Under an 8-bit CLUT, the frame buffer stores , plus the tiny palette table of —achieving a 66.7% reduction in video memory while still displaying any 256 colors chosen from 16.77 million possible shades.
3.4 Detailed Piecewise HSV-to-RGB Conversion and Gamut
When a digital artist selects a color in HSV space, the graphics pipeline must convert back into hardware intensities before writing to the frame buffer. Let represent chroma, , , and . Depending on which sector occupies, intermediate values are assigned as for , for , for , for , for , and for . Finally, .
Worked Numerical Example (HSV to RGB): Convert to RGB. Here , , and . Baseline . Because , . Adding yields .
Chapter 4: Hardware Display Pipelines and CRT Technologies
4.1 Cathode Ray Tube (CRT) Physics: Shadow-Mask vs. Beam-Penetration
Although flat-panel LCD and OLED screens dominate modern desktops, understanding Cathode Ray Tube (CRT) physics explains the origin of raster scan timing, retrace blanking, and color convergence. In a monochrome CRT, a heated cathode emits electrons accelerated by high-voltage anodes, focused by electrostatic lenses, and steered horizontally and vertically by magnetic deflection coils to strike a phosphor-coated glass faceplate. Color CRTs employ two principal phosphor architectures:
| Feature | Beam-Penetration CRT | Shadow-Mask CRT |
|---|---|---|
| Electron Guns | Single electron gun | Three electron guns (Red, Green, Blue) |
| Phosphor Arrangement | Two layered coatings (outer red, inner green) | Triad dots or vertical stripes of R, G, B phosphors |
| Color Selection Mechanism | Accelerating voltage controls beam penetration depth | Perforated metal shadow mask aligns each gun to its phosphor |
| Color Range | Limited to 4 colors (red, orange, yellow, green) | Millions of full-spectrum True Color shades |
| Primary Use | High-resolution random-scan vector CAD displays | Standard raster-scan television and color monitors |
4.2 Double Buffering, Refresh Synchronization, and VSync
When a CPU or GPU writes directly into the active frame buffer while the video controller is simultaneously scanning out a frame to the monitor, the upper half of the display may show the previous frame while the lower half shows the newly drawn frame—a visual defect known as screen tearing. Double buffering eliminates tearing by maintaining two complete frame buffers in video memory: a front buffer (read exclusively by the video controller for display scan-out) and a back buffer (written exclusively by the graphics renderer). Once the back buffer completes a frame, the graphics card waits for the vertical retrace interval (Vertical Synchronization, or VSync) and swaps the front and back buffer pointers atomically. If a scene takes slightly longer than one refresh period (16.67 ms at 60 Hz) to render, VSync forces the GPU to wait until the next retrace, dropping the effective frame rate to 30 fps; triple buffering adds a second back buffer to sustain smooth frame pacing without tearing.
4.3 Comparative Summary of Flat-Panel Technologies
Modern computing devices select display panels by balancing luminous efficiency, viewing angles, response latency, and manufacturing cost across LCD, LED-backlit, and emissive OLED/MicroLED architectures.
| Display Technology | Light Emission Principle | Contrast & Black Level | Response Time & Power Profile |
|---|---|---|---|
| TFT-LCD (CCFL/LED) | Non-emissive liquid crystal shutter + rear backlight | Moderate (1000:1); backlight bleed causes grayish blacks | 1–8 ms response; constant backlight power draw |
| OLED (Active Matrix) | Self-emissive organic diode per sub-pixel | Infinite contrast; true zero-nit pure black when off | Sub-0.1 ms response; power scales with bright pixels |
| DVST | Primary + flood electron guns with dielectric storage mesh | High-contrast monochrome green vector lines | Zero flicker, but slow full-screen erase flash |
4.4 Virtual Reality Pipeline: Optical Distortion and Latency Mitigation
In a Virtual Reality Head-Mounted Display, the magnifying lenses positioned centimeters from the user's eyes introduce strong optical pincushion distortion and chromatic aberration across the wide field of view (typically 90° to 110°). To ensure the user perceives geometrically straight lines, the GPU renders each eye's frame into an off-screen texture and applies an inverse barrel pre-distortion shader before outputting to the panel. Furthermore, maintaining a motion-to-photon latency under 20 milliseconds—from head rotation sensed by the IMU to updated photons reaching the retina—is critical to prevent simulator sickness. Modern VR runtimes use Asynchronous Timewarp (ATW), reprojecting the most recently rendered frame using updated rotational IMU data just microseconds before scan-out.
Chapter 5: Colorimetric Standards, Gamma Correction, and Display Engineering
5.1 CIE XYZ Color Space and Chromaticity Gamuts
Device-dependent color spaces such as RGB and CMY vary across physical monitors and printers because phosphors, LEDs, and inks differ in spectral emission. To establish an objective, device-independent standard of human color vision, the International Commission on Illumination (CIE) defined the CIE 1931 XYZ color space using three imaginary primary stimuli () constructed so that all visible spectral colors map to strictly non-negative coordinates, and the component represents pure perceptual luminance.
The curved outer boundary of the CIE chromaticity diagram traces pure monochromatic wavelengths from 380 nm to 700 nm, closed at the bottom by the non-spectral line of purples. Any three physical primaries—such as the Red, Green, and Blue sub-pixels of an sRGB monitor—form a triangle inside the horseshoe; all colors reproducible by mixing those three primaries lie strictly within that triangle, called the device's color gamut. Because no triangle of three real primaries can enclose the entire curved horseshoe, physical displays can reproduce only a subset of all colors visible to the human eye.
5.2 Gamma Correction and Non-Linear Display Response
Physical CRT electron guns and LCD voltage curves exhibit a non-linear power-law relationship between normalized input voltage and emitted screen luminance : , where the display exponent is typically around for standard sRGB monitors. Without compensation, mid-tone gray () would emit only of peak white luminance, making rendered images appear unnaturally dark and crushed in shadow detail. Gamma correction applies the inverse power law before storing pixel values into the 8-bit frame buffer, ensuring that perceptual mid-tones allocate balanced quantization levels across human vision's logarithmic sensitivity curve.
5.3 Sub-Pixel Rendering, Refresh Rates, and Video Adapter Evolution
Modern LCD and OLED panels arrange red, green, and blue sub-pixels side by side horizontally. Sub-pixel rendering (used in font anti-aliasing technologies) addresses individual R, G, and B sub-pixels independently rather than treating the triad as a single block, effectively tripling horizontal spatial resolution for crisp text edges. Historically, PC graphics progressed from monochrome text-only MDA (Monochrome Display Adapter) and 4-color CGA (Color Graphics Adapter) to 16-color EGA, 256-color VGA ( analog), and SVGA, before modern PCI Express GPUs adopted high-speed digital differential signaling (HDMI and DisplayPort) capable of driving 4K and 8K panels at 120 Hz to 240 Hz with High Dynamic Range (HDR10) 10-bit per channel precision.
Worked Numerical Example (Display Bandwidth with VSync & Double Buffering): Suppose a workstation drives dual monitors at with 32-bit RGBA color (4 bytes per pixel) and double buffering. Single-frame size per monitor is . With double buffering across two monitors, total frame buffer allocation is . Total scan-out bandwidth across both displays at 120 Hz equals , well within modern GDDR6 memory buses exceeding 400 GB/s.
Module II: Output Primitives
Chapter 1: Graphics Coordinate Systems and Scan Conversion
1.1 Modelling, World, Normalized Device, and Device Coordinates
Before any line, circle, or polygon can illuminate pixels on a monitor, its geometry passes through a sequence of standardized coordinate systems. Separating local object design from global scene placement and physical screen resolution enables software applications to remain hardware-independent.
- Modelling Coordinates (Local / Master Coordinates): Each individual object—such as a chair, gear, or character limb—is defined in its own convenient local coordinate frame, typically centered at its own origin . This allows identical parts to be designed once and instanced repeatedly.
- World Coordinates (WC): All individual objects are transformed and assembled into a unified scene space called World Coordinates, measured in application-specific physical units (meters, millimeters, or kilometers). Lighting, camera placement, and spatial relationships between objects are evaluated in World Coordinates.
- Normalized Device Coordinates (NDC): To decouple rendering logic from specific monitor resolutions, a selected rectangular region of World Coordinates (the window) is mapped into a device-independent unit range—typically or .
- Device Coordinates (Screen Coordinates): Finally, Normalized Device Coordinates are scaled to integer pixel indices corresponding to the actual frame buffer dimensions of the target output device (e.g., and ).
1.2 Output Primitives and Straight-Line Equations
Output primitives are the basic geometric building blocks provided by a graphics library (such as points, straight line segments, circles, ellipses, and polygons) from which complex scenes are constructed. Scan-converting a straight line segment between two integer endpoints and requires selecting a contiguous sequence of discrete pixels that closely approximates the continuous mathematical line , where slope and y-intercept . A good line-drawing algorithm must produce straight lines of uniform brightness regardless of slope, terminate accurately at the specified endpoints, and execute at high speed using minimal floating-point arithmetic.
Chapter 2: Line and Circle Scan-Conversion Algorithms
2.1 Digital Differential Analyzer (DDA) Line Algorithm
The DDA (Digital Differential Analyzer) algorithm is an incremental scan-conversion method based on sampling either or at unit intervals and computing the corresponding coordinate using the slope equation. Rather than evaluating from scratch at every pixel, DDA uses the previous pixel's coordinates to step incrementally.
If (shallow slope), increments by 1 at each step and . If (steep slope), increments by 1 at each step and , preventing gaps along steep lines. At each iteration, the floating-point values are rounded via to plot the pixel. While DDA eliminates the multiplication required by direct slope-intercept evaluation, it still relies on floating-point additions and rounding operations, which are slower than pure integer arithmetic and can accumulate drift over very long lines.
Worked Numerical Example (DDA): Digitizing the line from to : , . Since , . Increments are and . Starting at : Step 1 gives ; Step 2 gives ; Step 3 gives ; Step 4 gives ; Step 5 gives ; Step 6 gives ; Step 7 reaches .
2.2 Bresenham's Line Drawing Algorithm
Bresenham's Line Algorithm overcomes DDA's floating-point overhead by performing all calculations exclusively with fast integer addition, subtraction, and bit-shifting (multiplication by 2). For a line with slope moving left-to-right, after plotting pixel , the next candidate pixel must be either the East pixel or the North-East pixel . Bresenham's algorithm evaluates the vertical distances (from true line to lower pixel) and (from true line to upper pixel) and maintains an integer decision parameter .
Worked Numerical Example (Bresenham Line): Plot the line from to . Here , . Constants: , . Initial . Plot . Since , plot and . Since , plot and . Since , plot and . Since , plot and . Since , plot and . Finally, , plot .
2.3 Midpoint Circle Drawing Algorithm
A circle centered at the origin with radius satisfies . Exploiting 8-way symmetry, an algorithm only needs to compute pixel coordinates in the first octant—from down to —and reflect each point across all eight octants: and , translated by center .
In the first octant, always increments by 1, and either stays at (East) or decrements to (South-East). The Midpoint Circle Algorithm tests the sign of at the midpoint between the two candidate pixels:
Worked Numerical Example (Midpoint Circle): For centered at : , initial point . Step 0: , . Step 1: , . Step 2: , . Step 3: , . Step 4: , . Step 5: . Since , the octant completes and 8-way symmetry plots the full circle.
#include <graphics.h>
#include <stdio.h>
void plot8Way(int xc, int yc, int x, int y, int color) {
putpixel(xc + x, yc + y, color);
putpixel(xc - x, yc + y, color);
putpixel(xc + x, yc - y, color);
putpixel(xc - x, yc - y, color);
putpixel(xc + y, yc + x, color);
putpixel(xc - y, yc + x, color);
putpixel(xc + y, yc - x, color);
putpixel(xc - y, yc - x, color);
}
void midpointCircle(int xc, int yc, int r, int color) {
int x = 0, y = r;
int p = 1 - r;
plot8Way(xc, yc, x, y, color);
while (x < y) {
x++;
if (p < 0) {
p = p + 2 * x + 1;
} else {
y--;
p = p + 2 * x + 1 - 2 * y;
}
plot8Way(xc, yc, x, y, color);
}
}Chapter 3: Polygon Filling Algorithms
3.1 Seed-Based Filling: Boundary Fill and Flood Fill
Polygon filling assigns an interior color to all pixels enclosed within a closed polygonal region. Two primary paradigms exist: seed-based region filling (operating in image/frame-buffer space) and scan-line coherence filling (operating from geometric edge equations).
Boundary Fill Algorithm: Boundary fill starts from an interior seed pixel and expands outward recursively (or via an explicit stack) until it encounters pixels of a specified uniform boundary color. At each visited pixel, if its current color differs from both the boundary color and the target fill color, it is painted with the fill color and its neighbors are queued. Neighbors are visited using either 4-connected adjacency (North, South, East, West) or 8-connected adjacency (adding the four diagonal neighbors). Note that 4-connected fill cannot cross diagonal corners, whereas 8-connected fill can leak through thin 1-pixel diagonal boundary gaps.
Flood Fill Algorithm: When a region is bounded by multiple different colors (for instance, adjacent edges painted in red, blue, and green), Boundary Fill fails because there is no single boundary color to stop against. Flood Fill solves this by checking whether a visited pixel matches the original old interior color recorded at the seed point. Every contiguous pixel sharing that old color is replaced with the new fill color using 4-connected or 8-connected traversal.
3.2 Scan-Line Polygon Fill Algorithm
Recursive seed fills consume significant stack memory on large polygons and cannot fill polygons that are partially off-screen or self-intersecting with complex rules. The Scan-Line Polygon Fill Algorithm processes the polygon row by row from to . For each horizontal scan line , it computes all intersection -coordinates with the polygon edges, sorts those intersections in ascending order, and fills pixel spans between alternating pairs (parity odd-even rule: fill from 1st to 2nd intersection, skip 2nd to 3rd, fill 3rd to 4th).
To avoid recalculating intersections from scratch on every scan line, two coherence data structures are maintained:
- Sorted Edge Table (ET): Buckets indexed by each edge's minimum coordinate (). Each bucket entry stores the edge's , initial at , and inverse slope . Horizontal edges are ignored because they do not cross scan lines cleanly.
- Active Edge Table (AET): Contains only edges intersecting the current scan line , sorted by current . As increments by 1, edges with are removed, new edges from are inserted, and each remaining edge's intersection is updated incrementally via .
Special care is taken at polygon vertices where two edges meet: if both edges lie on the same side of the scan line (a local extremum vertex), the vertex counts as two intersections (even parity); if one edge goes above and the other goes below the scan line, the upper edge's is shortened by 1 pixel so the vertex counts as a single intersection, preserving proper odd-even span pairing.
| Filling Method | Stopping Condition | Strengths | Limitations |
|---|---|---|---|
| Boundary Fill | Stops at a uniform specified boundary color | Simple recursive/stack logic for arbitrary raster shapes | Requires single boundary color; deep recursion risks stack overflow |
| Flood Fill | Replaces pixels matching the seed's original interior color | Works on multi-colored boundaries and irregular paint regions | Slow per-pixel frame buffer reads; memory-intensive on large areas |
| Scan-Line Fill | Uses geometric edge intersections and odd-even parity | Fast incremental coherence; handles arbitrary polygons cleanly | Requires vertex/edge geometry; needs vertex-shortening rules |
3.3 Worked Numerical Trace: Scan-Line Polygon Fill
Consider a four-vertex polygon with vertices , , , and . Edge () and edge () are horizontal and therefore omitted from the Edge Table. The two non-horizontal edges are:
- Edge (from to ): , , , inverse slope .
- Edge (from to ): , , , inverse slope .
Both edges enter the Active Edge Table (AET) at scan line . At : , fill span . Incrementing : , fill span . At : , fill span . At : , fill span . At , both edges reach and are removed from the AET, terminating the fill cleanly.
3.4 Inside-Outside Tests: Odd-Even Rule vs. Non-Zero Winding Rule
For self-intersecting polygons (such as a five-pointed star) or polygons with interior holes, graphics systems must unambiguously decide whether a given point lies inside or outside the boundary:
- Odd-Even (Parity) Rule: Cast a ray from the test point in any fixed direction to infinity and count the number of polygon edge crossings. If the crossing count is odd, is interior; if even, is exterior. Under this rule, the central pentagon of a five-pointed star has two crossings and is treated as exterior (a hole).
- Non-Zero Winding Number Rule: Assign a direction vector to every polygon edge (say counter-clockwise around the perimeter). Cast a ray from and initialize a winding counter to zero. Add for every edge crossing from right to left across the ray, and for every edge crossing from left to right. If the final winding number is non-zero, is interior; if zero, is exterior.
Chapter 4: Midpoint Ellipse Algorithm, Anti-Aliasing, and C Lab Programs
4.1 Window-to-Viewport Coordinate Mapping
Mapping a rectangular World Coordinate window onto a Device Coordinate viewport preserves relative proportions via linear scaling:
4.2 Midpoint Ellipse Drawing Algorithm
An ellipse centered at the origin with horizontal semi-major radius and vertical semi-minor radius satisfies . Using 4-way symmetry across the four quadrants——the first quadrant is divided into two regions at the point where the tangent slope equals ():
- Region 1 (): Unit steps in , choosing between and . Initial parameter .
- Region 2 (): Unit steps in downward to , choosing between and . Initial parameter using the last point from Region 1.
4.3 Anti-Aliasing Techniques for Raster Primitives
Discrete sampling of continuous lines and polygon edges causes jagged staircase artifacts known as aliasing. Anti-aliasing softens these jagged edges by blending pixel intensities proportional to geometric coverage: (1) Supersampling (FSAA) renders the scene at a higher virtual grid resolution (e.g., sub-pixels per pixel) and averages sub-pixel colors down to each display pixel; (2) Unweighted Area Sampling sets pixel brightness proportional to the fraction of the pixel's square area overlapped by a finite-thickness line; and (3) Weighted Area Sampling (Gupta-Sproull) assigns greater weight to overlap near the center of the pixel using a conical filter kernel.
#include <graphics.h>
#include <math.h>
void ddaLine(int x1, int y1, int x2, int y2, int color) {
int dx = x2 - x1, dy = y2 - y1;
int steps = (abs(dx) > abs(dy)) ? abs(dx) : abs(dy);
float xInc = dx / (float)steps;
float yInc = dy / (float)steps;
float x = x1, y = y1;
for (int i = 0; i <= steps; i++) {
putpixel((int)(x + 0.5), (int)(y + 0.5), color);
x += xInc;
y += yInc;
}
}
void boundaryFill4(int x, int y, int fillCol, int boundCol) {
int current = getpixel(x, y);
if (current != boundCol && current != fillCol) {
putpixel(x, y, fillCol);
boundaryFill4(x + 1, y, fillCol, boundCol);
boundaryFill4(x - 1, y, fillCol, boundCol);
boundaryFill4(x, y + 1, fillCol, boundCol);
boundaryFill4(x, y - 1, fillCol, boundCol);
}
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
ddaLine(100, 100, 300, 220, WHITE);
rectangle(150, 150, 260, 260);
boundaryFill4(200, 200, CYAN, WHITE);
getch();
closegraph();
return 0;
}Chapter 5: General Octant Bresenham, Midpoint Ellipse Numerical & Scan-Line Seed Fill
5.1 Generalizing Bresenham's Line Algorithm to All Eight Octants
The basic derivation of Bresenham's algorithm assumes with . In general-purpose graphics libraries, lines can point in any direction across all 360 degrees. To handle arbitrary endpoints and : (1) compute absolute deltas and ; (2) determine step signs and (); (3) if (shallow slope ), step along by and conditionally step by ; and (4) if (steep slope ), swap the roles of and so the algorithm steps along by and conditionally steps by using decision parameter .
Worked Numerical Example (Steep Slope Bresenham): Plot the line from to . Here , . Since , we step along from 10 to 17. Initial , constants , . Plot . Step 0: , . Step 1: , . Step 2: , . Step 3: , . Step 4: , . Step 5: , . Step 6: .
5.2 Worked Numerical Example: Midpoint Ellipse Algorithm
Consider an ellipse centered at with and . Constants: , , , . Start in Region 1 at with and . Initial parameter :
- At : , , .
- At : , , .
- At : , , .
- At : , , , .
- At : , , .
- At : , , , .
- At : , , . Now , so Region 1 finishes and Region 2 begins at with . Stepping down from 3 to 0 yields , , and .
5.3 Scan-Line Seed Fill Optimization and Window-to-Viewport Numerical
Recursive 4-connected Boundary Fill pushes up to four stack frames per pixel, rapidly exhausting call-stack limits on regions. Scan-Line Seed Fill eliminates recursion explosion by popping one seed pixel from an explicit stack, filling the entire contiguous horizontal span from to between boundary pixels, and then scanning only the adjacent rows and to push the rightmost pixel of each unfilled sub-span onto the stack. This reduces stack memory by orders of magnitude.
Worked Numerical Example (Window-to-Viewport Mapping): Map point from World Window onto Device Viewport . Scale factors: , . Mapped coordinates: , . Because , proportions are preserved without distortion.
#include <graphics.h>
void plotEllipse4(int xc, int yc, int x, int y, int col) {
putpixel(xc + x, yc + y, col);
putpixel(xc - x, yc + y, col);
putpixel(xc + x, yc - y, col);
putpixel(xc - x, yc - y, col);
}
void midpointEllipse(int xc, int yc, int rx, int ry, int col) {
double rx2 = (double)rx * rx, ry2 = (double)ry * ry;
double x = 0, y = ry;
double dx = 0, dy = 2 * rx2 * y;
double p1 = ry2 - (rx2 * ry) + (0.25 * rx2);
while (dx < dy) {
plotEllipse4(xc, yc, (int)x, (int)y, col);
x++; dx += 2 * ry2;
if (p1 < 0) p1 += dx + ry2;
else { y--; dy -= 2 * rx2; p1 += dx - dy + ry2; }
}
double p2 = ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2;
while (y >= 0) {
plotEllipse4(xc, yc, (int)x, (int)y, col);
y--; dy -= 2 * rx2;
if (p2 > 0) p2 += rx2 - dy;
else { x++; dx += 2 * ry2; p2 += dx - dy + rx2; }
}
}Chapter 6: Mathematical Derivations and Complexity of Scan Conversion
6.1 Full Algebraic Derivation of Bresenham's Decision Parameter
To appreciate why Bresenham's algorithm requires zero floating-point operations, consider a line with slope passing through . At the next column , the exact continuous y-coordinate is . The vertical distance from the true line to the lower pixel is , while the distance to the upper pixel is . Subtracting these two distances yields:
Computing the difference between consecutive steps eliminates the constant entirely. Since always holds, if then so ; if then so . Evaluating at the starting endpoint where simplifies directly to .
6.2 Derivation of Midpoint Circle Decision Parameter
Given the implicit circle function , a point lies inside the circle if , on the boundary if , and outside if . Assuming pixel has been plotted in the first octant, we test the midpoint :
Expanding yields . When , this reduces to ; when , it reduces to . At the initial point , , which rounds cleanly to integer because all subsequent updates are integers.
6.3 Comparative Analysis of Line and Circle Rasterizers
| Algorithm | Arithmetic Type | Symmetry / Optimizations | Primary Strength & Limitation |
|---|---|---|---|
| Direct Line Equation | Floating-point multiply + add | None | Simple formula, but slow per-pixel multiplication and gaps on steep slopes |
| DDA Line | Floating-point add + round | Axis-dominant stepping | Avoids multiplication; rounding and cumulative floating-point drift remain |
| Bresenham Line | Pure integer add/subtract/shift | Exact integer decision variable | Fastest hardware-friendly line rasterizer with zero drift |
| Midpoint Circle | Pure integer add/subtract/shift | 8-way octant symmetry | Computes only 1/8 of the circle using purely incremental integer updates |
Chapter 7: Polygon Representation, Pattern Filling, and 8-Connected Lab
7.1 Polygon Data Structures: Vertex, Edge, and Surface Tables
Graphics engines store complex polygonal models using three linked geometric tables rather than duplicating shared vertex coordinates across adjacent faces. The Vertex Table stores each unique 3D or 2D coordinate once. The Edge Table defines each edge as a pair of pointers into the Vertex Table (e.g., ). The Polygon Surface Table defines each face as an ordered list of pointers into the Edge Table (e.g., ). This three-tier hierarchy saves memory, guarantees topological consistency when shared vertices move, and feeds directly into the Scan-Line Polygon Fill Sorted Edge Table.
7.2 Pattern Filling and Anchoring
Rather than filling a polygon with a solid uniform color, graphics systems often fill interiors using a repeating rectangular fill pattern (a bitmask or pixmap, such as hatching, brickwork, or stippling). During scan-line filling, the color assigned to interior pixel is indexed from the pattern matrix using modulo arithmetic: . Anchoring the pattern to world or screen origin ensures that moving an object does not cause its texture pattern to swim awkwardly.
7.3 8-Connected Boundary Fill vs. 4-Connected Diagonal Leakage
An 8-connected boundary fill checks all eight surrounding neighbors (horizontal, vertical, and four diagonals). While 8-connected fill successfully crosses narrow 1-pixel diagonal neck regions inside an irregular polygon that would block a 4-connected fill, it carries a well-known hazard: if the polygon's boundary itself is drawn as a thin 1-pixel diagonal line (where boundary pixels touch only corner-to-corner), an 8-connected fill will step diagonally straight across the boundary and leak out to color the entire screen. Consequently, thin-line boundaries require 4-connected fills, whereas thick boundaries permit 8-connected fills.
#include <graphics.h>
void boundaryFill8(int x, int y, int fillCol, int boundCol) {
int cur = getpixel(x, y);
if (cur != boundCol && cur != fillCol) {
putpixel(x, y, fillCol);
boundaryFill8(x + 1, y, fillCol, boundCol);
boundaryFill8(x - 1, y, fillCol, boundCol);
boundaryFill8(x, y + 1, fillCol, boundCol);
boundaryFill8(x, y - 1, fillCol, boundCol);
boundaryFill8(x + 1, y + 1, fillCol, boundCol);
boundaryFill8(x - 1, y + 1, fillCol, boundCol);
boundaryFill8(x + 1, y - 1, fillCol, boundCol);
boundaryFill8(x - 1, y - 1, fillCol, boundCol);
}
}
void bresenhamCircle(int xc, int yc, int r, int col) {
int x = 0, y = r, d = 3 - 2 * r;
while (x <= y) {
putpixel(xc+x, yc+y, col); putpixel(xc-x, yc+y, col);
putpixel(xc+x, yc-y, col); putpixel(xc-x, yc-y, col);
putpixel(xc+y, yc+x, col); putpixel(xc-y, yc+x, col);
putpixel(xc+y, yc-x, col); putpixel(xc-y, yc-x, col);
if (d < 0) d = d + 4 * x + 6;
else { d = d + 4 * (x - y) + 10; y--; }
x++;
}
}Chapter 8: Thick Lines, Line Styles, and Character Generation
8.1 Line Attributes: Width, Caps, Joins, and Dash Patterns
Beyond basic single-pixel rasterization, practical graphics packages support line attributes including line width, line style (solid, dashed, dotted, dash-dot), and pen/brush styles. Drawing a thick line of width requires careful geometry: for shallow lines (), plotting vertical pixels centered on each scan-converted pixel works well, whereas steep lines () require plotting horizontal pixels per row; otherwise, thick diagonal lines appear noticeably thinner than horizontal or vertical lines by a factor of .
Where thick line segments terminate or meet at polygon corners, graphics libraries apply line caps and line joins: (1) Butt Cap terminates squarely at the endpoint; (2) Round Cap appends a semicircular disk of diameter ; and (3) Projecting Square Cap extends past the endpoint by . At vertices, Miter Join extends outer edges to a sharp point, Round Join fills the corner with a circular arc, and Bevel Join flattens the corner with a straight segment. Line styles (dashed/dotted) are implemented using a repeating pixel bitmask (e.g., 1111000011110000) indexed by step counter .
8.2 Character Generation Methods: Bitmap vs. Stroke Fonts
Text primitives rendered onto a graphics viewport are stored using two principal representations:
- Bitmap (Raster) Fonts: Each character glyph is stored as a fixed rectangular grid of bits (e.g., or pixels). Bitmap fonts render at ultra-high speed via direct block bit-transfer (BitBLT), but enlarging or rotating them produces severe blocky staircase distortion.
- Outline / Stroke Fonts (Vector & TrueType): Each glyph is defined mathematically using straight line segments and quadratic/cubic Bezier curves. Because outlines transform cleanly under arbitrary affine scaling and rotation matrices before scan conversion, TrueType and OpenType fonts remain razor-sharp at any point size or display DPI.
Chapter 9: Scan-Line Polygon Fill Edge-Case Rules & Complete Lab
9.1 Handling Horizontal Edges, Local Extrema, and Shared Edges
When implementing Scan-Line Polygon Fill in production software, three subtle geometric edge cases must be handled rigorously to avoid missing pixels or parity inversion:
- Horizontal Edges: Edges where have infinite inverse slope and are excluded from the Sorted Edge Table; their horizontal span is already bounded by the endpoints of the two adjacent non-horizontal edges.
- Vertex Parity (Local Extremum vs. Monotonic): When a scan line passes directly through a polygon vertex, if both incident edges lie above (or both lie below) the scan line, the vertex is a local extremum and must be counted twice (even parity) so the interior span does not invert. Conversely, if one edge goes upward and the other goes downward (monotonic vertex), the upper edge's is shortened by 1 pixel so the vertex counts only once.
- Shared Edges Between Adjacent Polygons: To prevent double-blending or 1-pixel gaps along shared borders of adjacent triangles in a mesh, rasterizers apply the top-left fill convention: pixels falling exactly on left or top horizontal edges are included, while pixels on right or bottom edges are excluded.
#include <graphics.h>
void scanlineFillPoly(int n, int vx[], int vy[], int fillCol) {
int ymin = vy[0], ymax = vy[0];
for (int i = 1; i < n; i++) {
if (vy[i] < ymin) ymin = vy[i];
if (vy[i] > ymax) ymax = vy[i];
}
setcolor(fillCol);
for (int y = ymin; y <= ymax; y++) {
int xi[20], k = 0;
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
int y1 = vy[i], y2 = vy[j], x1 = vx[i], x2 = vx[j];
if ((y1 <= y && y2 > y) || (y2 <= y && y1 > y)) {
xi[k++] = x1 + (y - y1) * (x2 - x1) / (y2 - y1);
}
}
for (int a = 0; a < k - 1; a++) {
for (int b = a + 1; b < k; b++) {
if (xi[a] > xi[b]) { int t = xi[a]; xi[a] = xi[b]; xi[b] = t; }
}
}
for (int a = 0; a < k; a += 2) {
line(xi[a], y, xi[a + 1], y);
}
}
}Chapter 10: Coordinate Transformation Pipeline & Worked Examples
10.1 End-to-End Coordinate Mapping (MC to WC to NDC to DC)
In a structured graphics application, a 2D gear tooth defined in local Modelling Coordinates (MC) around is first placed into World Coordinates (WC) at using translation and rotation. Next, a rectangular World Window is mapped into Normalized Device Coordinates (NDC) , ensuring that all clipping and layout calculations remain independent of physical monitor dimensions. Finally, NDC coordinates are scaled to Device Coordinates (DC) on a display: and (inverting because screen raster rows increase downward from the top-left corner).
Chapter 11: Polynomial & Trigonometric Circle Scan Conversion
11.1 Direct Equation vs. Trigonometric vs. Midpoint Circle Comparison
Before Midpoint and Bresenham integer circle algorithms were invented, circles were plotted using either the explicit Cartesian equation or polar parametric coordinates . The direct square-root method suffers from severe pixel spacing gaps near where the slope approaches infinity, and requires costly floating-point square roots at every column. The polar trigonometric method produces uniform pixel spacing when , but demands expensive cos() and sin() evaluations per pixel. By contrast, Midpoint Circle exploits 8-way symmetry and integer addition alone.
Chapter 12: Anti-Aliased Bresenham & Supersampling Grid Trace
12.1 Xiaolin Wu's Line Algorithm and Sub-Pixel Coverage
While Bresenham's algorithm selects a single binary pixel per column, Xiaolin Wu's algorithm draws anti-aliased lines by plotting pairs of vertically adjacent pixels at each column : the lower pixel receives intensity and the upper pixel receives intensity , where . Because the two intensities always sum to 1.0, the perceived line center tracks the exact continuous line smoothly without staircase jaggies.
Chapter 13: Boundary-Fill Stack Optimization & Span Coherence
13.1 Iterative Explicit-Stack Flood Fill in C
Recursive flood fill and boundary fill routines risk stack overflow when filling large polygons on high-resolution displays (e.g., pixels). Production rasterizers replace call-stack recursion with an explicit heap-allocated coordinate stack or queue (Breadth-First Search), bounding memory usage predictably and avoiding segmentation faults during complex region fills.
Chapter 14: Output Primitives Summary & Algorithmic Complexity
14.1 Time and Space Complexity of Scan-Conversion Algorithms
| Primitive / Operation | Time Complexity | Space Complexity |
|---|---|---|
| DDA & Bresenham Line | ||
| Midpoint Circle | ||
| Scan-Line Polygon Fill | ( edges, pixels) | ( scan lines) |
14.2 Explicit-Stack 4-Connected Flood Fill in C (graphics.h)
To prevent call-stack overflow on large high-resolution polygons, the following C implementation replaces recursion with an explicit fixed-capacity coordinate stack, safely filling regions up to full VGA screen dimensions.
#include <graphics.h>
#define MAXSTACK 65536
typedef struct { int x, y; } PixelPt;
static PixelPt stk[MAXSTACK];
void floodFillIterative(int sx, int sy, int oldCol, int newCol) {
if (oldCol == newCol || getpixel(sx, sy) != oldCol) return;
int top = 0;
stk[top++] = (PixelPt){sx, sy};
while (top > 0) {
PixelPt p = stk[--top];
if (getpixel(p.x, p.y) == oldCol) {
putpixel(p.x, p.y, newCol);
if (top + 4 < MAXSTACK) {
stk[top++] = (PixelPt){p.x + 1, p.y};
stk[top++] = (PixelPt){p.x - 1, p.y};
stk[top++] = (PixelPt){p.x, p.y + 1};
stk[top++] = (PixelPt){p.x, p.y - 1};
}
}
}
}14.3 Worked Numerical Example: Bresenham Negative-Slope Line
Plot a line from to where and (negative shallow slope ). Using absolute magnitudes , with and , initial decision parameter . Step 0: , . Step 1: , . Step 2: , . Step 3: , . Step 4: , . Step 5: .
Chapter 15: Filled-Area Primitives & Soft-Fill Anti-Aliasing
15.1 Soft-Fill and Tint-Fill Blending for Anti-Aliased Boundaries
When filling an anti-aliased polygon whose boundary pixels already blend foreground and background colors, standard Boundary Fill stops prematurely or creates harsh jagged halos around the border. Soft-Fill (Tint-Fill) algorithms compute the fractional foreground-to-background mix at each boundary pixel and re-blend the new fill color proportionally: , preserving smooth anti-aliased edges seamlessly after region filling.
15.2 Practical Considerations for Raster Output Primitives
In real-world graphics software, scan-conversion routines must also address integer overflow, endpoint order invariance, and clipping integration. When implementing Bresenham's algorithm or Midpoint Circle in C or C++, multiplying large screen coordinates inside ellipse or circle equations (such as ) can exceed 16-bit or 32-bit signed integer limits; therefore, production code promotes intermediate squared terms to 64-bit integers (long long) or double-precision floats. Furthermore, drawing a line from A to B should illuminate the exact same set of pixels as drawing from B to A—a property called endpoint order invariance, which requires consistent tie-breaking whenever the decision parameter equals zero.
Finally, scan-converting primitives that extend outside the frame buffer boundaries without clipping causes illegal memory writes or visual wrap-around. High-performance graphics drivers combine analytical clipping (removing off-screen segments before rasterization) with hardware scissoring (rejecting out-of-bounds pixel writes at the frame buffer controller) to guarantee both memory safety and deterministic rendering speed across arbitrary window sizes and zoom levels.
Chapter 16: Worked Review of Output Primitive Calculations
16.1 Comparing DDA and Bresenham on a 45-Degree Diagonal
Consider digitizing the unit-slope diagonal from to , where and . In DDA, , , and , stepping cleanly through . In Bresenham's algorithm, , and at every step , so and both increment at every iteration, producing the exact same optimal diagonal pixels using pure integer addition.
16.2 Circle Circumference Pixel Count Estimation
In the Midpoint Circle Algorithm, the first octant steps from to . Because each step plots 8 symmetric pixels across all eight octants, the total number of pixels plotted for a circle of radius is approximately (accounting for slight overlap at the 45-degree octant boundaries and cardinal axes). For example, a circle of radius illuminates roughly 566 pixels in total, demonstrating why its time complexity scales strictly linearly as .
16.3 Worked Numerical: Midpoint Ellipse Algorithm (Region 1 and Region 2)
Digitize the first quadrant of an ellipse centered at the origin with semi-major axis and semi-minor axis . Compute the squared constants , , , and . Starting at , the initial incremental slope terms are and .
In Region 1 (where ), the initial decision parameter is . Stepping by 1 at each iteration until yields the following integer coordinates:
| Step | Plotted Pixel | |||
|---|---|---|---|---|
| 0 | -332 | (1, 6) | 72 | 768 |
| 1 | -224 | (2, 6) | 144 | 768 |
| 2 | -44 | (3, 6) | 216 | 768 |
| 3 | 208 | (4, 5) | 288 | 640 |
| 4 | -108 | (5, 5) | 360 | 640 |
| 5 | 288 | (6, 4) | 432 | 512 |
| 6 | 244 | (7, 3) | 504 | 384 |
At step 6, , signaling the transition to Region 2 from the last plotted point . The initial Region 2 decision parameter is evaluated at the midpoint :
In Region 2, decrements by 1 at each step until . For , , so increments to 8 and decrements to 2, plotting with . Next, since , remains 8 and decrements to 1, plotting with . Finally, plots , completing the first quadrant. Four-way symmetry then reflects every point to , , and .
Chapter 17: Scan-Line Active Edge Table Trace & Rasterization Summary
17.1 Step-by-Step Scan-Line Polygon Fill: Edge Table and Active Edge Table
Consider a triangle with vertices , , and . Horizontal edge lies entirely on scan line and is omitted from the global Edge Table (ET) because horizontal edges do not cross scan-line intervals. The two non-horizontal edges are (from to ) and (from to ).
For edge , , , , and inverse slope . For edge , , , , and inverse slope . Both edges are inserted into bucket of the Edge Table, sorted by ascending initial .
| Scan Line | Active Edge Table (AET) Entries | Filled Horizontal Pixel Span |
|---|---|---|
| 2 | AC: (2.00, +0.75, 6), BC: (8.00, -0.75, 6) | |
| 3 | AC: (2.75, +0.75, 6), BC: (7.25, -0.75, 6) | |
| 4 | AC: (3.50, +0.75, 6), BC: (6.50, -0.75, 6) | |
| 5 | AC: (4.25, +0.75, 6), BC: (5.75, -0.75, 6) | |
| 6 | Both edges reach and are removed | Vertex (5, 6) |
Because each scan line simply adds to the previous intersection rather than solving line equations from scratch, the Active Edge Table exploits scan-line coherence and edge coherence to fill arbitrary concave polygons in linear time relative to the total number of interior pixels.
17.2 Comprehensive Output Primitives Comparison Matrix
The table below summarizes the core rasterization and region-filling algorithms studied in Module 2, contrasting their arithmetic requirements, asymptotic complexity, and practical trade-offs in graphics hardware and software.
| Algorithm | Arithmetic Type | Time Complexity | Key Advantage & Limitation |
|---|---|---|---|
| DDA Line | Floating-point addition and rounding | Simple to implement; floating-point drift over long lines | |
| Bresenham Line | Pure integer addition and bit-shift | Exact, hardware-friendly, zero floating-point operations | |
| Midpoint Circle | Integer addition using 8-way symmetry | Computes only 1 octant; requires 8-way pixel plotting | |
| Midpoint Ellipse | Integer/fixed-point across 2 regions | Handles unequal axes; requires Region 1 to Region 2 switch | |
| Scan-Line Polygon Fill | Incremental edge stepping | Works on concave/self-intersecting polygons without stack overflow | |
| Boundary / Flood Fill | Recursive or explicit stack traversal | Simple for irregular regions; high stack memory on large areas |
Module III: Two Dimensional Transformations and Clipping
Chapter 1: Basic 2D Transformations and Homogeneous Coordinates
1.1 Translation, Rotation, and Scaling
Geometric transformations alter the position, orientation, size, or shape of graphical objects in 2D space by applying mathematical operations to their defining vertex coordinates . Once the vertices of a polygon or polyline are transformed, the object is redrawn by connecting the newly computed vertices.
- Translation: Rigidly shifts every point of an object by a translation vector without changing its size or orientation: and .
- Rotation (about Origin): Rotates every point counter-clockwise through an angle around the coordinate origin : and . Clockwise rotation uses negative .
- Scaling (about Origin): Resizes an object along the coordinate axes using scaling factors : and . When , scaling is uniform (preserving proportions); when , differential scaling distorts proportions. Values greater than 1 enlarge the object, whereas values between 0 and 1 shrink it.
1.2 Homogeneous Coordinates and Uniform Matrix Representation
In standard 2D Cartesian coordinates, rotation and scaling are multiplicative operations (), whereas translation is an additive operation (). Treating translation differently prevents chaining a sequence of translations, rotations, and scalings into a single matrix multiplication. Homogeneous coordinates resolve this asymmetry by embedding 2D points into a 3-element column vector where and for . Setting represents any 2D point as , allowing all affine transformations to be expressed uniformly as matrix multiplications:
1.3 Composite Transformations and Concatenation
When multiple transformations are applied sequentially to an object containing thousands of vertices, computing each step individually is inefficient. Because matrix multiplication is associative, individual transformation matrices can be pre-multiplied (concatenated) into a single composite matrix , and then is applied once per vertex. Note that matrix multiplication is not commutative (): transformations applied first appear on the right nearest the column vector .
Chapter 2: Reflection, Shearing, and Arbitrary-Point Transformations
2.1 Reflection and Shearing Matrices
Reflection produces a mirror image of an object across a specified axis (equivalent to a 180-degree rotation in 3D space about that axis). Common 2D reflections include reflection about the x-axis (), y-axis (), origin (), and the diagonal line (swapping and ).
Shearing slants the shape of an object proportionally along one coordinate axis based on the other coordinate, transforming rectangles into parallelograms. An x-direction shear with factor maps ; a y-direction shear with factor maps .
2.2 Transformations Relative to Arbitrary Points and Lines
To rotate or scale an object about an arbitrary pivot point rather than the origin, we compose three steps: (1) translate the pivot to the origin via , (2) perform the rotation or scaling at the origin, and (3) translate the pivot back via :
Worked Numerical Example (Composite Pivot Rotation): Rotate vertex by counter-clockwise about pivot . Since and : Step 1 translates by to . Step 2 rotates by to . Step 3 translates back by to yield . Using the composite matrix directly: , and .
Chapter 3: 2D Viewing Pipeline and Clipping Algorithms
3.1 Clip Window and Point Clipping
A 2D scene defined in World Coordinates is viewed through a rectangular clip window bounded by . Any geometric primitive—or portion of a primitive—lying outside the clip window must be discarded before scan conversion, a process called clipping. For a point , point clipping simply tests four inequalities: and . If all four inequalities hold, the point is retained; otherwise, it is rejected.
3.2 Cohen-Sutherland Line Clipping Algorithm
The Cohen-Sutherland algorithm accelerates line clipping by assigning a 4-bit region code (outcode) to each endpoint of a line segment based on its position relative to the four extended edges of the clip window (Top, Bottom, Right, Left = TBRL):
| Bit Position (TBRL) | Bit 3 (Top) | Bit 2 (Bottom) | Bit 1 (Right) | Bit 0 (Left) |
|---|---|---|---|---|
| Condition for Bit = 1 |
The interior clip window has outcode . Given endpoints and with outcodes and :
- Trivial Accept: If , both endpoints lie inside the window; accept the entire line immediately.
- Trivial Reject: If , both endpoints share at least one outside region (for example, both above ); reject the entire line immediately.
- Subdivision at Window Boundary: Otherwise, pick an endpoint with a non-zero outcode, locate a set bit (say Left, ), compute the intersection (or for horizontal edges), replace the outside endpoint with the intersection point, recompute its 4-bit outcode, and repeat.
Worked Numerical Example (Cohen-Sutherland): Let the clip window be , and clip the line from to . Outcode for : sets Left bit, so . Outcode for : sets Top bit, so . Bitwise OR (not trivial accept); bitwise AND (not trivial reject). Slope . Clip against Left boundary : , so with outcode . Next, clip against Top boundary : , so with outcode . Both outcodes are now , so the clipped segment to is trivially accepted.
3.3 Midpoint Subdivision Line Clipping Algorithm
The Midpoint Subdivision algorithm is a variation of Cohen-Sutherland that avoids floating-point division when computing boundary intersections, making it well suited for hardware implementation using integer bit-shifts. It uses the same 4-bit outcodes for trivial acceptance () and trivial rejection (). When a line cannot be trivially decided, it splits the segment at its midpoint using right-shift by 1, forming two sub-segments and . Each half is recursively tested until the sub-segments either become trivially accepted/rejected or converge to a single pixel on the clip boundary.
Worked Numerical Example (Midpoint Subdivision): Given clip window , clip segment to . Outcode (Left), (Inside). Not trivial: compute midpoint with outcode . Segment from to has and is trivially accepted. Subdivide from to : midpoint has outcode right on the Left boundary . Thus from to is accepted, and is rejected outside , yielding the exact clipped segment to .
Chapter 4: Inverse Matrices, Polygon Clipping, and C Lab Programs
4.1 Inverse 2D Transformations and Rigid-Body Properties
Every basic 2D affine transformation admits an exact algebraic inverse that restores transformed coordinates back to their original positions: (1) Inverse Translation shifts by negated offsets ; (2) Inverse Rotation rotates by negated angle because rotation matrices are orthogonal; and (3) Inverse Scaling scales by reciprocal factors provided . Translations and rotations are rigid-body transformations (preserving Euclidean distances and angles), whereas scaling and shearing alter lengths or angles.
4.2 Worked Composite Example: Triangle Transformation and Arbitrary Line Reflection
Triangle Composite Transformation: Consider triangle . Scale it uniformly by about fixed point , then translate by . The composite matrix is :
Reflection about Arbitrary Line : Here slope () and y-intercept . The five-step reflection sequence simplifies cleanly: since , the composite matrix maps to . Testing point : .
4.3 Liang-Barsky Line Clipping and Sutherland-Hodgman Polygon Clipping
While Cohen-Sutherland clips lines iteratively in Cartesian coordinates, the Liang-Barsky algorithm represents a line parametrically as , for , solving four linear inequalities directly to find entering () and exiting () parameter bounds in a single pass. For clipping closed polygons without breaking them into disconnected open line segments, the Sutherland-Hodgman Polygon Clipping algorithm passes the polygon vertex list sequentially through four independent boundary clippers (Left, Right, Bottom, Top). Each clipper inspects every edge against four cases: (1) Inside-to-Inside outputs ; (2) Inside-to-Outside outputs intersection ; (3) Outside-to-Outside outputs nothing; and (4) Outside-to-Inside outputs both and .
#include <graphics.h>
const int INSIDE = 0, LEFT = 1, RIGHT = 2, BOTTOM = 4, TOP = 8;
int xmin = 100, ymin = 100, xmax = 400, ymax = 300;
int computeCode(double x, double y) {
int code = INSIDE;
if (x < xmin) code |= LEFT;
else if (x > xmax) code |= RIGHT;
if (y < ymin) code |= BOTTOM;
else if (y > ymax) code |= TOP;
return code;
}
void cohenSutherlandClip(double x1, double y1, double x2, double y2) {
int c1 = computeCode(x1, y1), c2 = computeCode(x2, y2);
int accept = 0;
while (1) {
if ((c1 == 0) && (c2 == 0)) { accept = 1; break; }
else if (c1 & c2) { break; }
else {
double x = 0, y = 0;
int out = c1 ? c1 : c2;
if (out & TOP) { x = x1 + (x2 - x1) * (ymax - y1) / (y2 - y1); y = ymax; }
else if (out & BOTTOM) { x = x1 + (x2 - x1) * (ymin - y1) / (y2 - y1); y = ymin; }
else if (out & RIGHT) { y = y1 + (y2 - y1) * (xmax - x1) / (x2 - x1); x = xmax; }
else if (out & LEFT) { y = y1 + (y2 - y1) * (xmin - x1) / (x2 - x1); x = xmin; }
if (out == c1) { x1 = x; y1 = y; c1 = computeCode(x1, y1); }
else { x2 = x; y2 = y; c2 = computeCode(x2, y2); }
}
}
if (accept) { setcolor(GREEN); line((int)x1, (int)y1, (int)x2, (int)y2); }
}Chapter 5: Reference-Line Shearing, Window-to-Viewport Matrix & Clipping Traces
5.1 Shearing Relative to Arbitrary Reference Lines
Standard x-shear leaves the line fixed, while standard y-shear leaves fixed. When an object must be sheared relative to an arbitrary horizontal reference line or vertical reference line , we compose translation and shear matrices:
Worked Numerical Example (Reference-Line Shear): Shear the unit square horizontally by relative to . Using : vertices on stay fixed at and ; top vertices at shift right by to and .
5.2 Homogeneous Window-to-Viewport Transformation Matrix
The entire 2D viewing transformation—mapping World Window to Viewport —can be expressed as a single matrix concatenation . Furthermore, if the world window is rotated at an angle (representing a tilted 2D camera), we prepend around the window origin before scaling into Normalized Device Coordinates.
5.3 Worked Numerical Example: Liang-Barsky Line Clipping
Clip line to against window . Here , . Compute and :
- Left (): , . Since , entering ratio .
- Right (): , . Since , exiting ratio .
- Bottom (): , . Since , exiting ratio .
- Top (): , . Since , entering ratio .
Taking and : since , the clipped endpoints are and .
5.4 Sutherland-Hodgman Polygon Clipping Pipeline
When clipping a closed triangle against window , the Left Clipper () processes edges [Out-to-In: outputs and ], [In-to-In: outputs ], and [In-to-Out: outputs ]. The resulting 4-vertex polygon is passed to the Right Clipper, Bottom Clipper, and Top Clipper (), which clips cleanly into a closed 5-vertex clipped polygon ready for scan-line filling.
Chapter 6: Affine Invariants, Concatenation Efficiency & Matrix Proofs
6.1 Mathematical Properties of 2D Affine Transformations
Every transformation representable by a homogeneous matrix whose bottom row is is an affine transformation of the form . Affine transformations obey four foundational geometric invariants: (1) Collinearity: three points lying on a straight line remain collinear after transformation; (2) Parallelism: parallel lines remain parallel, so parallelograms map to parallelograms; (3) Ratio of Distances along a Line: midpoints map to midpoints, enabling us to transform just the endpoints of a line segment or control points of a Bezier curve rather than every rasterized pixel; and (4) Area Scaling: the area of any transformed polygon scales by the absolute determinant . For rigid-body transformations (translation and rotation), ; for pure reflections, , reversing vertex winding order from counter-clockwise to clockwise.
6.2 Computational Cost of Matrix Concatenation
Suppose a CAD drawing contains vertices and requires a sequence of 4 transformations: translate to origin, rotate by , scale by , and translate back. Applying each matrix separately to every vertex requires matrix-vector multiplications. By pre-multiplying the four matrices once into a single composite matrix (only 3 matrix-matrix multiplications) and then multiplying against each vertex, total work drops to operations—nearly a 4x speedup.
6.3 Worked Numerical Example: Arbitrary-Point Scaling & Shearing
Consider a rectangle with vertices . Scale it by about its center , and then apply an x-shear of relative to . First, scaling about maps and : , , , . Next, x-shear relative to adds to : , , , .
Chapter 7: Advanced Clipping: Text, Curves, NLN, and Exterior Clipping
7.1 Nicholl-Lee-Nicholl (NLN) and Exterior Clipping
While Cohen-Sutherland may clip a single line segment against up to four boundaries iteratively before accepting or rejecting it, the Nicholl-Lee-Nicholl (NLN) algorithm divides the 2D plane around the clip window into specialized directional regions based on the location of the first endpoint . By testing the slope of against rays drawn from to the four corners of the clip window, NLN determines immediately which exact boundary edges are intersected, avoiding redundant intersection calculations. In contrast, Exterior Clipping retains the portions of primitives lying outside a clip region and discards the interior—essential when rendering overlapping desktop windows where a foreground window occludes background windows.
7.2 Text Clipping and Curve Clipping Strategies
Text strings rendered inside viewports require specialized clipping strategies depending on whether characters are stroke-based (vector) or bitmap-based (raster):
- All-or-None String Clipping: The fastest method surrounds the entire text string with a single bounding box. If the bounding box lies completely inside the clip window, the entire string is drawn; if any edge crosses outside, the entire string is discarded.
- All-or-None Character Clipping: Each individual character's bounding box is tested against the clip window. Characters wholly inside are drawn; characters touching or outside the boundary are dropped cleanly without half-sliced letters.
- Component / Bitmap Character Clipping: Individual stroke segments of vector fonts or individual pixels of bitmap glyphs are clipped directly against the window edges, allowing partial characters to appear at window borders.
For Curve Clipping (circles, ellipses, splines), analytical intersection with rectangular edges can be costly. Graphics systems first test the curve's axis-aligned bounding box against the clip window for trivial acceptance or rejection; only when the bounding box straddles a window edge are scan-converted pixels or subdivided Bezier segments clipped individually.
Chapter 8: Complete C Lab Programs: 2D Transformations & Midpoint Subdivision
#include <graphics.h>
#include <math.h>
int xmin = 120, ymin = 120, xmax = 420, ymax = 320;
int outcode(double x, double y) {
int c = 0;
if (x < xmin) c |= 1; else if (x > xmax) c |= 2;
if (y < ymin) c |= 4; else if (y > ymax) c |= 8;
return c;
}
void midpointClip(double x1, double y1, double x2, double y2) {
int c1 = outcode(x1, y1), c2 = outcode(x2, y2);
if ((c1 | c2) == 0) {
setcolor(LIGHTGREEN);
line((int)(x1 + 0.5), (int)(y1 + 0.5), (int)(x2 + 0.5), (int)(y2 + 0.5));
return;
}
if ((c1 & c2) != 0) return;
if (fabs(x2 - x1) < 1.0 && fabs(y2 - y1) < 1.0) return;
double mx = (x1 + x2) * 0.5, my = (y1 + y2) * 0.5;
midpointClip(x1, y1, mx, my);
midpointClip(mx, my, x2, y2);
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
setcolor(WHITE);
rectangle(xmin, ymin, xmax, ymax);
setcolor(DARKGRAY);
line(60, 80, 480, 360);
midpointClip(60, 80, 480, 360);
getch();
closegraph();
return 0;
}#include <graphics.h>
void drawQuad(int x[4], int y[4], int col) {
setcolor(col);
for (int i = 0; i < 4; i++)
line(x[i], y[i], x[(i+1)%4], y[(i+1)%4]);
}
int main() {
int gd = DETECT, gm;
int x[4] = {100, 180, 180, 100}, y[4] = {100, 100, 160, 160};
int sx[4], sy[4], rx[4], ry[4];
initgraph(&gd, &gm, "");
drawQuad(x, y, WHITE);
/* X-Shear relative to y_ref = 100 with shx = 0.8 */
for (int i = 0; i < 4; i++) {
sx[i] = x[i] + (int)(0.8 * (y[i] - 100));
sy[i] = y[i];
}
drawQuad(sx, sy, YELLOW);
/* Reflection across vertical axis x = 320 */
for (int i = 0; i < 4; i++) {
rx[i] = 320 + (320 - x[i]);
ry[i] = y[i];
}
drawQuad(rx, ry, LIGHTCYAN);
getch();
closegraph();
return 0;
}Chapter 9: 2D Transformation Matrix Reference & Worked Multi-Step Trace
9.1 Complete 2D Homogeneous Matrix Reference Table
| Transformation | Homogeneous Matrix | Algebraic Mapping |
|---|---|---|
| Translation | ||
| Rotation (CCW) | ||
| Scaling | ||
| Reflection (y-axis) | ||
| X-Shear |
9.2 Worked Numerical Example: Multi-Step Reflection & Rotation
Reflect point across the line , then rotate the result by counter-clockwise about the origin. Reflection across swaps and negates both coordinates: , , yielding . Applying maps , yielding . Notice that multiplying the two matrices directly——produces , which is identical to reflection across the x-axis: !
Chapter 10: Complete C Lab Program: Sutherland-Hodgman Polygon Clipping
The following C program implements the 4-stage Sutherland-Hodgman polygon clipping pipeline against a rectangular clip window using graphics.h.
#include <graphics.h>
typedef struct { float x, y; } Pt;
int xmin = 150, ymin = 150, xmax = 450, ymax = 350;
int inside(Pt p, int edge) {
if (edge == 0) return p.x >= xmin;
if (edge == 1) return p.x <= xmax;
if (edge == 2) return p.y >= ymin;
return p.y <= ymax;
}
Pt intersect(Pt a, Pt b, int edge) {
Pt res;
float m = (b.x != a.x) ? (b.y - a.y) / (b.x - a.x) : 1e9;
if (edge == 0) { res.x = xmin; res.y = a.y + m * (xmin - a.x); }
else if (edge == 1) { res.x = xmax; res.y = a.y + m * (xmax - a.x); }
else if (edge == 2) { res.y = ymin; res.x = (b.x != a.x) ? a.x + (ymin - a.y) / m : a.x; }
else { res.y = ymax; res.x = (b.x != a.x) ? a.x + (ymax - a.y) / m : a.x; }
return res;
}
int clipEdge(Pt in[], int n, Pt out[], int edge) {
int cnt = 0;
Pt s = in[n - 1];
for (int i = 0; i < n; i++) {
Pt p = in[i];
if (inside(p, edge)) {
if (!inside(s, edge)) out[cnt++] = intersect(s, p, edge);
out[cnt++] = p;
} else if (inside(s, edge)) {
out[cnt++] = intersect(s, p, edge);
}
s = p;
}
return cnt;
}Chapter 11: Worked Numericals: Arbitrary Line Reflection & Pivot Scaling
11.1 Step-by-Step Matrix Multiplication for Pivot Scaling
Scale triangle by about fixed point . Form the composite matrix :
Chapter 12: 2D Clipping Algorithm Comparison & Complexity
12.1 Comparative Summary of 2D Line and Polygon Clippers
| Clipping Algorithm | Target Primitive | Core Technique | Primary Advantage |
|---|---|---|---|
| Cohen-Sutherland | Line segments | 4-bit TBRL outcodes + iterative intersection | Ultra-fast trivial accept/reject via bitwise AND/OR |
| Midpoint Subdivision | Line segments | 4-bit outcodes + binary midpoint bisection | Zero floating-point division; hardware shift-friendly |
| Liang-Barsky | Line segments | Parametric inequality bounds | Computes final clipped endpoints in a single pass |
| Sutherland-Hodgman | Polygons | 4-stage re-entrant boundary clipper pipeline | Preserves closed polygon topology for scan-line filling |
Chapter 13: Weiler-Atherton Concave Polygon Clipping
13.1 Handling Concave Polygons Without Degenerate Edges
While Sutherland-Hodgman outputs a single vertex list that can introduce unwanted degenerate connecting lines when clipping concave polygons with multiple disjoint interior regions, the Weiler-Atherton algorithm traces clockwise around both the subject polygon and the clip window. At an entering intersection it follows the subject boundary; at an exiting intersection it turns right onto the clip window boundary, cleanly splitting concave shapes into separate closed polygons.
13.2 Worked Numerical Example: 2D Window-to-Viewport Composite Matrix
Construct the single matrix mapping World Window onto Viewport . Here and . Concatenating yields:
Chapter 14: 2D Transformation Hierarchy & Scene Graphs
14.1 Hierarchical Articulated Models Using Matrix Stacks
Complex 2D objects such as robotic arms, clockwork mechanisms, and skeletal characters consist of parent-child hierarchies where child parts inherit the transformations of their parents. Graphics engines manage hierarchical transforms using a Matrix Stack (pushMatrix() / popMatrix()): the upper arm transformation is pushed onto the stack, multiplied by the forearm rotation around the elbow joint, and then popped cleanly before rendering independent limbs.
14.2 Floating-Point Precision and Matrix Re-Orthogonalization
In interactive 2D simulations and games where an object is rotated incrementally frame after frame by multiplying its current transformation matrix by a small rotation increment , tiny IEEE-754 floating-point rounding errors accumulate over thousands of frames. Gradually, the upper-left rotation block drifts away from true orthogonality, causing the object to subtly skew or shrink. To prevent cumulative drift, graphics engines either store the object's cumulative angle as a scalar and rebuild cleanly each frame, or periodically re-orthogonalize the basis vectors using Gram-Schmidt normalization.
Similarly, when clipping lines with steep or nearly vertical slopes in Cohen-Sutherland, dividing by when produces a division-by-zero error. Robust implementations guard horizontal and vertical edges explicitly—checking bitmasks before division—so vertical lines clip against Top and Bottom boundaries directly using without ever evaluating slope .
Module IV: 3D Concepts and Techniques
Chapter 1: 3D Display Techniques, Object Representations, and Transformations
1.1 3D Display Techniques and Object Representations
Three-dimensional computer graphics extends spatial modeling into depth (-axis), typically using a right-handed coordinate system where points right, points up, and points toward the viewer. Representing 3D objects in memory balances geometric precision against rendering speed:
- Polygon Meshes (Boundary Representation / B-Rep): Surfaces are approximated by interconnected planar polygons—most commonly triangle meshes—stored via vertex lists, edge lists, and face tables. GPUs are hardware-optimized to rasterize triangle meshes at millions of triangles per second.
- Wireframe Models: Objects are represented purely by vertices and connecting edges without surface faces. Wireframes are fast to compute and ideal for structural CAD inspection, though ambiguous without hidden-line removal.
- Constructive Solid Geometry (CSG): Complex solids are constructed by combining simple volumetric primitives (cubes, spheres, cylinders, cones) using Boolean set operations: Union (), Intersection (), and Difference ().
- Spatial Partitioning (Octrees & Voxels): Space is subdivided hierarchically into 8 octants (Octree) or uniform 3D grid cells (Voxels), widely used in medical CT/MRI volume rendering and terrain engines.
- Sweep & Parametric Representations: Translational or rotational sweeps extrude a 2D cross-section along a path or around an axis, while Bezier and B-Spline surfaces represent smooth curved shells mathematically.
1.2 Basic 3D Homogeneous Transformations
In 3D homogeneous coordinates, a point is represented as a 4-element column vector , and all affine transformations are matrices. Translation shifts by ; scaling scales by ; and 3D rotation occurs independently about each principal axis () following the right-hand rule:
Rotating around an arbitrary 3D axis defined by point and direction vector requires five concatenated matrices: translate to the origin, apply two rotations ( and ) to align with the z-axis, execute , and invert the alignment rotations and translation.
Chapter 2: 3D Projections (Parallel and Perspective)
2.1 Parallel Projections (Orthographic and Oblique)
A projection maps 3D scene coordinates onto a 2D view plane along projection lines called projectors. In parallel projection, the center of projection is at infinity, so all projectors are mutually parallel. Parallel projections preserve true relative proportions and parallel lines, making them essential for architectural and engineering blueprints, though they lack realistic depth foreshortening.
- Orthographic Parallel Projection: Projectors are perpendicular to the view plane. Multi-view orthographic projections (front, top, side elevations) align the view plane with principal axes—for example, projecting onto simply drops the coordinate (). Axonometric orthographic projections (isometric, dimetric, trimetric) tilt the view plane relative to all three principal axes so three faces of a cube are visible simultaneously; in isometric projection, all three axes are foreshortened equally.
- Oblique Parallel Projection: Projectors strike the view plane at an oblique angle , revealing front faces in true shape while showing depth along receding edges angled at . In Cavalier projection, so receding depth edges are drawn at full scale (). In Cabinet projection, () so receding depth edges are drawn at half scale (), appearing far more natural to the eye.
2.2 Perspective Projection and Vanishing Points
In perspective projection, projectors converge toward a finite Center of Projection (COP) (the viewer's eye). Consequently, distant objects appear smaller than nearby objects of identical size (foreshortening), and sets of parallel lines not parallel to the view plane appear to converge at vanishing points. Perspective projections are classified as one-point, two-point, or three-point depending on how many principal coordinate axes intersect the view plane. Placing the COP at the origin looking along with the view plane at , a 3D point projects via similar triangles to:
Worked Numerical Example (Perspective Projection): Project point onto a view plane at with COP at origin: , . A point twice as far away at projects to , demonstrating perspective foreshortening.
Chapter 3: Visible Surface Detection (Hidden Surface Removal)
3.1 Object-Space vs. Image-Space Methods
When rendering opaque 3D objects, surfaces closer to the camera obscure surfaces behind them. Visible surface detection algorithms are divided into object-space methods (comparing geometric surfaces directly in 3D precision, such as depth sorting) and image-space methods (resolving visibility pixel-by-pixel at screen resolution, such as Z-buffer, A-buffer, and scan-line).
3.2 Z-Buffer (Depth Buffer) and A-Buffer Algorithms
The Z-Buffer algorithm is the dominant hardware-accelerated visibility method in modern GPUs. Alongside the RGB frame buffer, it allocates a second array called the depth buffer (z-buffer) initialized to the maximum far-plane depth (). As each polygon is rasterized pixel by pixel, its interpolated depth is compared against . If (assuming smaller is closer to the camera), the pixel is visible: is updated to and the frame buffer is updated with the polygon's shaded color. Because polygons can be processed in any arbitrary order, Z-buffer handles intersecting and cyclic surfaces effortlessly, though it requires extra memory and only stores one surface per pixel—preventing native anti-aliasing or transparency.
The A-Buffer (Accumulation Buffer) extends the Z-buffer to support transparency and anti-aliasing. Each pixel entry in the A-buffer stores a linked list of surface fragments rather than a single depth value. Each fragment records RGB intensity, opacity (), depth, percent area coverage, and surface normal. After all polygons are submitted, the linked list at each pixel is sorted front-to-back and composited using alpha blending and sub-pixel coverage masks.
3.3 Scan-Line Method and Depth Sorting (Painter's Algorithm)
The Scan-Line visibility method extends the 2D scan-line polygon fill across multiple 3D polygons simultaneously. It maintains an Active Edge Table (AET) and an Active Surface Table (AST) for the current scan line . Between any two consecutive edge intersections along the scan line, the algorithm evaluates depth planes of all active surfaces to determine which single surface is closest, painting the entire horizontal span with that surface's color without needing a full-screen Z-buffer.
Depth Sorting (Painter's Algorithm) combines object-space sorting with image-space scan conversion: (1) sort all polygons in descending order of their farthest -coordinate; (2) resolve any depth-overlap ambiguities—checking bounding-box overlap, plane tests, and splitting cyclic or intersecting polygons if needed; and (3) render polygons strictly from back to front so nearer surfaces overwrite farther ones in the frame buffer.
| Visibility Algorithm | Domain | Handles Intersecting Surfaces? | Key Advantage & Tradeoff |
|---|---|---|---|
| Z-Buffer | Image Space | Yes, natively | Order-independent and GPU-native; requires extra depth memory |
| A-Buffer | Image Space | Yes, natively | Supports anti-aliasing and transparency; variable per-pixel memory |
| Scan-Line | Image Space | No (requires splitting) | Avoids full Z-buffer memory; complex edge-surface coherence |
| Depth Sorting | Hybrid (Object + Image) | No (must split polygons) | Simple back-to-front painting; struggles with cyclic overlaps |
Chapter 4: Detailed 3D Matrices, Back-Face Culling, and Worked Numericals
4.1 Complete 3D Rotation, Reflection, and Shearing Matrices
In addition to , rotating a 3D point around the x-axis or y-axis uses homogeneous matrices following the right-hand rule (positive angle rotates counter-clockwise when looking toward the origin from the positive axis):
3D Reflection and Shearing: Reflecting across the principal -plane negates (); reflecting across the -plane negates ; and reflecting across the -plane negates . A 3D -axis shear shifts and proportionally to depth : and .
Worked Numerical Example (3D Composite Transformation): Given 3D point , first rotate by about the y-axis, then translate by . Under (): , , , giving . Translating by gives final point .
4.2 Oblique Projection Formulation and Worked Example
In an oblique parallel projection onto the -plane (), a point projects to and , where is the foreshortening ratio and is the projection angle on the view plane (commonly or ). For a Cabinet projection (), point projects to and .
4.3 Back-Face Detection and Depth-Sorting Overlap Tests
Before running expensive Z-buffer or scan-line algorithms, Back-Face Detection (Culling) immediately discards roughly half the polygons of any closed opaque polyhedron. For a polygon face with outward unit normal and a viewing vector pointing from the polygon toward the camera (or along in canonical view space), the face is a back face and invisible if (for view vector from camera to surface, ). For example, a cube face with outward normal viewed from along gives , so it is culled immediately.
In Depth Sorting (Painter's Algorithm), when two polygons and overlap in -range, the algorithm checks up to four geometric tests in order before deciding whether can be drawn before : (1) do their -extents fail to overlap? (2) do their -extents fail to overlap? (3) is completely behind the plane of ? (4) is completely in front of the plane of ? If all four tests fail, their roles are swapped and re-tested; if cyclic overlap persists, one polygon is split along the plane of the other.
Chapter 5: 3D View Frustum, Z-Buffer Trace, BSP Trees & C Projection Lab
5.1 Canonical Perspective View Volume and Frustum Clipping
In a 3D rendering pipeline, the camera's visible region under perspective projection forms a truncated pyramid called the view frustum, bounded by six planes: Left, Right, Top, Bottom, Near (), and Far (). Before rasterization, a perspective projection matrix maps this frustum into a normalized Canonical View Volume (the cube ). Clipping 3D primitives against the six planes of the unit cube uses 6-bit outcodes (an extension of Cohen-Sutherland) before homogeneous perspective division by .
5.2 Worked Numerical Trace: Z-Buffer Depth Comparison
Suppose a pixel patch initializes its depth buffer to (far plane) and color buffer to Background (Black). Triangle (Red) covers pixel with depth . Since , updates to and color becomes Red. Next, Triangle (Blue) covers pixel with depth . Since , is occluded at and discarded. Finally, Triangle (Green) covers pixel with depth . Since , updates to and final pixel color becomes Green—demonstrating exact order-independent visibility.
5.3 Binary Space Partitioning (BSP) Trees and Warnock's Area Subdivision
For static 3D environments (such as architectural interiors and game levels), a Binary Space Partitioning (BSP) tree pre-computes visibility order offline. Each tree node selects a polygon plane and partitions all remaining polygons into Front () and Back () subtrees, splitting any polygon that straddles the plane. At runtime, an in-order traversal relative to the camera's side of each node yields an exact back-to-front Painter's order from any viewpoint without per-frame sorting. Alternatively, Warnock's Area Subdivision algorithm exploits area coherence in image space by recursively subdividing the screen into four quadrants until each quadrant contains zero polygons, one polygon, or a single surrounding polygon—reducing to pixel-level depth resolution only along complex silhouette edges.
#include <graphics.h>
#include <math.h>
typedef struct { double x, y, z; } Pt3D;
void projectPoint(Pt3D p, double d, int xc, int yc, int *sx, int *sy) {
double zShift = p.z + 250.0;
*sx = xc + (int)((p.x * d) / zShift);
*sy = yc - (int)((p.y * d) / zShift);
}
int main() {
int gd = DETECT, gm;
Pt3D cube[8] = {
{-50,-50,-50}, {50,-50,-50}, {50,50,-50}, {-50,50,-50},
{-50,-50, 50}, {50,-50, 50}, {50,50, 50}, {-50,50, 50}
};
int edges[12][2] = {
{0,1},{1,2},{2,3},{3,0},{4,5},{5,6},{6,7},{7,4},{0,4},{1,5},{2,6},{3,7}
};
initgraph(&gd, &gm, "");
double ang = 0.5;
int sx[8], sy[8];
for (int i = 0; i < 8; i++) {
Pt3D r;
r.x = cube[i].x * cos(ang) + cube[i].z * sin(ang);
r.y = cube[i].y;
r.z = -cube[i].x * sin(ang) + cube[i].z * cos(ang);
projectPoint(r, 300.0, 320, 240, &sx[i], &sy[i]);
}
setcolor(LIGHTGREEN);
for (int e = 0; e < 12; e++)
line(sx[edges[e][0]], sy[edges[e][0]], sx[edges[e][1]], sy[edges[e][1]]);
getch();
closegraph();
return 0;
}Chapter 6: 3D Object Representations, Normals, and Solid Modeling
6.1 Polygon Surface Normals and Cross-Product Calculation
In 3D rendering, every planar polygon face has an associated plane equation and an outward surface normal vector . Given three non-collinear vertices ordered counter-clockwise when viewed from outside the solid, the normal vector is computed via the vector cross product:
Worked Numerical Example (Surface Normal): Given triangle vertices : edge vectors are and . Cross product . Its magnitude is , giving unit normal .
6.2 Quadric Surfaces, Blobby Objects, and Solid Modeling
| 3D Representation | Mathematical / Structural Basis | Primary Application |
|---|---|---|
| Polygon Mesh (B-Rep) | Connected triangles/quads in vertex-edge-face tables | Real-time GPUs, video games, architectural visualization |
| Quadric Surfaces | Second-degree implicit equations (Sphere, Ellipsoid, Torus) | Ray tracing, molecular spheres, mechanical bearings |
| Constructive Solid Geometry | Boolean tree (Union, Intersection, Difference) of primitives | Precision CAD/CAM mechanical part design |
| Octrees & Voxels | Recursive 8-child spatial cubic subdivision | Medical CT/MRI volume rendering, terrain & collision trees |
| Blobby Objects (Metaballs) | Summed Gaussian density fields exceeding a threshold | Organic fluid simulation, soft biological modeling |
Chapter 7: 3D Camera Viewing Pipeline and Projection Matrices
7.1 Constructing the 3D Viewing Coordinate System (u, v, n)
To render a 3D world from an arbitrary camera position looking toward a target point with an upward reference vector , the graphics pipeline constructs an orthonormal camera basis : (1) view-plane normal pointing backward from the target to the eye; (2) horizontal right axis ; and (3) true vertical up axis . World-to-View transformation translates to the origin and multiplies by the orthogonal rotation matrix whose rows are .
7.2 Comprehensive Comparison of 3D Projections
| Projection Class | Sub-Type | Projector Angle & COP | Visual & Geometric Properties |
|---|---|---|---|
| Parallel | Multiview Orthographic | Perpendicular (), COP at | True lengths and angles preserved; shows only 1 face per view |
| Parallel | Isometric Axonometric | Perpendicular, tilted equally to 3 axes | Shows 3 faces simultaneously with equal foreshortening () |
| Parallel | Oblique Cavalier | to view plane, COP at | Front face true shape; receding depth drawn at full 1:1 scale |
| Parallel | Oblique Cabinet | to view plane, COP at | Front face true shape; receding depth drawn at 0.5 scale (natural look) |
| Perspective | 1-, 2-, or 3-Point | Converging at finite COP | Realistic depth foreshortening; parallel lines meet at vanishing points |
Chapter 8: Coherence in Visibility and Back-Face Culling Lab
8.1 Coherence Types in Visible Surface Detection
Evaluating visibility independently at every pixel would be computationally prohibitive. Fast algorithms exploit coherence—the tendency for scene properties to remain constant or vary smoothly across space and time: (1) Object Coherence tests bounding boxes of separate objects before comparing individual faces; (2) Face Coherence assumes surface properties change gradually across a single polygon; (3) Edge Coherence tracks edges incrementally across scan lines; (4) Scan-Line Coherence reuses depth spans from scan line to ; and (5) Area Coherence (used by Warnock's algorithm) assigns uniform color to homogeneous screen quadrants.
8.2 Perspective Depth Non-Linearity and Z-Fighting
After perspective division by , normalized screen depth varies inversely with . Consequently, depth precision is densely concentrated near the near clipping plane and sparse near the far plane. Placing too close to zero (e.g., ) starves distant polygons of depth bits, causing coplanar or closely spaced distant surfaces to flicker against each other—an artifact called z-fighting.
Chapter 9: Ray Casting, Sweep Surfaces, and 3D Axis Rotation Trace
9.1 Ray Casting for Visibility and Constructive Solid Geometry
While rasterization projects 3D polygons onto the 2D screen, Ray Casting reverses the direction of computation: for every pixel on the screen, a primary ray is fired from the Center of Projection through that pixel into the 3D scene. The ray is intersected analytically against all scene objects (spheres, planes, cylinders, CSG solids), and the closest positive intersection parameter determines the visible surface. Ray casting naturally resolves visibility for curved quadric surfaces and CSG Boolean operations without polygonal tessellation artifacts.
9.2 Sweep Representations: Translational and Rotational Sweeps
Sweep representations construct 3D volumes efficiently by moving a 2D cross-sectional profile along a 3D trajectory. A translational sweep extrudes a 2D polygon linearly along a path vector (producing beams, walls, and architectural columns), whereas a rotational sweep (surface of revolution) revolves a 2D silhouette curve around an axis of symmetry by to generate symmetric solids such as bottles, vases, shafts, and gears.
9.3 Worked Numerical Example: 3D Viewing Basis Vectors
Given camera position , look-at target , and up vector : (1) ; (2) ; (3) . This confirms the standard right-handed camera orientation looking down the axis.
Chapter 10: Complete C Lab Program: 3D Transformations & Back-Face Culling
#include <graphics.h>
typedef struct { float x, y, z; } Vec3;
void projectOrtho(Vec3 p, int xc, int yc, int *sx, int *sy) {
/* Isometric-like projection angles: 30 deg tilt */
*sx = xc + (int)(p.x * 0.866 - p.z * 0.866);
*sy = yc - (int)(p.y - p.x * 0.5 - p.z * 0.5);
}
int isFrontFace(Vec3 p1, Vec3 p2, Vec3 p3, Vec3 viewDir) {
Vec3 u = {p2.x - p1.x, p2.y - p1.y, p2.z - p1.z};
Vec3 v = {p3.x - p1.x, p3.y - p1.y, p3.z - p1.z};
Vec3 n = {u.y*v.z - u.z*v.y, u.z*v.x - u.x*v.z, u.x*v.y - u.y*v.x};
float dot = n.x * viewDir.x + n.y * viewDir.y + n.z * viewDir.z;
return dot > 0.0f;
}
int main() {
int gd = DETECT, gm;
Vec3 p1 = {0, 0, 40}, p2 = {60, 0, 40}, p3 = {60, 60, 40};
Vec3 viewDir = {0, 0, 1};
initgraph(&gd, &gm, "");
if (isFrontFace(p1, p2, p3, viewDir)) {
int x1, y1, x2, y2, x3, y3;
projectOrtho(p1, 320, 240, &x1, &y1);
projectOrtho(p2, 320, 240, &x2, &y2);
projectOrtho(p3, 320, 240, &x3, &y3);
setcolor(YELLOW);
line(x1, y1, x2, y2); line(x2, y2, x3, y3); line(x3, y3, x1, y1);
}
getch();
closegraph();
return 0;
}Chapter 11: Arbitrary 3D Axis Rotation & Vanishing Point Geometry
11.1 Five-Step Rotation About an Arbitrary 3D Axis
To rotate a 3D object by angle around an arbitrary axis passing through and : (1) translate to the origin via ; (2) compute unit axis vector and rotate around the x-axis by (, where ) to bring into the -plane; (3) rotate around the y-axis by () to align with the -axis; (4) apply ; and (5) apply the inverse rotations and inverse translation .
Chapter 12: 3D Visible Surface Detection Engineering Tradeoffs
12.1 Choosing Between Z-Buffer, A-Buffer, Scan-Line, and BSP
Real-time GPU engines universally pair Back-Face Culling with a hardware Z-Buffer because Z-buffering runs in constant time per pixel fragment and scales effortlessly to millions of dynamic triangles. Offline film renderers that require anti-aliased hair, motion blur, and layered semi-transparent glass employ A-Buffer deep fragment lists or ray tracing. Static architectural walkthroughs on memory-constrained hardware benefit from BSP trees or Scan-Line visibility to avoid large depth buffers.
Chapter 13: 3D Homogeneous Matrix Reference Summary
13.1 Consolidated 3D Transformation and Projection Reference
Combining modeling transforms (), camera view transform (), and perspective projection () forms the standard Model-View-Projection (MVP) matrix , transforming every 3D vertex directly from local object space into clip space in a single matrix-vector product.
13.2 Worked Numerical Example: 3D Rotation Around Z-Axis and Perspective
Take 3D point , rotate by about the z-axis, then apply perspective projection onto view plane . Under , , , . Projecting with gives , .
13.3 Octree Hierarchical Compression for 3D Volumes
In a uniform voxel grid, storing 1 byte per voxel consumes . An Octree recursively divides the volume into eight octants: any octant that is completely empty or completely solid is stored as a single leaf node without further subdivision, typically compressing medical and CAD volumetric models by 80% to 95% while supporting fast logarithmic spatial queries.
Chapter 14: 3D Clipping Against Canonical View Volume
14.1 Homogeneous 4D Clipping Before Perspective Division
Clipping 3D lines and polygons in 4D homogeneous clip space (, , ) before dividing by prevents division-by-zero singularities for vertices lying on the camera plane () and avoids wrap-around artifacts for geometry behind the eye ().
14.2 Summary of the Complete 3D Graphics Transformation Pipeline
Every 3D vertex processed by a modern GPU traverses five sequential coordinate spaces before illuminating a screen pixel. First, local Object (Modelling) Space vertices are positioned into World Space via the Model matrix. Second, the View Matrix (constructed from camera eye, target, and up vectors) transforms World Space into Camera (Eye) Space. Third, the Projection Matrix (orthographic or perspective) maps the view frustum into 4D Clip Space, where frustum clipping and back-face culling discard invisible geometry. Fourth, perspective division by yields 3D Normalized Device Coordinates in . Finally, the Viewport Transform scales NDC coordinates into integer screen pixels with interpolated depth values for Z-buffer visibility testing.
Module V: Flexi Module: Curves, Animation, Shading & Lab Programs
Chapter 1: Parametric Curves (Bezier and B-Spline)
1.1 Parametric Representation, Bezier Curves, and Properties
Polygonal approximations require huge vertex counts to look smooth under zoom. Smooth curves are instead represented parametrically as for parameter , naturally supporting vertical tangents and multi-valued loops. A Bezier curve of degree is defined by control points blended by Bernstein basis polynomials :
Key geometric properties of Bezier curves include: (1) Endpoint Interpolation: the curve always passes through at and at ; (2) Tangent Continuity: the start tangent aligns with and end tangent with ; (3) Convex Hull Property: because Bernstein weights are non-negative and sum to 1, the entire curve lies strictly inside the convex hull of its control polygon; and (4) Global Control Limitation: moving a single control point alters the shape of the entire Bezier curve, and adding control points raises the polynomial degree.
Worked Numerical Example (Cubic Bezier): Given four control points , , , , evaluate the midpoint at . The cubic Bernstein weights at are , , , and . Computing coordinates: ; . Thus .
1.2 B-Spline Curves and Local Control
B-Spline (Basis Spline) curves overcome Bezier's global-control and degree-coupling limitations. A B-Spline of order (degree ) over control points decouples the curve degree from the number of control points and uses a non-decreasing knot vector . Basis functions are defined recursively by the Cox–de Boor formula and are non-zero only over knot intervals, guaranteeing local control: moving a single control point affects only a localized segment of the curve without disturbing distant regions.
Chapter 2: Computer Animation and Shading Models
2.1 Computer Animation Techniques
Computer animation creates the illusion of continuous motion by displaying a rapid sequence of slightly altered frames (typically 24 to 60 fps) exploiting human persistence of vision. Core 2D/3D animation and viewport operations include:
- Tweening (In-Betweening): Animators specify key poses at sparse keyframes, and the computer automatically interpolates intermediate frames using linear, spline, or ease-in/ease-out functions over vertex positions, rotation angles, and colors.
- Morphing (Image Metamorphosis): Smoothly transforms one shape or photograph into a completely different shape by combining geometric mesh warping (interpolating corresponding feature control points) with color cross-dissolving across frames.
- Zooming: Enlarges or shrinks a scene by narrowing or widening the world-coordinate clip window while keeping the screen viewport fixed, effectively scaling object sizes smoothly.
- Panning: Translates the clip window horizontally or vertically across a larger world-coordinate scene without changing its dimensions, creating smooth camera tracking across wide backgrounds.
- Scissoring: Fast hardware-level rectangular clipping performed directly in device (raster) coordinates, discarding any pixels lying outside an active screen sub-region without geometric line intersection math.
2.2 Illumination and Surface Shading Models
Shading determines the final color intensity of every pixel on a polygon surface based on light sources, surface normal vectors, and viewer position. The standard Phong illumination model sums three components: ambient light (uniform background bounce), diffuse reflection (Lambertian matte scattering proportional to ), and specular reflection (glossy highlight proportional to ). Three polygon shading methods trade speed for visual smoothness:
- Flat (Constant) Shading: Evaluates the illumination equation once per polygon using its single face normal and fills the entire polygon with one uniform color. Fast, but reveals sharp Mach-band creases between adjacent facets.
- Gouraud Shading (Intensity Interpolation): Computes vertex normals by averaging adjacent face normals, evaluates illumination at each polygon vertex, and linearly interpolates vertex intensities across scan lines. Smooths curved surfaces effectively, though specular highlights can be missed or distorted inside large polygons.
- Phong Shading (Normal-Vector Interpolation): Linearly interpolates the surface normal vector across each scan line and evaluates the full illumination equation independently at every pixel. Produces crisp, accurate specular highlights at higher computational cost.
Chapter 3: Practical C Graphics (graphics.h) Lab Implementations
3.1 Initializing BGI Graphics and Essential Lab Programs
In C/C++ academic graphics laboratories using the Borland Graphics Interface (graphics.h), programs initialize the display driver via initgraph(&gd, &gm, ""), draw primitives using putpixel, line, circle, and setcolor, pause with getch(), and release graphics memory via closegraph(). Below are complete, lab-ready implementations for Bresenham's Line Algorithm, Cohen-Sutherland Clipping, and Cubic Bezier Curve generation.
#include <graphics.h>
#include <stdlib.h>
void bresenhamLine(int x1, int y1, int x2, int y2, int color) {
int dx = abs(x2 - x1), dy = abs(y2 - y1);
int sx = (x1 < x2) ? 1 : -1;
int sy = (y1 < y2) ? 1 : -1;
int err = dx - dy;
while (1) {
putpixel(x1, y1, color);
if (x1 == x2 && y1 == y2) break;
int e2 = 2 * err;
if (e2 > -dy) { err -= dy; x1 += sx; }
if (e2 < dx) { err += dx; y1 += sy; }
}
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
bresenhamLine(100, 100, 350, 240, WHITE);
getch();
closegraph();
return 0;
}#include <graphics.h>
#include <math.h>
void drawBezier(int x[4], int y[4]) {
double t;
for (t = 0.0; t <= 1.0; t += 0.001) {
double u = 1.0 - t;
double px = u*u*u*x[0] + 3*t*u*u*x[1] + 3*t*t*u*x[2] + t*t*t*x[3];
double py = u*u*u*y[0] + 3*t*u*u*y[1] + 3*t*t*u*y[2] + t*t*t*y[3];
putpixel((int)(px + 0.5), (int)(py + 0.5), YELLOW);
}
}
int main() {
int gd = DETECT, gm;
int x[4] = {100, 180, 320, 420};
int y[4] = {300, 80, 80, 300};
initgraph(&gd, &gm, "");
drawBezier(x, y);
for (int cx = 100; cx <= 420; cx += 5) {
setcolor(LIGHTCYAN);
circle(cx, 350, 20);
delay(25);
setcolor(BLACK);
circle(cx, 350, 20);
}
getch();
closegraph();
return 0;
}3.2 Additional Lab Programs: 2D Transformations & Flood Fill
The following two laboratory programs demonstrate homogeneous 2D transformations (translation, rotation, scaling) and 4-connected Flood Fill using standard BGI graphics.h routines.
#include <graphics.h>
#include <math.h>
void drawTriangle(int x[3], int y[3], int col) {
setcolor(col);
line(x[0], y[0], x[1], y[1]);
line(x[1], y[1], x[2], y[2]);
line(x[2], y[2], x[0], y[0]);
}
int main() {
int gd = DETECT, gm;
int x[3] = {200, 260, 230}, y[3] = {200, 200, 150};
int rx[3], ry[3];
double theta = 45.0 * 3.14159265 / 180.0;
int xf = 200, yf = 200;
initgraph(&gd, &gm, "");
drawTriangle(x, y, WHITE);
for (int i = 0; i < 3; i++) {
double dx = x[i] - xf, dy = y[i] - yf;
rx[i] = xf + (int)(dx * cos(theta) - dy * sin(theta));
ry[i] = yf + (int)(dx * sin(theta) + dy * cos(theta));
}
drawTriangle(rx, ry, YELLOW);
getch();
closegraph();
return 0;
}#include <graphics.h>
void floodFill4(int x, int y, int oldCol, int newCol) {
if (getpixel(x, y) == oldCol && oldCol != newCol) {
putpixel(x, y, newCol);
floodFill4(x + 1, y, oldCol, newCol);
floodFill4(x - 1, y, oldCol, newCol);
floodFill4(x, y + 1, oldCol, newCol);
floodFill4(x, y - 1, oldCol, newCol);
}
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
rectangle(150, 150, 250, 250);
floodFill4(200, 200, BLACK, LIGHTRED);
getch();
closegraph();
return 0;
}Chapter 4: Continuity, Phong Illumination, and BGI Reference
4.1 Parametric vs. Geometric Continuity and De Casteljau Subdivision
When joining multiple Bezier or B-Spline curve segments end-to-end, smoothness at the junction is classified by parametric continuity () and geometric continuity (): guarantees connected endpoints; requires identical tangent vectors (magnitude and direction), whereas requires collinear tangent directions with possibly different speeds; matches second-derivative curvature vectors.
De Casteljau's Algorithm evaluates any point on a Bezier curve without computing factorials or powers, using repeated linear interpolation: . For cubic Bezier at : Level 1 gives ; Level 2 gives ; Level 3 gives .
4.2 Phong Illumination Equation and Shading Comparison
The complete local illumination intensity at a surface point sums ambient, diffuse, and specular reflections:
| Shading Model | Interpolation Quantity | Illumination Evaluations | Visual Quality & Cost |
|---|---|---|---|
| Flat (Constant) | None (uniform polygon color) | Once per polygon | Fastest; visible faceted Mach bands |
| Gouraud | Vertex light intensities | Once per vertex | Smooth diffuse gradients; may miss interior specular highlights |
| Phong | Surface normal vectors | Once per pixel | Sharp specular highlights; highest computational cost |
4.3 Essential C graphics.h Function Reference
| BGI Function | Purpose & Parameters |
|---|---|
initgraph(&gd, &gm, path) |
Initializes graphics driver and mode for BGI screen rendering |
putpixel(x, y, color) / getpixel(x, y) |
Writes or reads the color index of a single pixel at |
line(x1, y1, x2, y2) / circle(xc, yc, r) |
Draws hardware-rasterized straight lines and circles |
setcolor(c) / setfillstyle(pat, col) |
Sets active foreground stroke color and polygon fill pattern |
delay(ms) / cleardevice() |
Pauses execution for animation timing and clears the viewport |
Chapter 5: B-Spline Cox–de Boor Formula, NURBS, Illumination Trace & Animation Lab
5.1 B-Spline Cox–de Boor Recursion and NURBS
A B-Spline curve of order (degree ) over control points and knot vector is evaluated via , where the basis functions obey the Cox–de Boor recurrence:
Uniform vs. Open-Uniform vs. NURBS: In a uniform B-Spline, knots are equally spaced (e.g., ), so the curve generally does not interpolate its first or last control points. An open-uniform B-Spline repeats the start and end knots times (e.g., ), forcing endpoint interpolation like a Bezier curve while retaining local control. NURBS (Non-Uniform Rational B-Splines) assign an individual scalar weight to each control point, enabling exact representation of conic sections (circles, ellipses, hyperbolas) alongside freeform CAD surfaces.
5.2 Worked Numerical Example: Phong Illumination Calculation
Evaluate the Phong illumination intensity at a surface point where ambient light , point light , reflectance coefficients , shininess , unit normal , light direction , reflection vector , and view vector :
- Ambient Term: .
- Diffuse Term: , so .
- Specular Term: . Raising to : , so .
- Total Intensity: (near peak brightness).
5.3 Morphing, Panning, Zooming, and Lab Animation Program
In 2D Shape Morphing, a source polygon with vertices transforms smoothly into a target polygon with vertices over normalized time via linear vertex tweening . Simultaneously, Panning shifts the clip window by per frame, and Zooming scales the window half-widths by factor to magnify the center of interest.
#include <graphics.h>
int main() {
int gd = DETECT, gm;
/* Morph a triangle into a wider diamond-like triangle over 50 frames */
int ax[3] = {200, 300, 250}, ay[3] = {300, 300, 200};
int bx[3] = {150, 350, 250}, by[3] = {220, 220, 340};
int cx[3], cy[3];
initgraph(&gd, &gm, "");
for (int f = 0; f <= 50; f++) {
double t = f / 50.0;
cleardevice();
for (int i = 0; i < 3; i++) {
cx[i] = (int)((1.0 - t) * ax[i] + t * bx[i]);
cy[i] = (int)((1.0 - t) * ay[i] + t * by[i]);
}
setcolor(LIGHTMAGENTA);
line(cx[0], cy[0], cx[1], cy[1]);
line(cx[1], cy[1], cx[2], cy[2]);
line(cx[2], cy[2], cx[0], cy[0]);
delay(35);
}
getch();
closegraph();
return 0;
}Chapter 6: Hermite Splines, Bicubic Surfaces, and De Casteljau Evaluation
6.1 Hermite Cubic Splines and Geometry Matrix
Unlike Bezier curves that use intermediate control points to shape tangents indirectly, a Hermite cubic spline interpolates two endpoints directly while matching explicitly specified endpoint tangent vectors . Expressing defines the Hermite basis matrix:
Worked Numerical Example (Hermite Spline): Given , , start tangent , and end tangent , evaluate at . Blending weights: , , , . Thus , and , giving arch apex .
6.2 Bicubic Bezier Surface Patches
Extending 1D Bezier curves into 3D curved surfaces creates a bicubic Bezier surface patch controlled by a grid of 16 control points parameterized by two independent variables :
Chapter 7: Blinn-Phong Shading, Texture Mapping & Double-Buffered Lab
7.1 Blinn-Phong Halfway Vector and Distance Attenuation
Computing the exact reflection vector at every pixel in Phong shading requires a dot product and vector subtraction per fragment. The Blinn-Phong model accelerates specular highlights by replacing with , where the halfway vector bisects the angle between light and view directions. For realistic point lights, intensity also diminishes with distance via an attenuation factor .
7.2 Texture Mapping, Bump Mapping, and Displacement Mapping
To add fine surface detail without increasing polygon counts, Texture Mapping maps 2D image coordinates onto 3D triangle vertices and interpolates them across scan lines to sample a color bitmap. Bump Mapping perturbs the surface normal vector per pixel using a grayscale height map, creating the illusion of rough stone or embossed metal under lighting without altering vertex geometry. Displacement Mapping actually offsets vertex positions along their normals, altering silhouettes as well as interior shading.
7.3 Double-Buffered Bouncing Ball Animation in BGI
Standard cleardevice() loops flicker visibly because the screen is erased and redrawn on the active visible page. Using setactivepage(page) and setvisualpage(1 - page) in BGI implements true hardware double buffering, eliminating animation flicker completely.
#include <graphics.h>
int main() {
int gd = DETECT, gm, page = 0;
int x = 100, y = 100, vx = 4, vy = 0, gravity = 1;
initgraph(&gd, &gm, "");
for (int frame = 0; frame < 200; frame++) {
setactivepage(page);
setvisualpage(1 - page);
cleardevice();
setcolor(WHITE);
line(20, 400, 620, 400);
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
fillellipse(x, y, 20, 20);
x += vx; vy += gravity; y += vy;
if (y >= 380) { y = 380; vy = -vy * 85 / 100; }
if (x > 600 || x < 40) vx = -vx;
delay(20);
page = 1 - page;
}
getch();
closegraph();
return 0;
}Chapter 8: Animation Principles, Gouraud Intensity Trace & Spline Comparison
8.1 Principles of Keyframe Animation and Ease-In / Ease-Out
Linear tweening moves objects at constant velocity, causing abrupt, robotic starts and stops. Smooth natural motion applies ease-in and ease-out timing curves—such as a cosine S-curve or cubic Hermite smoothstep —so velocity accelerates smoothly from zero at the start keyframe and decelerates smoothly to zero at the target keyframe. Traditional animation principles such as squash and stretch (preserving volume during impact), anticipation (backward wind-up before a leap), and follow-through (secondary motion after stopping) further enhance realism.
8.2 Worked Numerical Example: Gouraud Shading Span Interpolation
Suppose a triangle scan line intersects the left edge at with vertex intensity , and intersects the right edge at with vertex intensity . Under Gouraud shading, the incremental intensity step across the horizontal scan line is per pixel. Starting at , consecutive pixels receive intensities up to using a single floating-point addition per pixel.
8.3 Comprehensive Comparison of Parametric Curves
| Curve Type | Endpoint Interpolation | Control Locality | Key Mathematical Advantage |
|---|---|---|---|
| Hermite Cubic | Yes () | Local to segment | Direct control over endpoint tangent vectors |
| Bezier Curve | Yes () | Global across curve | Simple Bernstein convex hull; intuitive tangent polygon |
| B-Spline | Only if open-uniform | Strictly local | Decouples polynomial degree from number of control points |
| NURBS | Configurable via knots | Strictly local | Rational weights represent exact circles, ellipses, and freeform CAD |
Chapter 9: Complete C Lab Program: De Casteljau Bezier & Scissoring
#include <graphics.h>
void deCasteljau(double x[4], double y[4], double t, int *ox, int *oy) {
double px[4], py[4];
for (int i = 0; i < 4; i++) { px[i] = x[i]; py[i] = y[i]; }
for (int r = 1; r <= 3; r++) {
for (int i = 0; i <= 3 - r; i++) {
px[i] = (1.0 - t) * px[i] + t * px[i + 1];
py[i] = (1.0 - t) * py[i] + t * py[i + 1];
}
}
*ox = (int)(px[0] + 0.5);
*oy = (int)(py[0] + 0.5);
}
int main() {
int gd = DETECT, gm;
double x[4] = {80, 160, 340, 460}, y[4] = {320, 90, 90, 320};
int sxmin = 120, symin = 120, sxmax = 420, symax = 300;
initgraph(&gd, &gm, "");
setcolor(WHITE);
rectangle(sxmin, symin, sxmax, symax);
for (double t = 0.0; t <= 1.0; t += 0.002) {
int px, py;
deCasteljau(x, y, t, &px, &py);
/* Scissoring: only plot pixels inside active screen rectangle */
if (px >= sxmin && px <= sxmax && py >= symin && py <= symax)
putpixel(px, py, LIGHTGREEN);
}
getch();
closegraph();
return 0;
}Chapter 10: B-Spline Knot Vector Worked Example & Local Control
10.1 Evaluating Uniform Quadratic B-Spline Basis Functions
Consider a quadratic B-Spline () with uniform knot vector . At parameter , the only non-zero order-1 basis function is (since ). Applying Cox–de Boor recursion to order 2 yields and . Applying recursion once more to order 3 yields , , and , summing strictly to while blending only three adjacent control points .
Chapter 11: Real-Time Graphics Pipeline & Flexi Lab Summary
11.1 Integrating Curves, Shading, and Animation in Interactive Systems
Interactive 3D applications combine all five modules of Computer Graphics into a unified frame loop: (1) update object transforms and keyframe tweening parameters; (2) evaluate Bezier/B-Spline paths and surface normals; (3) apply 3D viewing and perspective projection matrices; (4) clip primitives against the view frustum; (5) rasterize triangles with Z-buffer visibility and Gouraud/Phong shading; and (6) swap double buffers during vertical retrace for tear-free 60+ fps display.
Chapter 12: Degree Elevation, Subdivision, and Shading Artifacts
12.1 Mach Banding and Specular Highlight Aliasing
In Flat shading, sudden intensity jumps across shared polygon edges trigger the human visual system's lateral inhibition response, exaggerating bright and dark strips along facet borders—a perceptual effect known as Mach banding. Gouraud shading eliminates Mach bands across smooth diffuse surfaces by interpolating vertex intensities, though sharp specular highlights falling inside a large triangle are still missed unless Phong normal-vector interpolation or fine mesh tessellation is used.
12.2 Worked Numerical Example: Cubic Bezier Derivative & Tangent Vector
For a cubic Bezier curve with control points , the first derivative with respect to is . Evaluating at yields ; at yields . Therefore, to join two cubic Bezier segments and with continuity, we simply set , placing collinearly at equal spacing.
Chapter 13: Frame Rate Pacing & Real-Time Animation Loop
13.1 Delta-Time Integration for Hardware-Independent Motion
Hardcoding fixed pixel steps (such as x += 5; delay(20);) ties animation speed to CPU and monitor refresh rates. Modern interactive graphics engines measure elapsed frame time in seconds and update positions via , guaranteeing identical physical motion speed across 60 Hz, 120 Hz, and 240 Hz displays.
13.2 Arc-Length Parameterization for Constant-Speed Curve Motion
When animating a camera or vehicle along a cubic Bezier or B-Spline path , stepping parameter uniformly by does not produce constant physical speed along the curve, because control point spacing stretches or compresses . To achieve smooth, constant-velocity motion along a spline, animators pre-compute a lookup table mapping uniform arc-length distance back to parameter using numerical integration (adaptive Simpson's rule or fine piecewise chord-length summation), ensuring smooth camera tracking without unintended acceleration or deceleration.
University of Kerala FYUGP Academic Framework
Syllabus details for BCA Semester 3 under official University of Kerala regulations.
Assessment comprises a 70-mark End-Semester Examination (2.5 Hours) and 30-mark Continuous Internal Evaluation.
About Computer Graphics (University of Kerala BCA Sem 3)
Computer Graphics (UK3DSCCAP204 • 4 Credits • 60 Hours (4 Hrs/Week)) is a DSC offering under the Bachelor of Computer Applications (BCA) Four-Year Undergraduate Programme (UoK FYUGP Regulations 2024 / 2025) at the University of Kerala. Structured across five sequentially integrated instructional modules, the course builds solid theoretical foundations and hands-on technical proficiency in computer graphics. Students engage with core computing principles, structured problem-solving, implementation techniques, and modern industry practices aligned with Kerala State Higher Education Council outcome-based education standards.
Computer Graphics Module-by-Module Curriculum Breakdown
Official syllabus unit modules prescribed by the University of Kerala FYUGP framework:
Introduction to Computer Graphics
Computer graphics is the branch of computer science concerned with generating, representing, manipulating, and displaying visual images—ranging from two-dimensional diagrams and user interfaces to photorealistic three-dimensional scenes and real-time interactive simulations—using digital hardware and mathematical algorithms. Unlike image processing, which takes an existing captured photograph and enhances or analyzes its pixel array, computer graphics synthesizes visual output from abstract geometric models, color specifications, lighting equations, and camera viewpoints.
Output Primitives
Before any line, circle, or polygon can illuminate pixels on a monitor, its geometry passes through a sequence of standardized coordinate systems. Separating local object design from global scene placement and physical screen resolution enables software applications to remain hardware-independent. Output primitives are the basic geometric building blocks provided by a graphics library (such as points, straight line segments, circles, ellipses, and polygons) from which complex scenes are constructed.
Two Dimensional Transformations and Clipping
Geometric transformations alter the position, orientation, size, or shape of graphical objects in 2D space by applying mathematical operations to their defining vertex coordinates P = ( x, y ). Once the vertices of a polygon or polyline are transformed, the object is redrawn by connecting the newly computed vertices. In standard 2D Cartesian coordinates, rotation and scaling are multiplicative operations ( P ′ = M ⋅ P ), whereas translation is an additive operation ( P ′ = P + T ).
3D Concepts and Techniques
Three-dimensional computer graphics extends spatial modeling into depth ( z -axis), typically using a right-handed coordinate system where + x points right, + y points up, and + z points toward the viewer. Representing 3D objects in memory balances geometric precision against rendering speed: In 3D homogeneous coordinates, a point is represented as a 4-element column vector ( x, y, z, 1 ) T, and all affine transformations are 4 × 4 matrices.
Flexi Module: Curves, Animation, Shading & Lab Programs
Polygonal approximations require huge vertex counts to look smooth under zoom. Smooth curves are instead represented parametrically as P ( t ) = ( x ( t ), y ( t ), z ( t )) for parameter t ∈ [ 0, 1 ], naturally supporting vertical tangents and multi-valued loops.
Core Curriculum & Key Topics
- Foundations of Computer Graphics, Pixels, and Frame Buffers
- 1 Scope and Applications of Computer Graphics
- 2 Pixels, Resolution, and Aspect Ratio
- 3 Frame Buffer Organization and Bandwidth Calculations
- Display Architectures, Video Controllers, and 3D Viewing
- 1 Raster Scan vs. Random Scan Systems
- 2 Video Controller, Video Adapter, and Graphics Card Architecture
- 3 Flat-Panel and Specialized Display Devices (LCD, LED, DVST)
Learning Outcomes
- Demonstrate authoritative comprehension of the foundational concepts, architectures, and principles of computer graphics.
- Apply algorithmic, programming, or analytical techniques to design and evaluate practical computing solutions.
- Analyze system trade-offs, security considerations, and industry standards relevant to modern software and IT environments.
- Implement, test, and document structured technical workflows aligned with professional computing practices.
- Achieve exam-ready mastery of University of Kerala FYUGP BCA question patterns across short concepts, technical comparisons, and comprehensive essays.
University of Kerala Examination Scheme for Computer Graphics
The evaluation framework for Computer Graphics (UK3DSCCAP204) under University of Kerala FYUGP regulations combines Continuous Internal Evaluation (30 Marks) with the university End-Semester Examination (70 Marks) for a total of 100 Marks (2.5 Hours duration):
10 Questions × 3 Marks (Maximum ceiling 24 Marks). Short definitional and conceptual questions covering all 5 syllabus modules.
8 Questions × 6 Marks (Maximum ceiling 36 Marks). Paragraph questions, comparative evaluations, and analytical problems.
2 Questions × 10 Marks (Answer any 1 for 10 Marks). Long-form essay or comprehensive numerical workout problem.
Exam Preparation Strategy:
To score top marks in the University of Kerala UK3DSCCAP204 (Computer Graphics) examination: 1. Use Block Diagrams & Process Flowcharts: Visual schematics for SDLC phases, testing lifecycles, system architectures, or workflow models earn strong presentation marks. 2. Anchor Answers in Standard Frameworks & Terminology: Define technical terms precisely in 2–3 sentences for Part A before expanding with practical examples in Parts B and C. 3. Include Comparative Tables: Present distinctions (e.g., black-box vs. white-box testing, proprietary vs. open-source licensing, MIS vs. DSS) in clean tabular form. 4. Follow a Structured Essay Format: Organize 10-mark and 15-mark answers with an Introduction, Core Architecture/Taxonomy, Labeled Diagram, Practical Application, and Conclusion.
Exam Preparation & Study Guides — Computer Graphics
What is Computer Graphics & Applications and why is it important in Computer Graphics?
Computer graphics synthesizes, manipulates, and displays visual images from mathematical models and numerical data using digital hardware and rendering algorithms, distinct from image processing which enhances existing captured photographs.
What is LCD (Liquid Crystal Display) and why is it important in Computer Graphics?
Non-emissive flat panel using voltage-controlled nematic liquid crystals between crossed polarizers to modulate light from a rear backlight; active-matrix TFT-LCD places a transistor at every sub-pixel for sharp contrast.
What is General Octant Bresenham and why is it important in Computer Graphics?
Handles steep slopes (|Δy| > |Δx|) by stepping along y and swapping Δx with Δy, using step signs s_x, s_y ∈ {−1, +1} for all 360° directions.
What is Transformations wrt Arbitrary Pivot (x_f, y_f) and why is it important in Computer Graphics?
Concatenate three steps: translate pivot to origin T(−x_f, −y_f), apply R(θ) or S(s_x, s_y) at origin, and translate back T(x_f, y_f).
What is A-Buffer (Accumulation Buffer) and why is it important in Computer Graphics?
Extends Z-buffer by storing a per-pixel linked list of surface fragments (RGB, alpha opacity, depth, area coverage), enabling anti-aliasing and multi-layer transparency.
What is the official course code and credit structure for Computer Graphics at University of Kerala?
Computer Graphics carries the official course code UK3DSCCAP204 under the University of Kerala FYUGP BCA framework. It is awarded 4 credits (60 Hours (4 Hrs/Week)), evaluated through 30 marks Continuous Internal Evaluation (CIE) and 70 marks End-Semester Examination (ESE).
Where can students download free PDF notes for Computer Graphics?
Students can read all 5 module notes online and download verified chapter-wise PDFs, combined exam notes, and quick revision sheets for Computer Graphics (UK3DSCCAP204) directly from DegreeLive (degreelive.in) with zero paywalls or sign-ups.
Course outlines and study notes follow official University of Kerala curricula. Curated by Anoop (Thiruvananthapuram).
For feedback or corrections, contact [email protected].
Related Study Resources & Student Support
Related Semester 3 Subjects
Browse study notes for other courses in BCA Sem 3:
Financial Aid & Grants 2026-27
Check eligibility criteria and deadlines for Kerala government and merit scholarships (e-Grantz 3.0, KSHEC, DCE).
Request Notes
Can't find what you're looking for? Let us know which subject notes you need.