SlideShare a Scribd company logo
Experiment no. – 3.1
Student Name: Krishna Kumar UID: 19BCS2605
Branch: CSE - 11 Section/Group : ‘C’
Semester: 5th
Date of Performance: 21 Oct 2021
Subject Name: Computer Graphics Lab Subject Code: CSP - 305
1. Aim/Overview of the practical: a) To display 4-bit region code for end points of a line and
check whether line is completely on the screen or off the screen
b) To clip a line intersecting at one point with given window using Cohen
Sutherland Line Clipping algorithm.
c) To clip a line intersecting at Two or more points with given window using
Cohen Sutherland Line Clipping algorithm
2. Task to be done: a) To display 4-bit region code for end points of a line
b) To clip a line intersecting at one point with given window
c) To clip a line intersecting at Two or more points with given window
3. Algorithm :
a) algorithms for display 4-bit region code for end points of a line
Step 1: Start
Step 1.1: taking two point, starting point and end point of line for user
Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co-
ordinate of rectangle for user
Step 1. 4: Assign a region code for two endpoints of given line
Step 2 : If both endpoints have a region code 0000 then given line is completely
inside and we will keep this line
Step 3 : If step 2 fails, perform the logical AND operation for both region codes.
Step 3.1 : If the result is not 0000, then given line is completely outside.
Step 3.2 : Else line is partially inside.
Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle.
Step 3.2.b : Find the intersection point of the rectangular boundary (based on
region code).
Step 3.2.c : Replace endpoint with the intersection point and update the region
code.
Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or
rejected.
Step 4 : Repeat step 1 for all lines
Step 5: using while for taking point of line again and again form user.
Step 6: Displaying window, line and line in side window at a green colour at
green colour
Step 7: End
b) algorithms for clip a line intersecting at one point with given window
Step 1: Start
Step 1.1: taking two point, starting point and end point of line for user
Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co-
ordinate of rectangle for user
Step 1.3 : Assign a region code for two endpoints of given line
Step 2 : If both endpoints have a region code 0000 then given line is completely
inside and we will keep this line
Step 3 : If step 2 fails, perform the logical AND operation for both region codes.
Step 3.1 : If the result is not 0000, then given line is completely outside.
Step 3.2 : Else line is partially inside.
Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle.
Step 3.2.b : Find the intersection point of the rectangular boundary (based on
region code).
Step 3.2.c : Replace endpoint with the intersection point and update the region
code.
Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or
rejected.
Step 4 : Repeat step 1 for all lines
Step 5: Displaying window and line before line clipping and after line clipping
at green colour
Step 6: End
c) algorithms for clip a line intersecting at Two or more points with given window
Step 1: Start
Step 1.1: taking two point, starting point and end point of line for user
Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co-
ordinate of rectangle for user
Step 1.3 : Assign a region code for two endpoints of given line
Step 2 : If both endpoints have a region code 0000 then given line is completely
inside and we will keep this line
Step 3 : If step 2 fails, perform the logical AND operation for both region codes.
Step 3.1 : If the result is not 0000, then given line is completely outside.
Step 3.2 : Else line is partially inside.
Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle.
Step 3.2.b : Find the intersection point of the rectangular boundary (based on
region code).
Step 3.2.c : Replace endpoint with the intersection point and update the region
code.
Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or
rejected.
Step 4 : Repeat step 1 for all lines
Step 5: Displaying window and line before line clipping and after line clipping
Step 6: End
4. Programming Code:
a) Code for display 4-bit region code for end points of a line
#include<iostream>
#include<graphics.h>
#include<math.h>
#include<conio.h>
using namespace std;
class CohenSutherLandAlgo
{
private:
double x1,y1,x2,y2;
double x_max,y_max,x_min,y_min;
const int INSIDE = 0;
const int LEFT = 1;
const int RIGHT = 2;
const int BOTTOM = 4;
const int TOP = 8;
public:
CohenSutherLandAlgo()
{
x1 = 0.0;
x2 = 0.0;
y1 = 0.0;
y2 = 0.0;
}
void getCoordinates();
void getClippingRectangle();
int generateCode(double x, double y);
void cohenSutherland();
};
void CohenSutherLandAlgo::getCoordinates()
{
std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : ";
std::cin >> x1>>y1;
std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :";
std::cin >> x2>>y2;
std::cout<<endl;
setcolor(WHITE);
line(x1,y1,x2,y2);
}
void CohenSutherLandAlgo::getClippingRectangle()
{
std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl;
std::cout << "Enter the X_MAX and Enter the Y_MAX : ";
std::cin >> x_max>>y_max;
std::cout << "Enter the X_MIN and Enter the Y_MIN : ";
std::cin >> x_min>>y_min;
rectangle(x_min,y_min,x_max,y_max);
}
int CohenSutherLandAlgo::generateCode(double x, double y)
{
int code = INSIDE;
if (x < x_min)
code |= LEFT;
else if (x > x_max)
code |= RIGHT;
if (y < y_min)
code |= BOTTOM;
else if (y > y_max)
code |= TOP;
return code;
}
void CohenSutherLandAlgo::cohenSutherland()
{
int code1 = generateCode(x1, y1);
int code2 = generateCode(x2, y2);
bool accept = false;
while (true)
{
if ((code1 == 0) && (code2 == 0))
{
accept = true;
break;
}
else if (code1 & code2)
{
break;
}
else
{
int code_out;
double x, y;
if (code1 != 0)
code_out = code1;
else
code_out = code2;
if (code_out & TOP)
{
x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1);
y = y_max;
}
else if (code_out & BOTTOM)
{
x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1);
y = y_min;
}
else if (code_out & RIGHT)
{
y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1);
x = x_max;
}
else if (code_out & LEFT)
{
y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1);
x = x_min;
}
if (code_out == code1)
{
x1 = x;
y1 = y;
code1 = generateCode(x1, y1);
}
else
{
x2 = x;
y2 = y;
code2 = generateCode(x2, y2);
}
}
}
if (accept)
{ std::cout<<endl;
std::cout <<"Line accepted from " <<"("<< x1 << ", "
<< y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" <<
std::endl;
setcolor(GREEN);
line(x1,y1,x2,y2);
}
else
std::cout << "Line rejected" << std::endl;
}
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:turboc3bgi");
int x;
outtextxy(5,5,"White color that part of line segment is not accept ");
setcolor(GREEN);
outtextxy(5,20,"Green color that part of line segment is accept ");
setcolor(WHITE);
CohenSutherLandAlgo c;
c.getClippingRectangle();
do{
c.getCoordinates();
c.cohenSutherland();
std::cout<<endl;
cout<<"Please press 1 (one) for continue :";
cin>>x;
}
while(x==1);
getch();
closegraph();
}
b) Code for clip a line intersecting at one point with given window
#include<iostream>
#include<graphics.h>
#include<math.h>
#include<conio.h>
using namespace std;
class CohenSutherLandAlgo
{
private:
double x1,y1,x2,y2;
double x_max,y_max,x_min,y_min;
const int INSIDE = 0;
const int LEFT = 1;
const int RIGHT = 2;
const int BOTTOM = 4;
const int TOP = 8;
public:
CohenSutherLandAlgo()
{
x1 = 0.0;
x2 = 0.0;
y1 = 0.0;
y2 = 0.0;
}
void getCoordinates();
void getClippingRectangle();
int generateCode(double x, double y);
void cohenSutherland();
};
void CohenSutherLandAlgo::getCoordinates()
{
std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : ";
std::cin >> x1>>y1;
std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :";
std::cin >> x2>>y2;
std::cout<<endl;
line(x1,y1,x2,y2);
}
void CohenSutherLandAlgo::getClippingRectangle()
{
std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl;
std::cout << "Enter the X_MAX and Enter the Y_MAX : ";
std::cin >> x_max>>y_max;
std::cout << "Enter the X_MIN and Enter the Y_MIN : ";
std::cin >> x_min>>y_min;
rectangle(x_min,y_min,x_max,y_max);
outtextxy(x_min,y1-20,"Before line Clipping");
setcolor(GREEN);
outtextxy(x_max+50,y1-20,"After line Clipping");
rectangle(x_max+50,y_min,x_max+50+x_max-x_min,y_max);
}
int CohenSutherLandAlgo::generateCode(double x, double y)
{
int code = INSIDE;
if (x < x_min)
code |= LEFT;
else if (x > x_max)
code |= RIGHT;
if (y < y_min)
code |= BOTTOM;
else if (y > y_max)
code |= TOP;
return code;
}
void CohenSutherLandAlgo::cohenSutherland()
{
int code1 = generateCode(x1, y1);
int code2 = generateCode(x2, y2);
bool accept = false;
while (true)
{
if ((code1 == 0) && (code2 == 0))
{
accept = true;
break;
}
else if (code1 & code2)
{
break;
}
else
{
int code_out;
double x, y;
if (code1 != 0)
code_out = code1;
else
code_out = code2;
if (code_out & TOP)
{
x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1);
y = y_max;
}
else if (code_out & BOTTOM)
{
x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1);
y = y_min;
}
else if (code_out & RIGHT)
{
y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1);
x = x_max;
}
else if (code_out & LEFT)
{
y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1);
x = x_min;
}
if (code_out == code1)
{
x1 = x;
y1 = y;
code1 = generateCode(x1, y1);
}
else
{
x2 = x;
y2 = y;
code2 = generateCode(x2, y2);
}
}
}
if (accept)
{ std::cout<<endl;
std::cout <<"Line accepted from " <<"("<< x1 << ", "
<< y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" <<
std::endl;
setcolor(GREEN);
line(x1+x_max-x_min+50,y1,x2+x_max-x_min+50,y2);
}
else
std::cout << "Line rejected" << std::endl;
}
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:turboc3bgi");
CohenSutherLandAlgo c;
c.getCoordinates();
c.getClippingRectangle();
c.cohenSutherland();
getch();
closegraph();
}
c) Code for clip a line intersecting at Two or more points with given window
#include<iostream>
#include<graphics.h>
#include<math.h>
#include<conio.h>
using namespace std;
class CohenSutherLandAlgo
{
private:
double x1,y1,x2,y2;
double x_max,y_max,x_min,y_min;
const int INSIDE = 0;
const int LEFT = 1;
const int RIGHT = 2;
const int BOTTOM = 4;
const int TOP = 8;
public:
CohenSutherLandAlgo()
{
x1 = 0.0;
x2 = 0.0;
y1 = 0.0;
y2 = 0.0;
}
void getCoordinates();
void getClippingRectangle();
int generateCode(double x, double y);
void cohenSutherland();
};
void CohenSutherLandAlgo::getCoordinates()
{
std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : ";
std::cin >> x1>>y1;
std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :";
std::cin >> x2>>y2;
std::cout<<endl;
line(x1,y1,x2,y2);
}
void CohenSutherLandAlgo::getClippingRectangle()
{
std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl;
std::cout << "Enter the X_MAX and Enter the Y_MAX : ";
std::cin >> x_max>>y_max;
std::cout << "Enter the X_MIN and Enter the Y_MIN : ";
std::cin >> x_min>>y_min;
rectangle(x_min,y_min,x_max,y_max);
outtextxy(x_min,y1-20,"Before line Clipping");
setcolor(GREEN);
outtextxy(x_max+50,y1-20,"After line Clipping");
rectangle(x_max+50,y_min,x_max+50+x_max-x_min,y_max);
}
int CohenSutherLandAlgo::generateCode(double x, double y)
{
int code = INSIDE;
if (x < x_min)
code |= LEFT;
else if (x > x_max)
code |= RIGHT;
if (y < y_min)
code |= BOTTOM;
else if (y > y_max)
code |= TOP;
return code;
}
void CohenSutherLandAlgo::cohenSutherland()
{
int code1 = generateCode(x1, y1);
int code2 = generateCode(x2, y2);
bool accept = false;
while (true)
{
if ((code1 == 0) && (code2 == 0))
{
accept = true;
break;
}
else if (code1 & code2)
{
break;
}
else
{
int code_out;
double x, y;
if (code1 != 0)
code_out = code1;
else
code_out = code2;
if (code_out & TOP)
{
x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1);
y = y_max;
}
else if (code_out & BOTTOM)
{
x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1);
y = y_min;
}
else if (code_out & RIGHT)
{
y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1);
x = x_max;
}
else if (code_out & LEFT)
{
y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1);
x = x_min;
}
if (code_out == code1)
{
x1 = x;
y1 = y;
code1 = generateCode(x1, y1);
}
else
{
x2 = x;
y2 = y;
code2 = generateCode(x2, y2);
}
}
}
if (accept)
{ std::cout<<endl;
std::cout <<"Line accepted from " <<"("<< x1 << ", "
<< y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" <<
std::endl;
setcolor(GREEN);
line(x1+x_max-x_min+50,y1,x2+x_max-x_min+50,y2);
}
else
std::cout << "Line rejected" << std::endl;
}
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:turboc3bgi");
CohenSutherLandAlgo c;
c.getCoordinates();
c.getClippingRectangle();
c.cohenSutherland();
getch();
closegraph();
}
5. Output:
a) Output for display 4-bit region code for end points of a line
b) Output for clip a line intersecting at one point with given window
c) Output for clip a line intersecting at Two or more points with given window
6. Learning outcomes (What I have learnt):
1. I have gathered detail knowledge about how to display 4-bit region code for end
points of a line and check whether line is completely on the screen or off the screen
2. I have gathered detail knowledge about how to clip a line intersecting at one point
with given window using Cohen Sutherland Line Clipping algorithm.
3. I have gathered detail knowledge about how to clip a line intersecting at Two or
more points with given window using Cohen Sutherland Line Clipping algorithm
4. I have learn how to display 4-bit region code for end points of a line and check
whether line is completely on the screen or off the screen
5. I have learn how to clip a line intersecting at one point and two or more point with
given window using Cohen Sutherland Line Clipping algorithm.
6. I get to know about proper logic & algorithm in computation of clip a line
intersecting at one point andTwo or more points with given window using Cohen
Sutherland Line Clipping algorithm
7. Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.

