 Hello friends, myself, Narshan Pandit, assistant professor, department of computer science and engineering from Walton Institute of Technology, Solapur. So today we are going to discuss about midpoint subdivision algorithm. So at the end of this session student will be able to clip the line by using midpoint subdivision algorithm. So here we are going to see first what is difference between so the line cohen line clipping algorithm and midpoint subdivision algorithm after that clipping process in midpoint subdivision algorithm, visibility test and algorithm. So difference between so the line cohen line clipping algorithm and midpoint subdivision algorithm is that the so the line cohen line clipping algorithm requires the floating point calculation in order to find intersection of line segment with the window edges and this calculation can be afforded by using midpoint subdivision algorithm as this algorithm repeatedly subdivides the line segment at its midpoint. So here in this example you can see so this is the window edge and line segment P1, P2 and at every step we divide this line segment into equal halves. So now we get P1, P3 and P3, P2 again this P1, P3 is divided in two equal halves again this P3, P2 is divided in two equal halves. So in this way we are dividing this line segment into two equal halves and we are finding which line segment lie inside this window or outside the window that is nothing but we are applying the visibility test. So like so the line cohen line clipping algorithm the line is tested for visibility that is if line is completely visible then it is drawn, if line is completely invisible then it is rejected that is if line is outside the window then it is rejected and if line is partially visible then it is subdivided into two equal parts. So only on partially visible lines we apply visibility test on each half and again subdivision process is repeated until we get completely visible or invisible line segments. So in this visibility test we are having three conditions, condition 1 if region code of both end point are 0 then line is completely visible, second if region code of both end point are not 0 and logical ending of them is also non-zero then line is completely invisible. So we can reject the line, condition 3 if region code of two end point do not satisfy above two condition then line is partially visible. So let us consider the example and apply region code to it, so this is the window these are the line segment P1, P2, P3, P4, P5, P6. So we divide this window in nine regions and we add region code to this window so that every line segment will get one region code that is end point of every line segment will get one region code. So let us consider line P5, P6, so where P6 is having region code 0010, P5 is having 0110, so end operation this two end point gives 0010, so line is completely invisible and we can reject this line segment P5, P6. So now let us consider the line P3, P4 where both the end points are having region code 0000. So end operation of P3 and P4 gives you 0000, hence we can say that line is completely visible. Next we can consider the line segment P1, P2 where P1 is having region code 0000 and P2 is having 0010. End operation of 0000 and 0010 gives you 0000, hence we can say that line is partially visible. So now we need to get the table in this way that is inside visibility test table where we are having line segment after that starting point and end point of line segment with its region code after that end operation and result that is line is completely visible, invisible or partially visible. Then we need to apply midpoint subdivision algorithm on partially visible line that is line segment P1, P2. So now we are dividing this line segment in two equal halves so that we will get two parts P1, P1 dash and P1 dash, P2. So again we are checking inside visibility test that is P1 is having region code 00, P1 dash is also having 00 and end operation of both the end point gives you 0000, hence we can say that P1, P1 dash is completely visible and it is inside the window. Now P1 dash, P2 we need to check whether this line segment is inside or outside, again we are applying inside visibility test on this line segment, hence we get the line segment is partially visible as P1 dash is having 0000 and P2 is having 0010 and end operation of this gives you 0000. So we can say P1 dash, P2 is partially visible. Now again we need to subdivide this line in two equal halves so that we will get P1 dash, P2 dash and we need to check whether this line segment is inside or outside and we again we perform end operation of P1 dash and P2 dash and it is 0000, hence we can say that line is completely visible. After that we are having line segment P2 dash, P2, P2 dash, P2 we need to check whether this line segment is inside or outside, again visibility test is applied on this line segment. So the end point of P2 dash is 0010 and P2 is also having 0010. So end operation of P2 dash, P2 is 0010 so we can say line is completely invisible. So when line is completely invisible we can reject the line and finally we get the line segment P1, P2 dash. So this line segment is completely visible and it is inside the window and finally we get two line segment P1, P2 dash and P3, P4 which are inside the window and they are completely visible line segments. So this is the result of the clipping by using midpoint subdivision algorithm. So you can pause the video and answer this question. So apply midpoint subdivision algorithm and clip the line segment to the window edge. So here you are having two line segment A1, A2, A3, A4 so you need to clip this line segment to this window edge and you need to generate this inside visibility test table and on this table you need to apply midpoint subdivision algorithm on partially visible lines after that you have to get final result in this way that is A1 dash, A2, A3 dash, A4. So this is the result of the clipping the line segment to the window edge with the help of midpoint subdivision algorithm. So these are the references which I have used to create this video. Thank you.