Computer Graphics Notes Summary - CSU358 - Shoolini U

Computer Graphics Notes Summary

1) Ultra‑simple summary

2) One‑line definitions

3) All numericals gathered in one place

A) DDA line drawing - from your notes (worked)

Given: Draw a line from (2, 2) to (8, 5).

Step‑1: $(dx=8-2=6)$, $(dy=5-2=3)$ → steps $(=\max(|6|,|3|)=6)$.

Step‑2: $(x_{inc}=dx/\text{steps}=6/6=1)$, $(y_{inc}=3/6=0.5)$.

Step‑3 (iterate 6 steps starting at (2,2)):

k x y plot(round)
0 2.0 2.0 (2,2)
1 3.0 2.5 (3,3)
2 4.0 3.0 (4,3)
3 5.0 3.5 (5,4)
4 6.0 4.0 (6,4)
5 7.0 4.5 (7,5)
6 8.0 5.0 (8,5)

Plotted sequence: (2,2) → (3,3) → (4,3) → (5,4) → (6,4) → (7,5) → (8,5).

B) Bresenham line drawing - from your notes (fully solved)

Given: Line from (2, 2) to (9, 6), slope $(0\le m\le 1)$.

Compute: $(dx=7,\ dy=4,\ p_0=2dy-dx=8-7=1)$.

Rule:

Iterations (start at (2,2)):

Step p before Decision Next point p after
0 1 NE (3,3) (1+8-14=-5)
1 -5 E (4,3) (-5+8=3)
2 3 NE (5,4) (3+8-14=-3)
3 -3 E (6,4) (-3+8=5)
4 5 NE (7,5) (5+8-14=-1)
5 -1 E (8,5) (-1+8=7)
6 7 NE (9,6) (7+8-14=1)

Plotted sequence: (2,2) → (3,3) → (4,3) → (5,4) → (6,4) → (7,5) → (8,5) → (9,6).

C) Window → Viewport mapping - from your notes (worked)

Given:

Window: $((x_w,y_w)\in[10,100]\times[10,100])$
Viewport: $((x_v,y_v)\in[200,400]\times[200,400])$
Point: $((55,70))$

Formulas:

$$ [ x_v=x_{vmin}+\frac{(x_w-x_{wmin})(x_{vmax}-x_{vmin})}{x_{wmax}-x_{wmin}},\quad y_v=y_{vmin}+\frac{(y_w-y_{wmin})(y_{vmax}-y_{vmin})}{y_{wmax}-y_{wmin}} ] $$

Compute:

Mapped point: $((300,\ 333.\overline{3}))$.

D) 2D transform examples - from your notes (worked)

Example 1: Translate then rotate

Answer: $((-5,6))$.

Example 2: Scale then translate

Answer: $((5,8))$.

E) Cohen–Sutherland line clipping - from your notes (fully solved)

Given: Window $([10,80]\times[10,80])$; line from $(P_1(5,20))$ to $(P_2(90,70))$.

Outcodes:

Clipped segment: $((10,22.9412))$ to $((80,64.1176))$.

F) Liang–Barsky line clipping - from your notes (fully solved)

Same line: $(P_1(5,20)\to P_2(90,70))$; window $([10,80]\times[10,80])$.

$(\Delta x=85,\ \Delta y=50)$.

Set $(t_E=0,\ t_L=1)$. For each boundary define $(p_k)$ and $(q_k)$:

Since $(t_E\le t_L)$, compute endpoints:

Clipped segment: same as Cohen–Sutherland (as expected).