Question
Write a program in C/C++ to implement Bresenham’s line generation algorithm.
Answer :
Word Count : 345
___ _________ _______ _____ _________ ________ _______ ______.
_________ ___ _________ ___ ______ __________ ________ ______ ____.
_________ ____ _______ ______ _____.
___ ________ ____ _____ ___ ____ ____ _____ _____ _____ ________.
_____ ______ ___ ____ _______ ________ ___ ___ ____ _______.
_______ ______ __________ __________ _____ ___ ________ _______ ___ ____ __________.
_____ _____ ______ ___ _________ ___ ________ ________ ________ _____ _____ ____.
____ ________ _______ _______ _______ ______ _________ _________.
___ __________ ______ ________ _________ ______ _____ ___ ____ ________ _______.
_____ __________ _____ _________ _____ _____ ____ _________.
_________ _______ _____ ________ _________ _____ _________.
___ _________ __________ _____ ___ ___ ___ _____ ______ _________.
____ _________ ____ _________ _________ ________ _________ __________ ______ _________ _______.
________ __________ _______ ___ _____ _________ ________ _________ ___ _______ ______.
_____ _________ _________ __________ ______ ___.
____ ______ ________ _______ _____ __________ ____ ____ __________ _________.
_______ _________ ____ _______ ________ ___ __________ ________ _____ ______.
______ ____ __________ ______ _________.
________ ______ ____ _______ _________ ________.
______ ____ ____ _________ __________ _______ _______ _______ ___ _____ _________ _____.
_________ _______ __________ ________ _________ ______ _____ _______.
____ _________ _______ ________ _______ _________ ___ ______ _______.
________ ___ ____ ________ _________ _______ ___ _____ ______.
_______ _________ ___ ________ ___ _______ _______ __________ ___ ___ ______ _________.
____ ___ ________ ______ _______ ___ __________ _____ ____ ______ __________.
_________ _________ __________ __________ _______ ________.
__________ _____ _______ __________ ___.
Skip in 10
Here's a C++ program that implements Bresenham's line generation algorithm:
#include <iostream>
#include <graphics.h>
using namespace std;
void drawLine(int x0, int y0, int x1, int y1) {
int dx = abs(x1 - x0);
int dy = abs(y1 - y0);
int sx, sy;
if (x0 < x1) {
sx = 1;
} else {
sx = -1;
}
if (y0 < y1) {
sy = 1;
} else {
sy = -1;
_________ ___ _________ ___ ______ __________ ________ ______ ____.
_________ ____ _______ ______ _____.
___ ________ ____ _____ ___ ____ ____ _____ _____ _____ ________.
_____ ______ ___ ____ _______ ________ ___ ___ ____ _______.
_______ ______ __________ __________ _____ ___ ________ _______ ___ ____ __________.
_____ _____ ______ ___ _________ ___ ________ ________ ________ _____ _____ ____.
____ ________ _______ _______ _______ ______ _________ _________.
___ __________ ______ ________ _________ ______ _____ ___ ____ ________ _______.
_____ __________ _____ _________ _____ _____ ____ _________.
_________ _______ _____ ________ _________ _____ _________.
___ _________ __________ _____ ___ ___ ___ _____ ______ _________.
____ _________ ____ _________ _________ ________ _________ __________ ______ _________ _______.
________ __________ _______ ___ _____ _________ ________ _________ ___ _______ ______.
_____ _________ _________ __________ ______ ___.
____ ______ ________ _______ _____ __________ ____ ____ __________ _________.
_______ _________ ____ _______ ________ ___ __________ ________ _____ ______.
______ ____ __________ ______ _________.
________ ______ ____ _______ _________ ________.
______ ____ ____ _________ __________ _______ _______ _______ ___ _____ _________ _____.
_________ _______ __________ ________ _________ ______ _____ _______.
____ _________ _______ ________ _______ _________ ___ ______ _______.
________ ___ ____ ________ _________ _______ ___ _____ ______.
_______ _________ ___ ________ ___ _______ _______ __________ ___ ___ ______ _________.
____ ___ ________ ______ _______ ___ __________ _____ ____ ______ __________.
_________ _________ __________ __________ _______ ________.
__________ _____ _______ __________ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.