More Related Content

Similar to 19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf

2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
MdAlAmin187
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
Anwar Ul Haq
 
Primitives
PrimitivesPrimitives
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
Lcdf4 chap 03_p2
Lcdf4 chap 03_p2Lcdf4 chap 03_p2
Lcdf4 chap 03_p2
ozgur_can
 
Study on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan GraphicsStudy on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan Graphics
Chandrakant Divate
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
Harshana Madusanka Jayamaha
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
Akira Maruoka
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
Tony Kurishingal
 
openMP loop parallelization
openMP loop parallelizationopenMP loop parallelization
openMP loop parallelization
Albert DeFusco
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
bolovv
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
C++ Homework Help
 
I am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdfI am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdf
thangarajarivukadal
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
ssuserd6b1fd
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
Arun Umrao
 
Clipping
ClippingClipping
Clipping
Udayan Gupta
 

Similar to 19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf (20)

2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
Primitives
PrimitivesPrimitives
Primitives
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Lcdf4 chap 03_p2
Lcdf4 chap 03_p2Lcdf4 chap 03_p2
Lcdf4 chap 03_p2
 
Study on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan GraphicsStudy on Fundamentals of Raster Scan Graphics
Study on Fundamentals of Raster Scan Graphics
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
openMP loop parallelization
openMP loop parallelizationopenMP loop parallelization
openMP loop parallelization
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
I am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdfI am working on java programming that converts zipcode to barcode an.pdf
I am working on java programming that converts zipcode to barcode an.pdf
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
Clipping
ClippingClipping
Clipping
 

