tag:blogger.com,1999:blog-8329398836729935187.post16384404236111693..comments2023-12-17T02:41:05.953-08:00Comments on C Programming: C Program for Cohen Sutherland Line Clipping AlgorithmAngadhttp://www.blogger.com/profile/08514166718619263546noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-8329398836729935187.post-7134363578500231762013-03-30T07:23:56.024-07:002013-03-30T07:23:56.024-07:00watz the path that is specified in initgraph(&...watz the path that is specified in initgraph(&gd,&gm,"e:\\tc\\bgi");?????????Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-38462250931138033532012-10-16T08:27:26.500-07:002012-10-16T08:27:26.500-07:00oops its too late :-( sorryoops its too late :-( sorryAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-10214931257707184272012-10-16T08:25:21.102-07:002012-10-16T08:25:21.102-07:00@tondralok
That error comes when u do not specify...@tondralok<br /><br />That error comes when u do not specify the data type of the parameters u passed in the funtion.<br /><br />SO instead of "void lineclip(x0,y0,x1,y1,xwmin,ywmin,xwmax,ywmax)"<br /><br />try <br />void lineclip(int x0,int y0,int x1,int y1,int xwmin,int ywmin,int xwmax,int ywmax)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-24259057243703496302012-05-06T02:58:57.820-07:002012-05-06T02:58:57.820-07:00Hi, I think there is a problem in the code @
if(y...Hi, I think there is a problem in the code @<br /><br />if(y> ywmax)<br />code |=TOP;<br />else if( y xwmax)<br />code |= RIGHT;<br />else if ( x< xwmin)<br />code |= LEFT;<br /><br />what happens if the point-koords are bigger than ywmax, and bigger than xwmax?<br /><br />Because of the "else if" the code wouldn't check for X-statements?<br /><br />So I think, the X-statements should begin with a new "if" and not as a follow of the Y-statements.<br /><br />right?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-56662065359972239232012-04-11T04:00:12.868-07:002012-04-11T04:00:12.868-07:00thank a lot..:) its workingthank a lot..:) its workingNikkihttps://www.blogger.com/profile/07432885552203846845noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-18377448392000288892012-03-14T04:04:01.033-07:002012-03-14T04:04:01.033-07:00bhaakk sale...bhaakk sale...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-63365738474371548912012-02-28T01:43:58.693-08:002012-02-28T01:43:58.693-08:00chuttiya bana rha hey sala !! madarchodchuttiya bana rha hey sala !! madarchodAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-54355261028263156082012-01-31T22:13:15.487-08:002012-01-31T22:13:15.487-08:00thank you very much
Anasthank you very much<br /><b>Anas</b>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-75044792590956128732011-04-01T08:33:30.700-07:002011-04-01T08:33:30.700-07:00It's very good but much complexIt's very good but much complexAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-68631857049015166042011-01-19T18:50:44.278-08:002011-01-19T18:50:44.278-08:00i found an error on the code that shows me on this...i found an error on the code that shows me on this line "void lineclip(x0,y0,x1,y1,xwmin,ywmin,xwmax,ywmax )"<br />and tells "style of function definition is now absolute".<br />pls tell me what can i for it ?tondralokhttps://www.blogger.com/profile/12237661038196391089noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-26329917623078107972010-08-17T09:10:12.457-07:002010-08-17T09:10:12.457-07:00Turbo C has a 16-bit system to display colors, the...Turbo C has a 16-bit system to display colors, these colors have pre defined values which can initialized using the numbers 0-15. Using the statement 'setcolor(3)', I have specified the color parameters. I hope this helps......Angadhttps://www.blogger.com/profile/08514166718619263546noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-85758269689669902602010-07-24T02:04:56.021-07:002010-07-24T02:04:56.021-07:00Great buddy you made my life simpler..Great buddy you made my life simpler..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-84450853147186656982010-04-24T23:45:23.447-07:002010-04-24T23:45:23.447-07:00Where have you given the color parameters in your ...Where have you given the color parameters in your code?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-90552698154538528092010-03-13T08:03:28.902-08:002010-03-13T08:03:28.902-08:00#include
#include
#include
#define left 0x1
#def...#include<br />#include<br />#include<br />#define left 0x1<br />#define right 0x2<br />#define bottom 0x4<br />#define top 0x8<br />int gen_code(int,int);<br />int WinMinX,WinMaxX,WinMinY,WinMaxY,n;<br />void line_check(int,int,int,int);<br />void draw_window();<br />void main()<br />{<br /> int gd=DETECT,gm,i;<br /> int x0,y0,x1,y1;<br /> initgraph(&gd,&gm," ");<br /> printf("\n\tRead value for clipping window Boundry ");<br /> printf("\n\t************************************** ");<br /> printf("\n\n\t Xwmin, Ywmin :");<br /> scanf("%d%d",&WinMinX,&WinMinY);<br /> printf("\n\t Xwmax, Ywmax :");<br /> scanf("%d%d",&WinMaxX,&WinMaxY);<br /> initgraph(&gd,&gm," ");<br /> printf("\n\tEnter Line End points :");<br /> printf("\n\t X0 , Y0 :");<br /> scanf("%d %d",&x0,&y0);<br /> printf("\n\t X1 , Y1 :");<br /> scanf("%d %d",&x1,&y1);<br /> initgraph(&gd,&gm," ");<br /> line(x0,y0,x1,y1);<br /> draw_window();<br /> getch();<br /> initgraph(&gd,&gm," ");<br /> draw_window();<br /> line_check(x0,y0,x1,y1);<br /> getch();<br />}<br /><br />int gen_code(int pnt_x,int pnt_y)<br />{<br /> int i;<br /> int code;<br /> if(pnt_yWinMaxY)<br /> code=bottom;<br /> else if(pnt_xWinMaxX)<br /> code=right;<br /> else<br /> code=0x0;<br /> return code;<br />}<br /><br />void line_check(int x0,int y0,int x1,int y1)<br />{<br /> int code1,code2,outcode;<br /> float x,y;<br /> int done=1,draw;<br /> while(done)<br /> {<br /> draw=0;<br /> code1=gen_code(x0,y0);<br /> code2=gen_code(x1,y1);<br /> if(!(code1 | code2))<br /> {<br /> draw=1; done=0;<br /> }<br /> else if( code1 & code2 )<br /> {<br /> done=0; draw=0;<br /> }<br /> else<br /> {<br /> outcode=code1;<br /> if(code1==0)<br /> outcode=code2;<br /> if(outcode & bottom )<br /> {<br /> x=x0+(x1-x0)*(WinMaxY-y0)/(y1-y0);<br /> y=WinMaxY;<br /> }<br /><br /> else if(outcode & top)<br /> {<br /> x=x0+(x1-x0)*(WinMinX-y0)/(y1-y0);<br /> y=WinMinY;<br /> }<br /> else if(outcode & left )<br /> {<br /> y=y0+(y1-y0)*(WinMinX-x0)/(x1-x0);<br /> x=WinMinX;<br /> }<br /> else<br /> {<br /> y=y0+(y1-y0)*(WinMaxX-x0)/(x1-x0);<br /> x=WinMaxX;<br /> }<br /><br /> if(outcode!=code1)<br /> {<br /> x1=x; y1=y;<br /> }<br /> else<br /> {<br /> x0=x; y0=y;<br /> }<br /> }<br /> }<br /> if(draw)<br /> line(x0,y0,x1,y1);<br /> return;<br /><br /> }<br />void draw_window()<br />{<br /> setcolor(3);<br /> setlinestyle(SOLID_LINE,1,1);<br /> rectangle(WinMinX,WinMinY,WinMaxX,WinMaxY);<br />}Stringsnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-21731306584489557722010-03-13T07:45:04.170-08:002010-03-13T07:45:04.170-08:00this is my version....:)
hey !!!!
Guys check it ...this is my version....:)<br /><br />hey !!!!<br /><br />Guys check it out...Stringsnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-38083374537470830192010-03-13T07:42:58.519-08:002010-03-13T07:42:58.519-08:00#include
#include
#include
#define left 0x1
#def...#include<br />#include<br />#include<br />#define left 0x1<br />#define right 0x2<br />#define bottom 0x4<br />#define top 0x8<br />int gen_code(int,int);<br />int WinMinX,WinMaxX,WinMinY,WinMaxY,n;<br />void line_check(int,int,int,int);<br />void draw_window();<br />void main()<br />{<br /> int gd=DETECT,gm,i;<br /> int x0,y0,x1,y1;<br /> initgraph(&gd,&gm," ");<br /> printf("\n\tRead value for clipping window Boundry ");<br /> printf("\n\t************************************** ");<br /> printf("\n\n\t Xwmin, Ywmin :");<br /> scanf("%d%d",&WinMinX,&WinMinY);<br /> printf("\n\t Xwmax, Ywmax :");<br /> scanf("%d%d",&WinMaxX,&WinMaxY);<br /> initgraph(&gd,&gm," ");<br /> printf("\n\tEnter Line End points :");<br /> printf("\n\t X0 , Y0 :");<br /> scanf("%d %d",&x0,&y0);<br /> printf("\n\t X1 , Y1 :");<br /> scanf("%d %d",&x1,&y1);<br /> initgraph(&gd,&gm," ");<br /> line(x0,y0,x1,y1);<br /> draw_window();<br /> getch();<br /> initgraph(&gd,&gm," ");<br /> draw_window();<br /> line_check(x0,y0,x1,y1);<br /> getch();<br />}<br /><br />int gen_code(int pnt_x,int pnt_y)<br />{<br /> int i;<br /> int code;<br /> if(pnt_yWinMaxY)<br /> code=bottom;<br /> else if(pnt_xWinMaxX)<br /> code=right;<br /> else<br /> code=0x0;<br /> return code;<br />}<br /><br />void line_check(int x0,int y0,int x1,int y1)<br />{<br /> int code1,code2,outcode;<br /> float x,y;<br /> int done=1,draw;<br /> while(done)<br /> {<br /> draw=0;<br /> code1=gen_code(x0,y0);<br /> code2=gen_code(x1,y1);<br /> if(!(code1 | code2))<br /> {<br /> draw=1; done=0;<br /> }<br /> else if( code1 & code2 )<br /> {<br /> done=0; draw=0;<br /> }<br /> else<br /> {<br /> outcode=code1;<br /> if(code1==0)<br /> outcode=code2;<br /> if(outcode & bottom )<br /> {<br /> x=x0+(x1-x0)*(WinMaxY-y0)/(y1-y0);<br /> y=WinMaxY;<br /> }<br /><br /> else if(outcode & top)<br /> {<br /> x=x0+(x1-x0)*(WinMinX-y0)/(y1-y0);<br /> y=WinMinY;<br /> }<br /> else if(outcode & left )<br /> {<br /> y=y0+(y1-y0)*(WinMinX-x0)/(x1-x0);<br /> x=WinMinX;<br /> }<br /> else<br /> {<br /> y=y0+(y1-y0)*(WinMaxX-x0)/(x1-x0);<br /> x=WinMaxX;<br /> }<br /><br /> if(outcode!=code1)<br /> {<br /> x1=x; y1=y;<br /> }<br /> else<br /> {<br /> x0=x; y0=y;<br /> }<br /> }<br /> }<br /> if(draw)<br /> line(x0,y0,x1,y1);<br /> return;<br /><br /> }<br />void draw_window()<br />{<br /> setcolor(3);<br /> setlinestyle(SOLID_LINE,1,1);<br /> rectangle(WinMinX,WinMinY,WinMaxX,WinMaxY);<br />}Stringsnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-82652422151031892242010-03-13T07:41:13.014-08:002010-03-13T07:41:13.014-08:00i spend ma whole day to solve this stuff....
this...i spend ma whole day to solve this stuff....<br /><br />this code really help me a lot...<br /><br />thanx thanx alot.......<br /><br />itz coool and gr8...Stringsnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-59891947578194096182010-03-05T04:48:31.777-08:002010-03-05T04:48:31.777-08:00THANX A LOTTHANX A LOTTRISHAnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-62241409744731675272009-11-05T22:06:31.225-08:002009-11-05T22:06:31.225-08:00u dont hv code for sutherman-hodgeman polygon clip...u dont hv code for sutherman-hodgeman polygon clipping!!!!<br /><br />:(Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-9494638938994107592009-11-05T09:35:17.850-08:002009-11-05T09:35:17.850-08:00thanx for the code......thanx for the code......Ashish Rathorehttps://www.blogger.com/profile/01055014548465009413noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-40092932686043585762009-10-25T00:34:41.409-07:002009-10-25T00:34:41.409-07:00@ SRI,
you are welcome!@ SRI,<br />you are welcome!Angadhttps://www.blogger.com/profile/08514166718619263546noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-68650814941698540682009-10-25T00:33:34.121-07:002009-10-25T00:33:34.121-07:00@ william,
Here is one way circle clipping can be ...@ william,<br />Here is one way circle clipping can be done:<br />To clip a circle against a rectangle, we can first do a<br />trivial accept/reject test by intersecting the circle's extent (a square the size of the circle's diameter ) with the clip rectangle, using the algorithm for polygon clipping. If the circle intersects the rectangle, we divide it into quadrant and do the accept/reject test for each quadrant.This method can be used for eclipse too!Angadhttps://www.blogger.com/profile/08514166718619263546noreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-38400235922623513192009-10-19T10:47:00.964-07:002009-10-19T10:47:00.964-07:00Thank u..Thank u..SRInoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-33297240196449902572009-10-17T09:59:30.562-07:002009-10-17T09:59:30.562-07:00hi.. is there a code for circle clipping with the ...hi.. is there a code for circle clipping with the use of Cohen Sutherland coding?Williamnoreply@blogger.comtag:blogger.com,1999:blog-8329398836729935187.post-12885385197424032412009-06-02T20:57:26.033-07:002009-06-02T20:57:26.033-07:00you're welcome !you're welcome !Angadhttps://www.blogger.com/profile/08514166718619263546noreply@blogger.com