top of page

Consider a line from (0,0) to (5,5). Rasterize the line using Bresenham line drawing algorithm.

Dhruv Badaya

We have been given the start points and endpoints of a line.


X0 = 0

Y0 = 0


The first step in Bresenham's Line Drawing Algorithm is to find the value of ΔX and ΔY.


ΔX = 5

ΔY = 5


The initial decision parameter is given by 2ΔY - ΔX = 10 - 5 = 5.


Since the decision parameter is positive, the next value of X and Y is calculated as

X = X+1 = 0+1 = 1

Y = Y+1 = 0+1 = 1

P = P+(2ΔY - ΔX) = 5+5 = 10


Again since the decision parameter is positive, X and Y are calculated as:

X = X+1 = 1+1 = 2

Y = Y+1 = 1+1 = 2

P = P+(2ΔY - ΔX) = 10+5 = 15


Again since the decision parameter is positive, X and Y are calculated as:

X = X+1 = 2+1 = 3

Y = Y+1 = 2+1 = 3

P = P+(2ΔY - ΔX) = 15+5 = 20


Again since the decision parameter is positive, X and Y are calculated as:

X = X+1 = 3+1 = 4

Y = Y+1 = 3+1 = 4

P = P+(2ΔY - ΔX) = 20+5 = 25


Again since the decision parameter is positive, X and Y are calculated as:

X = X+1 = 4+1 = 5

Y = Y+1 = 4+1 = 5

P = P+(2ΔY - ΔX) = 25+5 = 30


Since this is the end point, we terminate our algorithm here. Let us draw the line we have rasterized.



 
 
 

Commenti


logo

Crookshanks Academy is an online learning platform with free netflix styled courses.

Crookshanks Academy 2023 ©️ All Rights Reserved

This content is protected from right clicks.
bottom of page