Answer to Question #124277 in Algorithms for Qasai

Question #124277
Using Cohen-Sutherland algorithm,
Let, the rectangular window A (15, 15), B (80, 15), C (80, 60), D (15, 60). Find the region codes, slope, intersection points to clip the line with P1(10,20) and P2(70, 80).
1
Expert's answer
2020-07-01T16:28:56-0400

The answer depends on the actual details of the algorithm.


Region codes:

LRBT form

P1(10,20) : 1000
P2(70,80) : 0001

P1 != 0, P2 != 0, P1 & P2 = 0

Slope:

m = (P1y - P2y) / (P1x - P2x) = (80 - 20) / (70 - 10) = 1

m != 0, m != inf

Intersections:

P1(10,20), just left bit != 0
L: x = Ax, y = P1y + m(Ax - P1x) = 15 - 10 + 20 = 25, y >= Ay, y <= Cy

P2(70,80), just top bit != 0
T: y = Cy, x = P2x + 1/m (Cy - P2y) = 70 + 60 - 80 = 50, x >= Ax, x <= Cx

Conclusion:

I1(15,25) and I2(50,60) are the clipped points.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS