1) Ultra‑simple summary
- What is Computer Graphics & CRT basics: Computer graphics uses a computer to create and show pictures; CRTs shoot electron beams onto a phosphor screen and must be refreshed to keep the picture visible.
- Display types - Random (Vector) vs Raster: Random scan draws only the lines of a picture; raster scan sweeps the whole screen in rows of pixels to form images.
- Frame buffer & color depth: The frame buffer stores one value per pixel (brightness/color); more bits per pixel mean more colors; refresh rate, persistence, and resolution affect perceived quality.
- Input devices & basic display techniques: Keyboard, mouse, light pen, joystick, trackball, scanner, digitizer; graphics draw points, lines, characters, and images.
- Line algorithms - DDA & Bresenham: DDA uses fractional steps (floating‑point); Bresenham uses only integers and a decision variable for faster line plotting.
- Circle & Ellipse - Midpoint methods: Use symmetry and a midpoint test to pick the next pixel while staying on the ideal curve.
- 2D transforms (translation, scaling, rotation): Move, resize, and turn shapes using matrices (homogeneous coordinates).
- Reflection & Shear: Mirror shapes across axes/lines; shear slants a shape without changing its sizes directly.
- Transform about an arbitrary point & composition: Do a translate → transform → translate back; combine transforms by matrix multiplication (order matters).
- Homogeneous coordinates: Add a “1” to points so that translation can be done with matrix multiplication and different transforms can be combined neatly.
- Window → Viewport mapping: Convert world (window) coordinates to screen (viewport) coordinates with a linear mapping that preserves proportions.
- Clipping - Cohen–Sutherland & Liang–Barsky: Decide which parts of lines lie inside a rect window; Cohen–Sutherland uses outcodes; Liang–Barsky uses line parameters for direct intersections.
- Polygon clipping - Sutherland–Hodgman: Clip polygons by processing one window edge at a time and building the kept vertex list.
- 3D transforms: Extend 2D transforms to (x,y,z): translate, scale, rotate about X/Y/Z, reflect across planes, shear in 3D.
- 3D projections - parallel & perspective: Parallel keeps sizes with no vanishing point; perspective makes far objects look smaller for realism.
2) One‑line definitions
- Computer Graphics: Creating and manipulating pictures with a computer.
- CRT (Cathode Ray Tube): A display where electron beams excite phosphor dots to emit light.
- Phosphor & Refreshing: Phosphor glows briefly when hit by electrons; refreshing redraws the image repeatedly to avoid fading.
- Random (Vector) Scan: Draws only the picture’s lines/edges (great for wireframes).
- Raster Scan: Sweeps each pixel row to build full images (what modern screens do).
- Frame Buffer: Memory that holds pixel color/brightness for the whole image.
- Bit Depth (Color Resolution): Bits per pixel; higher bits → more colors.
- Refresh Rate: Number of screen redraws per second (Hz).
- Persistence: How long a pixel glows after being lit.
- Resolution: Number of pixels horizontally × vertically.
- Keyboard/Mouse/Light Pen/Joystick/Trackball/Scanner/Digitizer: Standard input tools for text, pointing, drawing, and digitizing shapes.
- Point Plotting: Drawing by turning on individual pixels.
- Line Drawing: Algorithms to approximate straight lines on a pixel grid.
- DDA Line Algorithm: Draws a line using fractional x/y increments per step.
- Bresenham Line Algorithm: Draws a line using integer steps and a decision test.
- Midpoint Circle Algorithm: Picks the next circle pixel using a midpoint decision and symmetry.
- Midpoint Ellipse Algorithm: Similar to the circle case but split into two slope regions.
- Translation (2D): Move points by adding (Tx, Ty).
- Scaling (2D): Resize by multiplying x and y by (Sx, Sy).
- Rotation (2D): Turn a shape by angle θ using a rotation matrix.
- Reflection (2D): Mirror across an axis or line.
- Shearing (2D): Slant a shape by shifting x with y or y with x.
- Arbitrary‑Point Transform: Translate to origin → transform → translate back.
- Composite Transform: Multiply matrices to combine transforms; order matters.
- Homogeneous Coordinates: Use (x, y, 1) so all transforms are matrices.
- Window: World‑coordinate rectangle you want to show.
- Viewport: Screen‑coordinate rectangle where it’s shown.
- Cohen–Sutherland: Line clip via 4‑bit outcodes and quick accepts/rejects.
- Liang–Barsky: Line clip via parametric t‑values for direct intersections.
- Sutherland–Hodgman: Clip polygons by iterating edges and keeping visible parts.
- 3D Translation/Scaling/Rotation/Reflection/Shear: 3D versions of 2D transforms using 4×4 matrices.
- Parallel Projection: Rays are parallel; no size change with depth.
- Perspective Projection: Rays meet at a point; farther looks smaller.
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:
- If $(p<0)$ → E: $((x+1,y))$, $(p\gets p+2dy)$
- Else → NE: $((x+1,y+1))$, $(p\gets p+2dy-2dx)$
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:
- $x_v=200+\frac{(55-10)\cdot 200}{100-10}=200+\frac{45\cdot 200}{90}=200+100=300$
- $y_v=200+\frac{(70-10)\cdot 200}{100-10}=200+\frac{60\cdot 200}{90}=200+133.\overline{3}=333.\overline{3}$
Mapped point: $((300,\ 333.\overline{3}))$.
D) 2D transform examples - from your notes (worked)
Example 1: Translate then rotate
- Given: $(P(2,3),\ T=(+4,+2),\ \theta=90^\circ)$ about origin.
- Translate: $(P'=(2+4,3+2)=(6,5))$.
- Rotate 90° CCW: $((x,y)\mapsto(-y,x)\Rightarrow P''=(-5,6))$.
Answer: $((-5,6))$.
Example 2: Scale then translate
- Given: $(P(1,2),\ S=(2,3),\ T=(+3,+2))$.
- Scale: $((2,6))$.
- Translate: $((2+3,6+2)=(5,8))$.
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:
- $(P_1:)$ Left → 0001; $(P_2:)$ Right → 0010 → bitwise AND = 0000 → potentially visible.
Intersect with left $(x=10)$: Parametric form $(x=5+85t,\ y=20+50t)$. - $(5+85t=10\Rightarrow t=\tfrac{5}{85}=\tfrac{1}{17}\approx0.05882)$
- $(y=20+50\cdot\tfrac{1}{17}=20+\tfrac{50}{17}\approx22.9412)$ → $((10,22.9412))$.
Intersect with right $(x=80)$: - $(5+85t=80\Rightarrow t=\tfrac{75}{85}=\tfrac{15}{17}\approx0.88235)$
- $(y=20+50\cdot\tfrac{15}{17}=20+\tfrac{750}{17}\approx64.1176)$ → $((80,64.1176))$.
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)$:
- Left: $(p_1=-\Delta x=-85,\ q_1=x_1-x_{min}=5-10=-5 \Rightarrow t=q/p=0.05882)$ → $(p<0)$ → $(t_E=\max(0,0.05882)=0.05882)$
- Right: $(p_2=+\Delta x=85,\ q_2=x_{max}-x_1=80-5=75 \Rightarrow t=0.88235)$ → $(p>0)$ → $(t_L=\min(1,0.88235)=0.88235)$
- Bottom: $(p_3=-\Delta y=-50,\ q_3=y_1-y_{min}=20-10=10 \Rightarrow t=-0.2)$ → $(p<0)$ → $(t_E=\max(0.05882,-0.2)=0.05882)$
- Top: $(p_4=+\Delta y=50,\ q_4=y_{max}-y_1=80-20=60 \Rightarrow t=1.2)$ → $(p>0)$ → $(t_L=\min(0.88235,1.2)=0.88235)$
Since $(t_E\le t_L)$, compute endpoints:
- $(t_E=\tfrac{1}{17}\Rightarrow (x,y)=(5+85t_E,\ 20+50t_E)=(10,\ 22.9412))$
- $(t_L=\tfrac{15}{17}\Rightarrow (x,y)=(80,\ 64.1176))$
Clipped segment: same as Cohen–Sutherland (as expected).