100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Notas de lectura

Computer graphics-Unit-II RASTER SCAN GRAPHICS

Puntuación
-
Vendido
-
Páginas
32
Subido en
30-03-2023
Escrito en
2021/2022

chapter name :-RASTER SCAN GRAPHICS

Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Grado

Información del documento

Subido en
30 de marzo de 2023
Número de páginas
32
Escrito en
2021/2022
Tipo
Notas de lectura
Profesor(es)
S.gaikwad
Contiene
Chapter 2

Temas

Vista previa del contenido

Unit-II Raster Scan Graphics


Second Year Diploma Courses in Computer Science & Engineering / Computer
Engineering / Computer Technology / Information Technology Branch.




Computer Graphics
As per MSBTE ‘I’ Scheme Syllabus
CGR-22318

Unit-II
RASTER SCAN GRAPHICS
Total Marks- 12

Contents:
2.1 Basic concepts in line drawing,:
2.1.1 Line.
2.1.2 Drawing algorithms:
1. Digital Differential Analyzer (DDA) algorithm,
2. Bresenham's algorithm.
2.2 Circle generating algorithms:
2.2.1 Symmetry of circle,
2.2.2 Bresenham’s circle drawing algorithm.
2.3 Polygons –
2.3.1 Types of polygons,
2.3.2 inside-outside test,
2.3.3 Polygon Filling:
A. Seed fill algorithms:
A.1 Flood fill.
A.2 Boundary fill,
B. scan line algorithms
2.4 Scan conversion,
2.5 Frame Buffers.
2.6 Character generation methods:
1. stroke,
2. starburst,
3. bitmap.

CGR-22318 www.freestudyroom.xyz Page 1

, Unit-II Raster Scan Graphics

Unit-II Raster Scan Graphics

2.1 Basic Concept in Line Drawing:
2.1.1 Line: Line is a straight object with no curves, no thickness and it extends in both
directions without end. If it does have ends it is called as a line segment.
The process is turning on pixels for a line segment is called vector generation or line
generation and algorithm for them is known as vector generation algorithm or line drawing
algorithm.

Problems of vector generation:
 Line is straight but width is no constant.
 Brightness of line dependent on orientation of the line.
 Calculate only an approximate line length.
 Reduce the calculations using simple integer arithmetic.
2.1.2 Line Drawing Algorithms:
Line drawing algorithms are classified as Digital Differential Analyzer (DDA) algorithm
and Bresenham’s algorithm.

1. DDA Algorithm (Digital Differential Analyzer)
DDA algorithm is an incremental scan conversion method. Here we perform calculations at
each step using the results from the previous step.
We know that the slop of a straight line is given as -
Slop(
Where
m=Slop of line
dy=distance of y co-ordinates
dx=distance of x co-ordinates
The above differential equation can be used to obtain a rasterized straight line. For any given
x interval x along a line, we can compute the corresponding y interval y.
Similarly, we can obtain the x interval x corresponding to a specified y.
Once the intervals are known the values for next x and next y on the straight line can be
obtained.
Digital Differential Analyzer (DDA) algorithm is the simple line generation algorithm which
is explained step by step here.
Vector generation/DDA Line Algorithm –
1. Read line end points(x1,y1) and (x2,y2) such that they are not equal.
(If equal then plot that point and exit)
2. Compute Horizontal and Vertical differences-
dy=|y2-y1| and dx=|x2-x1|
3. if (|dx|>=|dy) then
steps=dx
else
steps=dy
4. Increment x, xinc=dx/steps


CGR-22318 www.freestudyroom.xyz Page 2

, Unit-II Raster Scan Graphics
5. Increment y, yinc=dy/steps
6. x=x1+0.5*sign(dx)
y=y1+0.5*sign(dy)
(here, sign function makes the algorithm work in all quadrant.)
7. for(i=0;i<steps;i++)
{
Plot (Integer(x), Integer(y))
x1=x+xinc
y1=y+yinc
}
8. Stop

‘C’ Code for DDA Line Drawing Algorithm:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
int sign(float val)
{
if(val<0)
return -1;
else
return 1;
}
int main()
{
int gd=DETECT,gm,i;
float x,y,x1,y1,x2,y2,dx,dy,xinc,yinc,steps;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
printf("Enter x1,y1");
scanf("%f%f",&x1,&y1);
printf("Enter x2,y2");
scanf("%f%f",&x2,&y2);
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>=dy)
{
steps=dx;
}
else
{
steps=dy;
}
xinc=dx/steps;
yinc=dy/steps;
x=x1+0.5*sign(dx); (Initial value with adding the factor 0.5 to make round value for x,
also sign function work in all quadrant.)
y=y1+0.5*sign(dy); (Initial value with adding the factor 0.5 to make round value for
y, also sign function work in all quadrant.)
putpixel(x,y,WHITE);
for(i=1;i<=steps;i++)

CGR-22318 www.freestudyroom.xyz Page 3

, Unit-II Raster Scan Graphics
{
x=x+xinc;
y=y+yinc;
putpixel(x,y,WHITE);
delay(100);
}
getch();
closegraph();
return 0;
}
OUTPUT:




Example 1: Consider the line from (0,0) to (4,6). Use the simple DDA algorithm to rasterize
this line.
Solution: Evaluating steps 1 to 5 in the DDA algorithm we have,
We have,
xl = 0, y1 = 0
x2 = 4, y2 = 6
dx=|x2 – x1| =4-0=4
dy =|y2 – yl|=6-0=6
here, dy is greater than dx
so, steps = dy = 6
Increment x, xinc=dx/steps=4/6=0.667
Increment y, yinc=dy/steps=6/6=1
Initial value with adding the factor 0.5 to make round value for x & y, also sign function work
in all quadrant.
x=0 + 0.5 sign (dx) = 0.5
y =0 + 0.5 sign (dy) = 0.5
Plot integer now:
1. Plot (0, 0), x=0.5, y=0.5
2. Plot (1, 1), x=x+ dx =0.5+0.667=1.167, y=y+ dy=0.5+1=1.5
3. Plot (1, 2), x=x+ dx =1.167+0.667=1.833 y=y+ dy =1.5+1=2.5
4. Plot (2, 3), x=x+ dx =1.833+0.667=2.5 y=y+ dy =2.5+1=3.5
5. Plot (3, 4), x=x+ dx =2.5+0.667=3.167 y=y+ dy =3.5+1=4.5
6. Plot (3, 5), x=x+ dx =3.167+0.667=3.833 y=y+ dy =4.5+1=5.5
7. Plot (4, 6) x=x+ dx =3.833+0.667=4.5 y=y+ dy =5.5+1=6.5
Tabulating the result of each iteration-
i x y plot
1 0.50 0.50 (0,0)
2 1.17 1.50 (1,1)
3 1.83 2.50 (1,2)
4 2.50 3.50 (2,3)

CGR-22318 www.freestudyroom.xyz Page 4
$8.59
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
shreyasshirsath

Conoce al vendedor

Seller avatar
shreyasshirsath silver lotus school
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
2 año
Número de seguidores
0
Documentos
14
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes