Quick Summary & Numericals - Computer Graphics ESM

Computer Graphics Notes ESM

UNIT 1: INTRODUCTION & HARDWARE

1. What is Computer Graphics?

Simple Definition: Computer Graphics is the art and science of drawing pictures using computers. It acts as a translator: it takes numbers (which computers understand) and turns them into images (which humans understand).

Core Purpose: To visualize information. Whether it is a graph, a movie character, or a medical scan, graphics make data readable.

2. Applications (Where do we use it?)

3. Graphics Hardware (The Tools)

Hardware is divided into Input (giving orders) and Output (seeing results).

4. The Frame Buffer (Crucial Exam Concept)

The Frame Buffer is the memory that holds the picture before it goes to the screen.

Concept: The screen is a grid of pixels. The Frame Buffer stores the color code for every single pixel.

Memory Calculation Formula:
$\text{Memory} = \text{Resolution} \times \text{Color Depth}$

Example: For resolution $1024 \times 768$ and 24-bit color:
$$1024 \times 768 \times 24 \approx 18.8 \text{ million bits} \approx 2.25 \text{ MB}$$

UNIT 2: TRANSFORMATIONS (THE MATH)

1. What are Transformations?

Transformation simply means changing an object. We use Matrix Multiplication to do this because computers can calculate matrices very fast.

2. 2D Transformations (The Big 5)

You must memorize these 5 operations.

A. Translation (Moving)

Moving an object from point A to point B. We add values to coordinates.

$$x' = x + t_x$$
$$y' = y + t_y$$

B. Scaling (Resizing)

Making an object bigger or smaller. We multiply coordinates.

$$x' = x \cdot s_x$$
$$y' = y \cdot s_y$$

C. Rotation (Spinning)

Turning an object around a point by angle $\theta$.

Without Matrix Formula:

$$x' = x \cdot \cos\theta - y \cdot \sin\theta$$
$$y' = x \cdot \sin\theta + y \cdot \cos\theta$$

Matrix (Counter-Clockwise):

$$ \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} $$

D. Reflection (Mirroring)

Flipping an object (like looking in a mirror).

Without Matrix Formula:

$$x' = -x \text{ or } y' = -y $$

E. Shearing (Slanting)

Distorting the shape (like pushing the top of a deck of cards).

Without Matrix Formula:

$$x' = x + k_y \cdot y$$
$$y' = y + k_x \cdot x$$

3. Homogeneous Coordinates

Problem: Translation uses addition, but Scaling/Rotation use multiplication. We want to combine them all into one matrix multiplication.

Solution: Add a dummy coordinate '$1$'.

Point $(x, y)$ becomes $(x, y, 1)$. This allows us to represent Translation as a matrix multiplication too.

4. 3D Transformations

This is exactly the same as 2D, just add a $Z$-axis. We use 4×4 Matrices (using homogeneous coordinate $w=1$).

Point becomes $(x, y, z, 1)$.

All formulas of 3d transformatin without matrix

A. Translation

$$x' = x + t_x$$
$$y' = y + t_y$$
$$z' = z + t_z$$

B. Scaling

$$x' = x \cdot s_x$$
$$y' = y \cdot s_y$$
$$z' = z \cdot s_z$$

C. Rotation

About X-axis:

$$x' = x$$
$$y' = y \cdot \cos\theta - z \cdot \sin\theta$$
$$z' = y \cdot \sin\theta + z \cdot \cos\theta$$

About Y-axis:

$$x' = z \cdot \sin\theta + x \cdot \cos\theta$$
$$y' = y$$
$$z' = z \cdot \cos\theta - x \cdot \sin\theta$$

About Z-axis:

$$x' = x \cdot \cos\theta - y \cdot \sin\theta$$
$$y' = x \cdot \sin\theta + y \cdot \cos\theta$$
$$z' = z$$

D. Reflection

$$x' = -x \text{ or } y' = -y \text{ or } z' = -z $$

E. Shearing

$$x' = x + k_{xy} \cdot y + k_{xz} \cdot z$$
$$y' = y + k_{yx} \cdot x + k_{yz} \cdot z$$
$$z' = z + k_{zx} \cdot x + k_{zy} \cdot y$$

F. Composite Transformations

To combine multiple transformations, multiply their matrices in the reverse order of application.

Example: To first rotate, then translate, use
$$\text{Final Matrix} = \text{Translation Matrix} \times \text{Rotation Matrix}$$

This way, when you multiply the point, it first gets rotated, then translated.

Important: Matrix multiplication is not commutative. The order matters!

G. Coordinate Systems

In 3D graphics, we often switch between different coordinate systems:

  • World Coordinates: The global 3D space where all objects live.
  • Camera (View) Coordinates: The viewpoint of the camera. Transform objects from World to Camera space.
  • Screen Coordinates: The 2D pixel grid of the display. Transform from Camera to Screen space using Projection.

UNIT 3: PROJECTION

1. What is Projection?

Screens are 2D (flat). The world is 3D. Projection is the math used to squash a 3D object onto a 2D screen.

2. Parallel Projection

Concept: Light rays travel parallel to each other. There is no depth.

Real Life Example: The shadow of a building at noon.

3. Perspective Projection

Concept: All light rays meet at one point (Center of Projection). This mimics the Human Eye.

Real Life Example: Standing on a railway track; the tracks seem to meet at a point in the distance (Vanishing Point).

UNIT 4: VISIBLE SURFACE DETECTION

1. The Problem

When you look at a car, you can't see the engine inside. The metal body covers it. The computer needs to know what is in front (visible) and what is behind (hidden) so it doesn't waste time drawing hidden things.

2. Z-Buffer Algorithm (Depth Buffer)

This is the most popular algorithm used in almost all graphics cards today.

How it works (The Feynman Explanation):

  1. Imagine a grid representing your screen pixels.
  2. Every pixel has a "Depth Card" (Z-Buffer) that starts at Infinity (very far away).
  3. When the computer wants to draw a pixel of an object, it calculates the distance ($Z$) of that object from the camera.
  4. Comparison:
    • Is the new object closer ($Z_{new} < Z_{old}$) than what is currently there?
    • YES: Paint the new color and write the new $Z$ on the Depth Card.
    • NO: Ignore it (it's hidden behind something else).

Pros: Simple and easy to implement in hardware.
Cons: Takes extra memory.

3. A-Buffer (Anti-Aliased Buffer)

Concept: An upgrade to Z-Buffer. Instead of storing just one value per pixel, it stores a list of data for that pixel.

Why? It helps with Transparency (seeing through glass) and Anti-aliasing (smoothing jagged edges).

UNIT 5: ANIMATION

1. What is Animation?

Animation is creating the illusion of motion by showing a series of still images (frames) very quickly. The eye blends them together.

2. Key Techniques

A. Panning

Concept: The camera rotates horizontally (left or right) while standing in one spot.

Analogy: Turning your head left and right to see the whole room without moving your feet.

Use: To follow a character running across the screen or to reveal a large background.

B. Tweening (In-Betweening)

Concept: The lazy (smart) way to animate.

Benefit: Saves massive amounts of time. Used in Flash/Animate and modern 3D software.

3. Types of Animation