Graphics

Draw Line using Line Equation – Slope-Intercept Equation Algo

This method is the first method, even before any of other methods of line drawing like DDA , BLA were defined. The major drawback of this method is the fraction values it is, More the fraction values more would be approximation, more approximation means more loss of information. If the information loss is more then the line drawn would not be smooth. There fore other superior methods like DDA, BLA were developed. Lets understand this methods by an example.

But before that some fundamentals. The equation of the line is y=mx+b, where m is slope of the line and b is the intercept.

Draw a line from (0,0) to (4,6) using slope intercept method.

S-1 : y1=0 and x1=0 with x2=4 and y2=6.

S-2 : dy=y2-y1 => 6-0 = 6 and dx = x2-x1 = 4-0 = 4

S-3 : Slope (m) = dy/dx = 6/4 so m>1 and b will be calculated using x1 and y1 only. As y =m*x+b , set the values of x1 and y1. Therefore, 0=6/4*0 + b so b would be equal to 0. Which means that this line would pass through origin.

S-4 : As a rule, when m =>1 always increase y and calculate x. With every increase of x, y would be calculated.  We will use equation of line (y=m*x+b) to calculate y. Just put the values of m, x and b.

So x would be calculated as x=(y-b)/m

StepY1X1Pixel Plotted
100(0,0)
21(1-0)/(6/4) = 4/6=0.67(1,1)
32(2-1)*4/6 = 0.67(1,1)
43(3-1)*4/6 = 1.33(1,3)
54(4-1)*4/6= 2(2,4)
65(5-2)*4/6 = 2(2,5)
76(6-2)*4/6 = 2.67(3,6)

This method takes lot of approximations as seen above so the line drawn cannot be smooth. Therefore new methods were needed hence DDA and BLA algorithms were developed.

sr_2018

Recent Posts

Entrepreneurship UNIT-2 ENTREPRENEURIAL PLANNING ClassXII

NOTES UNIT-2 ENTREPRENEURIAL PLANNING CLASS-XII SUBJECT- ENTREPRENEURSHIP

3 years ago

Color Generating Techniques- Computer Graphics

There are two ways by which you can see some objects colorful, let's say RED…

4 years ago

MCQs on Moving Charges and Magnetism – Ch-4 Class 12

What is the formula of Lorentz force  q = charge B = Magnetic Fields E…

4 years ago

MCQs on Electrostatic Potential & Capacitance -ch 2 Class 12

MCQs on Electrostatic Potential & Capacitance - Chapter 2 - Class 12 CBSELove to Learn…

4 years ago

MCQs – Electric Charges – Chapter 1

A. Which out of the following are conductors Metal Human Body Animal Bodies Earth All…

4 years ago

MCQs on Solutions – Chapter -2

MCQs with answer explanation on - Solutions Chapter -2 Class 12 Prepared by Experts MCQ…

4 years ago