際際滷

際際滷Share a Scribd company logo
2
Most read
WAP in C to draw a line using DDA(Digital
Differential Algorithm) algorithm
OUTPUT
C CODE:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#define round(val)(int)(val+0.5)
void main()
{
int gd = DETECT, gm;
void line_daa(int,int,int,int);
int Xa,Xb,Ya,Yb;
clrscr();
printf("ntEnter the values:");
scanf("%d%d%d%d",&Xa,&Ya,&Xb,&Yb);
initgraph(&gd, &gm, "C:TCBGI");
cleardevice();
line_daa(Xa,Ya,Xb,Yb);
getch();
closegraph();
}
void line_daa(int Xa,int Ya,int Xb,int Yb)
{
int Dx=Xb-Xa,Dy=Yb-Ya,steps,k;
float Xin,Yin,X=Xa,Y=Ya;
if(abs(Dx)>abs(Dy))
steps=abs(Dx);
else
steps=abs(Dy);
Xin=Dx/(float)steps;
Yin=Dy/(float)steps;
putpixel(round(X),round(Y),6);
for(k=0;k<steps;k++)
{
X=X+Xin;
Y=Y+Yin;
putpixel(round(X),round(Y),6);
}
}

More Related Content

What's hot (20)

PPTX
2 d transformations and homogeneous coordinates
Tarun Gehlot
PDF
Online train ticket booking system project.pdf
Kamal Acharya
PPT
Lecture+ +raster+&+random+scan+systems
avelraj
PPTX
Travelling and salesman problem using ant colony optimization
Akash Sethiya
PPT
Ant Colony Optimization - ACO
Mohamed Talaat
PPT
Ant colony optimization
vk1dadhich
PPTX
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
PPT
Ant colony optimization
Abdul Rahman
DOC
us reservation System Report
Rajat Tripathi
PPTX
Green computing
suchitra poskar
PPT
Modes Of Transfer in Input/Output Organization
MOHIT AGARWAL
PPTX
ant colony algorithm
bharatsharma88
DOCX
Bus Ticket Management System Documentation
muzammil siddiq
DOCX
Synopsis on railway reservation system
Ankit Verma
DOC
Online Bus Reservation
Astha Patel
PDF
Computer graphics lab report with code in cpp
Alamgir Hossain
PPTX
TRAIN TICKETING SYSTEM
NimRaH NaZaR
PDF
Report on online bus management
Naeem Ahmad
PPTX
Optimization by Ant Colony Method
Uday Wankar
PPT
Ant Colony Optimization presentation
Partha Das
2 d transformations and homogeneous coordinates
Tarun Gehlot
Online train ticket booking system project.pdf
Kamal Acharya
Lecture+ +raster+&+random+scan+systems
avelraj
Travelling and salesman problem using ant colony optimization
Akash Sethiya
Ant Colony Optimization - ACO
Mohamed Talaat
Ant colony optimization
vk1dadhich
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
Ahtesham Ullah khan
Ant colony optimization
Abdul Rahman
us reservation System Report
Rajat Tripathi
Green computing
suchitra poskar
Modes Of Transfer in Input/Output Organization
MOHIT AGARWAL
ant colony algorithm
bharatsharma88
Bus Ticket Management System Documentation
muzammil siddiq
Synopsis on railway reservation system
Ankit Verma
Online Bus Reservation
Astha Patel
Computer graphics lab report with code in cpp
Alamgir Hossain
TRAIN TICKETING SYSTEM
NimRaH NaZaR
Report on online bus management
Naeem Ahmad
Optimization by Ant Colony Method
Uday Wankar
Ant Colony Optimization presentation
Partha Das

Viewers also liked (16)

