Points and lines in computer graphics

This article show the complete knowledge about points and lines both are used in computer graphics .

Points in computer graphics
Points is a location of space this is denoted by the dot symbol (.)
In computer graphics point is a pixel present on the device screen , point is a starting point of any element.

Line in computer graphics
Line is a collection of poits drawing is accomplished by calculating intermediate positions along the line path between two specified endpoint positions.

An output device is then directed to fill in these positions between the endpoints. For analog devices, such as a vector pen plotter or a random-scan display, a straight line can be drawn smoothly from one endpoint to the other.

Digital devices display a straight line segment by plotting discrete points between the two endpoints. Discrete coordinate positions along the line path are calculated from the equation of the line.

slope-intercept equation for a straight line is
Where m slope , c as the y intercept

A raster video display, the line color (intensity) is then loaded into the frame buffer at the corresponding pixel coordinates.

To load a specified color into the frame buffer at a position corresponding to column x along scan line y

points and lines in computer graphics

Pixel positions referenced by scan- line number and column number

Line Drawing Algorithms

Slope-intercept equation for a straight line
Where  m represent the slope of the line and c as the y intercept

Given that the two endpoints of a line segment are speafied at positions (x1 , y1) and (x2 , y2)

Determine the values of the slope m and y intercept c with the help of this formula c=y1  -  m.x1  
> m=  (y2-y1)(x2-x1)

  1. slope magnitudes m < 1 dx can be set proportional to a small horizontal deflection voltage
  2. slope magnitudes m > 1 dy can be set proportional to a small vertical deflection voltage
  3. slope magnitudes m = 1 , dx=dy can be set proportional to a horizontal and vertical deflection voltage equal

points and lines in graphics

Digital diffrential analyzer algorithm (DDA)

The digital diffrential analyzer (DDA) is a scan-conversion line algorithm based on calculating either dy , (dy = dx/m) or dx , (dx = dy/m) using We sample the line at unit in tervals in one coordinate and determine corresponding integer values nearest the line path for the other coordinate.

  1. Slope is less than or equal to 1 (m1), we sample at unit x intervals (dx = 1) and compute eachsuccessive y value .
    Yk+1 = Yk+ m
  2. Subscript k takes integer values starting from 1, for the first point, and increasesby 1 until the final endpoint is reached .
  3. m can be any real number between 0 to 1 .
  4. y values must be rounded to the nemt integer .

  1. When slope is greater then 1 (m > 1) .
  2. Then calculate each succeeding x value

    Xk+1 = Xk + 1/m

Digital diffrential analyzer algorithm

				         			dx=x2 - x1
dy=y2 - y1
if( abs(dx) > abs(dy) )
step abs(dx)
step abs(dy)
x inc = dx/step
y inc = dy/step
for(i=1 ; i<=step ; i++)
put pixel (x1 , y1)
x1=x1 + x inc
y1=x1 + y inc

  1. The DDA algorithm is a faster method for calculating pixel positions
  2. Appropriate increments are applied in the x or y direction to step to pixel positions along the line path
  3. we consider more general scan-line procedures that can be applied to both lines and curves