Computer Graphic
Computer Graphic
Explicit form
10 − 3 7
m= =
7−2 5
7
Now we have m = 5 fiding the y-intercept (b) by plugging in one of the points (use the first
point, (2;3)):
7
3= ×2+b
5
14 1
⇒ b=3− =
5 5
7 1
So, the explicit form of the line is: y = x +
5 5
2. Implicit form
We use the equation f(x, y) = mx + b − y to describe the implicit relationship between x and y
for the line passing through these points.
7
We already know the m = 5
7
f(x, y) = x + b − y
5
7
Substituting (2;3) into the equation f(x, y) = 5 x + b − y, to solve for b:
7
3= ×2+b−3
5
16
⇒b= 5
7 16
So, we have the equation in implicit form: f(x, y) = 5 x + −y
5
3. Parametric form
In 2D, line segment:
x = (1 − t)x0 + tx1
(1) { t∈ [0,1]
y = (1 − t)y0 + ty1
Substituting (x0 , y0 )=(2;3), (x1 , y1 )=(7;10) into (1), we have the equation in parametric form:
x = 2 + 5t
{
y = 3 + 7t
(x0 , y0 )=(2;3)
(x1 , y1 )=(7;10)
N=x1 − x0 = 7 − 2 = 5
1 2 3 4
⇒ t = {0, 5 , 5 , 5 , 5 , 1}
i=0,1,2,3,4,5
x0 = 2 + 0 x =2
i=0 ⇒ { ⇒ { 0
y0 = (1 − 0) × 3 + 0 × 10 y0 = 3
x1 = 2 + 1 x1 = 3
i=1 ⇒ { 1 1 ⇒ { 22 ⇒setPixel (3;4)
y1 = (1 − 5) × 3 + 5 × 10 y1 = 5
x2 = 2 + 2 x2 = 4
i=2 ⇒ { 2 2 ⇒ { 29 ⇒setPixel (4;6)
y2 = (1 − ) × 3 + × 10 y2 =
5 5 5
x3 = 2 + 3 x3 = 5
i=3 ⇒ { 3 3 ⇒ { 36 ⇒setPixel (5;7)
y3 = (1 − 5) × 3 + 5 × 10 y3 = 5
x4 = 2 + 4 x4 = 6
i=4 ⇒ { 4 4 ⇒ { 43 ⇒setPixel (6;9)
y4 = (1 − 5) × 3 + 5 × 10 y4 = 5
x5 = 2 + 5 x =7
i=5 ⇒ { ⇒ { 5
y5 = (1 − 1) × 3 + 1 × 10 y5 = 10