PPTX
dda algorithm
774474
DOCX
Computer Graphics Lab File C Programs
Kandarp Tiwari
PPT
Plant layouts
Harinadh Karimikonda
PPTX
Plant layout,Factors influencing plant layout,Types and principles of plant l...
Indraja Modem
PPTX
Graphics Programming in C
Kasun Ranga Wijeweera
PPTX
Introduction to graphics programming in c
baabtra.com - No. 1 supplier of quality freshers
DOCX
Computer Graphics Practical
Neha Sharma
PPTX
Bresenham Line Drawing Algorithm
Mahesh Kodituwakku
PPTX
Output primitives in Computer Graphics
Kamal Acharya
PPT
Fuel and combustion
Raju Mirdha
PPTX
MET 401 Chapter 3 fuels_and_combustion
Ibrahim AboKhalil
PPTX
Unit 4 introduction to fuels and combustion
Santosh Damkondwar
PPT
Fuels and combustion (2014)
Yuri Melliza
PPTX
Plant layout and its types
Kritika Garg
PPT
Plant layout and its types
Hammaduddin
PPT
applications of computer graphics
Aaina Katyal
dda algorithm
774474
Computer Graphics Lab File C Programs
Kandarp Tiwari
Plant layouts
Harinadh Karimikonda
Plant layout,Factors influencing plant layout,Types and principles of plant l...
Indraja Modem
Graphics Programming in C
Kasun Ranga Wijeweera
Introduction to graphics programming in c
baabtra.com - No. 1 supplier of quality freshers
Computer Graphics Practical
Neha Sharma
Bresenham Line Drawing Algorithm
Mahesh Kodituwakku
Output primitives in Computer Graphics
Kamal Acharya
Fuel and combustion
Raju Mirdha
MET 401 Chapter 3 fuels_and_combustion
Ibrahim AboKhalil
Unit 4 introduction to fuels and combustion
Santosh Damkondwar
Fuels and combustion (2014)
Yuri Melliza
Plant layout and its types
Kritika Garg
Plant layout and its types
Hammaduddin
applications of computer graphics
Aaina Katyal
Ad

Recently uploaded (20)

PDF
01-introduction to the ProcessDesign.pdf
StiveBrack
PDF
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
PPTX
Work at Height training for workers .pptx
cecos12
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
PPTX
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
PDF
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
PDF
Designing for Tomorrow Architectures Role in the Sustainability Movement
BIM Services
PPT
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
PPTX
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
PPTX
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
PDF
PRIZ Academy - Process functional modelling
PRIZ Guru
PDF
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
PDF
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego L坦pez-de-Ipi単a Gonz叩lez-de-Artaza
PPTX
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
01-introduction to the ProcessDesign.pdf
StiveBrack
Generative AI & Scientific Research : Catalyst for Innovation, Ethics & Impact
AlqualsaDIResearchGr
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
Work at Height training for workers .pptx
cecos12
Computer network Computer network Computer network Computer network
Shrikant317689
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
Designing for Tomorrow Architectures Role in the Sustainability Movement
BIM Services
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
PRIZ Academy - Process functional modelling
PRIZ Guru
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego L坦pez-de-Ipi単a Gonz叩lez-de-Artaza
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
Ad

Wap in c to draw a line using DDA algorithm

  • 1. WAP in C to draw a line using DDA(Digital Differential Algorithm) algorithm OUTPUT C CODE: #include <stdio.h> #include <conio.h> #include <math.h> #include <graphics.h> #define round(val)(int)(val+0.5) void main() { int gd = DETECT, gm; void line_daa(int,int,int,int); int Xa,Xb,Ya,Yb; clrscr(); printf("ntEnter the values:"); scanf("%d%d%d%d",&Xa,&Ya,&Xb,&Yb); initgraph(&gd, &gm, "C:TCBGI"); cleardevice(); line_daa(Xa,Ya,Xb,Yb);
  • 2. getch(); closegraph(); } void line_daa(int Xa,int Ya,int Xb,int Yb) { int Dx=Xb-Xa,Dy=Yb-Ya,steps,k; float Xin,Yin,X=Xa,Y=Ya; if(abs(Dx)>abs(Dy)) steps=abs(Dx); else steps=abs(Dy); Xin=Dx/(float)steps; Yin=Dy/(float)steps; putpixel(round(X),round(Y),6); for(k=0;k<steps;k++) { X=X+Xin; Y=Y+Yin; putpixel(round(X),round(Y),6); } }