Recently uploaded

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 

Recently uploaded (20)

KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 

19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf

  • 1. Experiment no. – 3.1 Student Name: Krishna Kumar UID: 19BCS2605 Branch: CSE - 11 Section/Group : ‘C’ Semester: 5th Date of Performance: 21 Oct 2021 Subject Name: Computer Graphics Lab Subject Code: CSP - 305 1. Aim/Overview of the practical: a) To display 4-bit region code for end points of a line and check whether line is completely on the screen or off the screen b) To clip a line intersecting at one point with given window using Cohen Sutherland Line Clipping algorithm. c) To clip a line intersecting at Two or more points with given window using Cohen Sutherland Line Clipping algorithm 2. Task to be done: a) To display 4-bit region code for end points of a line b) To clip a line intersecting at one point with given window c) To clip a line intersecting at Two or more points with given window 3. Algorithm : a) algorithms for display 4-bit region code for end points of a line Step 1: Start Step 1.1: taking two point, starting point and end point of line for user Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co- ordinate of rectangle for user Step 1. 4: Assign a region code for two endpoints of given line Step 2 : If both endpoints have a region code 0000 then given line is completely inside and we will keep this line
  • 2. Step 3 : If step 2 fails, perform the logical AND operation for both region codes. Step 3.1 : If the result is not 0000, then given line is completely outside. Step 3.2 : Else line is partially inside. Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle. Step 3.2.b : Find the intersection point of the rectangular boundary (based on region code). Step 3.2.c : Replace endpoint with the intersection point and update the region code. Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or rejected. Step 4 : Repeat step 1 for all lines Step 5: using while for taking point of line again and again form user. Step 6: Displaying window, line and line in side window at a green colour at green colour Step 7: End b) algorithms for clip a line intersecting at one point with given window Step 1: Start Step 1.1: taking two point, starting point and end point of line for user Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co- ordinate of rectangle for user Step 1.3 : Assign a region code for two endpoints of given line Step 2 : If both endpoints have a region code 0000 then given line is completely inside and we will keep this line Step 3 : If step 2 fails, perform the logical AND operation for both region codes. Step 3.1 : If the result is not 0000, then given line is completely outside. Step 3.2 : Else line is partially inside. Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle. Step 3.2.b : Find the intersection point of the rectangular boundary (based on region code). Step 3.2.c : Replace endpoint with the intersection point and update the region code. Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or rejected.
  • 3. Step 4 : Repeat step 1 for all lines Step 5: Displaying window and line before line clipping and after line clipping at green colour Step 6: End c) algorithms for clip a line intersecting at Two or more points with given window Step 1: Start Step 1.1: taking two point, starting point and end point of line for user Step 1.2: taking two co-ordinate of rectangle, starting co-ordinate and end co- ordinate of rectangle for user Step 1.3 : Assign a region code for two endpoints of given line Step 2 : If both endpoints have a region code 0000 then given line is completely inside and we will keep this line Step 3 : If step 2 fails, perform the logical AND operation for both region codes. Step 3.1 : If the result is not 0000, then given line is completely outside. Step 3.2 : Else line is partially inside. Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle. Step 3.2.b : Find the intersection point of the rectangular boundary (based on region code). Step 3.2.c : Replace endpoint with the intersection point and update the region code. Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or rejected. Step 4 : Repeat step 1 for all lines Step 5: Displaying window and line before line clipping and after line clipping Step 6: End 4. Programming Code: a) Code for display 4-bit region code for end points of a line #include<iostream> #include<graphics.h> #include<math.h>
  • 4. #include<conio.h> using namespace std; class CohenSutherLandAlgo { private: double x1,y1,x2,y2; double x_max,y_max,x_min,y_min; const int INSIDE = 0; const int LEFT = 1; const int RIGHT = 2; const int BOTTOM = 4; const int TOP = 8; public: CohenSutherLandAlgo() { x1 = 0.0; x2 = 0.0; y1 = 0.0; y2 = 0.0; } void getCoordinates(); void getClippingRectangle(); int generateCode(double x, double y); void cohenSutherland(); }; void CohenSutherLandAlgo::getCoordinates() { std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : "; std::cin >> x1>>y1; std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :"; std::cin >> x2>>y2; std::cout<<endl; setcolor(WHITE); line(x1,y1,x2,y2); } void CohenSutherLandAlgo::getClippingRectangle() { std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl; std::cout << "Enter the X_MAX and Enter the Y_MAX : "; std::cin >> x_max>>y_max; std::cout << "Enter the X_MIN and Enter the Y_MIN : ";
  • 5. std::cin >> x_min>>y_min; rectangle(x_min,y_min,x_max,y_max); } int CohenSutherLandAlgo::generateCode(double x, double y) { int code = INSIDE; if (x < x_min) code |= LEFT; else if (x > x_max) code |= RIGHT; if (y < y_min) code |= BOTTOM; else if (y > y_max) code |= TOP; return code; } void CohenSutherLandAlgo::cohenSutherland() { int code1 = generateCode(x1, y1); int code2 = generateCode(x2, y2); bool accept = false; while (true) { if ((code1 == 0) && (code2 == 0)) { accept = true; break; } else if (code1 & code2) { break; } else { int code_out; double x, y; if (code1 != 0) code_out = code1; else code_out = code2; if (code_out & TOP)
  • 6. { x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1); y = y_max; } else if (code_out & BOTTOM) { x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1); y = y_min; } else if (code_out & RIGHT) { y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1); x = x_max; } else if (code_out & LEFT) { y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1); x = x_min; } if (code_out == code1) { x1 = x; y1 = y; code1 = generateCode(x1, y1); } else { x2 = x; y2 = y; code2 = generateCode(x2, y2); } } } if (accept) { std::cout<<endl; std::cout <<"Line accepted from " <<"("<< x1 << ", " << y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" << std::endl; setcolor(GREEN); line(x1,y1,x2,y2); }
  • 7. else std::cout << "Line rejected" << std::endl; } int main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:turboc3bgi"); int x; outtextxy(5,5,"White color that part of line segment is not accept "); setcolor(GREEN); outtextxy(5,20,"Green color that part of line segment is accept "); setcolor(WHITE); CohenSutherLandAlgo c; c.getClippingRectangle(); do{ c.getCoordinates(); c.cohenSutherland(); std::cout<<endl; cout<<"Please press 1 (one) for continue :"; cin>>x; } while(x==1); getch(); closegraph(); } b) Code for clip a line intersecting at one point with given window #include<iostream> #include<graphics.h> #include<math.h> #include<conio.h> using namespace std; class CohenSutherLandAlgo { private:
  • 8. double x1,y1,x2,y2; double x_max,y_max,x_min,y_min; const int INSIDE = 0; const int LEFT = 1; const int RIGHT = 2; const int BOTTOM = 4; const int TOP = 8; public: CohenSutherLandAlgo() { x1 = 0.0; x2 = 0.0; y1 = 0.0; y2 = 0.0; } void getCoordinates(); void getClippingRectangle(); int generateCode(double x, double y); void cohenSutherland(); }; void CohenSutherLandAlgo::getCoordinates() { std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : "; std::cin >> x1>>y1; std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :"; std::cin >> x2>>y2; std::cout<<endl; line(x1,y1,x2,y2); } void CohenSutherLandAlgo::getClippingRectangle() { std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl; std::cout << "Enter the X_MAX and Enter the Y_MAX : ";
  • 9. std::cin >> x_max>>y_max; std::cout << "Enter the X_MIN and Enter the Y_MIN : "; std::cin >> x_min>>y_min; rectangle(x_min,y_min,x_max,y_max); outtextxy(x_min,y1-20,"Before line Clipping"); setcolor(GREEN); outtextxy(x_max+50,y1-20,"After line Clipping"); rectangle(x_max+50,y_min,x_max+50+x_max-x_min,y_max); } int CohenSutherLandAlgo::generateCode(double x, double y) { int code = INSIDE; if (x < x_min) code |= LEFT; else if (x > x_max) code |= RIGHT; if (y < y_min) code |= BOTTOM; else if (y > y_max) code |= TOP; return code; } void CohenSutherLandAlgo::cohenSutherland() { int code1 = generateCode(x1, y1); int code2 = generateCode(x2, y2); bool accept = false; while (true) { if ((code1 == 0) && (code2 == 0)) { accept = true; break; } else if (code1 & code2) {
  • 10. break; } else { int code_out; double x, y; if (code1 != 0) code_out = code1; else code_out = code2; if (code_out & TOP) { x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1); y = y_max; } else if (code_out & BOTTOM) { x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1); y = y_min; } else if (code_out & RIGHT) { y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1); x = x_max; } else if (code_out & LEFT) { y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1); x = x_min; } if (code_out == code1) { x1 = x; y1 = y; code1 = generateCode(x1, y1); }
  • 11. else { x2 = x; y2 = y; code2 = generateCode(x2, y2); } } } if (accept) { std::cout<<endl; std::cout <<"Line accepted from " <<"("<< x1 << ", " << y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" << std::endl; setcolor(GREEN); line(x1+x_max-x_min+50,y1,x2+x_max-x_min+50,y2); } else std::cout << "Line rejected" << std::endl; } int main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:turboc3bgi"); CohenSutherLandAlgo c; c.getCoordinates(); c.getClippingRectangle(); c.cohenSutherland(); getch(); closegraph(); } c) Code for clip a line intersecting at Two or more points with given window #include<iostream> #include<graphics.h>
  • 12. #include<math.h> #include<conio.h> using namespace std; class CohenSutherLandAlgo { private: double x1,y1,x2,y2; double x_max,y_max,x_min,y_min; const int INSIDE = 0; const int LEFT = 1; const int RIGHT = 2; const int BOTTOM = 4; const int TOP = 8; public: CohenSutherLandAlgo() { x1 = 0.0; x2 = 0.0; y1 = 0.0; y2 = 0.0; } void getCoordinates(); void getClippingRectangle(); int generateCode(double x, double y); void cohenSutherland(); }; void CohenSutherLandAlgo::getCoordinates() { std::cout << "Enter Co-ordinates of P1(X1,Y1) of Line Segment : "; std::cin >> x1>>y1; std::cout << "Enter Co-ordinates of P2(X2,Y2) of Line Segment :"; std::cin >> x2>>y2; std::cout<<endl; line(x1,y1,x2,y2);
  • 13. } void CohenSutherLandAlgo::getClippingRectangle() { std::cout << "Enter the Co-ordinates of Interested Rectangle."<<endl; std::cout << "Enter the X_MAX and Enter the Y_MAX : "; std::cin >> x_max>>y_max; std::cout << "Enter the X_MIN and Enter the Y_MIN : "; std::cin >> x_min>>y_min; rectangle(x_min,y_min,x_max,y_max); outtextxy(x_min,y1-20,"Before line Clipping"); setcolor(GREEN); outtextxy(x_max+50,y1-20,"After line Clipping"); rectangle(x_max+50,y_min,x_max+50+x_max-x_min,y_max); } int CohenSutherLandAlgo::generateCode(double x, double y) { int code = INSIDE; if (x < x_min) code |= LEFT; else if (x > x_max) code |= RIGHT; if (y < y_min) code |= BOTTOM; else if (y > y_max) code |= TOP; return code; } void CohenSutherLandAlgo::cohenSutherland() { int code1 = generateCode(x1, y1); int code2 = generateCode(x2, y2); bool accept = false; while (true)
  • 14. { if ((code1 == 0) && (code2 == 0)) { accept = true; break; } else if (code1 & code2) { break; } else { int code_out; double x, y; if (code1 != 0) code_out = code1; else code_out = code2; if (code_out & TOP) { x = x1 + (x2 - x1) * (y_max - y1) / (y2 - y1); y = y_max; } else if (code_out & BOTTOM) { x = x1 + (x2 - x1) * (y_min - y1) / (y2 - y1); y = y_min; } else if (code_out & RIGHT) { y = y1 + (y2 - y1) * (x_max - x1) / (x2 - x1); x = x_max; } else if (code_out & LEFT) { y = y1 + (y2 - y1) * (x_min - x1) / (x2 - x1);
  • 15. x = x_min; } if (code_out == code1) { x1 = x; y1 = y; code1 = generateCode(x1, y1); } else { x2 = x; y2 = y; code2 = generateCode(x2, y2); } } } if (accept) { std::cout<<endl; std::cout <<"Line accepted from " <<"("<< x1 << ", " << y1 << ")" << " to "<< "(" << x2 << ", " << y2 << ")" << std::endl; setcolor(GREEN); line(x1+x_max-x_min+50,y1,x2+x_max-x_min+50,y2); } else std::cout << "Line rejected" << std::endl; } int main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:turboc3bgi"); CohenSutherLandAlgo c; c.getCoordinates(); c.getClippingRectangle(); c.cohenSutherland();
  • 16. getch(); closegraph(); } 5. Output: a) Output for display 4-bit region code for end points of a line
  • 17. b) Output for clip a line intersecting at one point with given window c) Output for clip a line intersecting at Two or more points with given window
  • 18. 6. Learning outcomes (What I have learnt): 1. I have gathered detail knowledge about how to display 4-bit region code for end points of a line and check whether line is completely on the screen or off the screen 2. I have gathered detail knowledge about how to clip a line intersecting at one point with given window using Cohen Sutherland Line Clipping algorithm. 3. I have gathered detail knowledge about how to clip a line intersecting at Two or more points with given window using Cohen Sutherland Line Clipping algorithm 4. I have learn how to display 4-bit region code for end points of a line and check whether line is completely on the screen or off the screen 5. I have learn how to clip a line intersecting at one point and two or more point with given window using Cohen Sutherland Line Clipping algorithm. 6. I get to know about proper logic & algorithm in computation of clip a line intersecting at one point andTwo or more points with given window using Cohen Sutherland Line Clipping algorithm 7. Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty): Sr. No. Parameters Marks Obtained Maximum Marks 1. 2. 3.