4
$\begingroup$

I'm currently enrolled in an entry level Computer Graphics class, and as I'm studying for my final, I realize I have a question regarding the Cohen-Sutherland line clipping algorithm. I understand the basics of the algorithm, such as how to compute the 4-bit outcodes associated with each region and the test conditions for the endpoints of a line segment, but where I'm struggling is how to determine what the worst case scenario is for the algorithm.

I've had the following question on both my midterm and a homework assignment: "Draw two line segments (one with a positive slope and one with a negative slope) that reflect the worst case scenarios for the corresponding checking order."

The following image file shows what the checking order was for each question, along with my original answers to the questions followed by the correct answers. If anyone could point me in the right direction, it would be greatly appreciated. The only "answer" from my professor I received when asking for an explanation was "the worst case has to do with the checking order", and that answers absolutely nothing for me. enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$

Maybe it helps to draw out the steps of the algorithm. Here is an example for TBLR enter image description here

The red is the worst case: clip top, clip bottom, clip left, clip right. Four steps!

The green is the best case: clip top, clip bottom, done. Two steps.

The blue is a middle case: clip top, clip bottom, clip left, done. Three steps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.