Question

In: Computer Science

Use Cohen Sutherland algorithm to clip line P1(70,20) and p2(100, 10) against a window lower left...

Use Cohen Sutherland algorithm to clip line P1(70,20) and p2(100, 10) against a window lower left corner(50,10) and upper right hand corner(80,40)

Solutions

Expert Solution

Here the given line is P1(70,20) to P2(100,10)

window lower left corner = (50,10)

window upper right corner = (80,40)

So the window is...

Now we assign 4-bit binary outcode

As point P1 is inside the window so outcode of P1 = (0000) and outcode of P2 = (0010) as P2 is right to window

Doing AND operation on P1 & P2 0 0 0 0 0 0 1 0 -------------- 0 0 0 0 the result of AND operation is zero, so line is partially visible...

slope of line P1P2 is m = (y2 - y1) / (x2 - x1) = (20 - 10) / (100 - 70) = - 1 / 3

We have to find intersection of the line P1P2 with right edge of the window i.e point P2

Let the intersection point be (x , y) and here x=80 here P2(x2 , y2) = P2(100 , 10)

m = (y - y2) / (x - x2)

from above we got m = - 1 / 3

So... - 1 / 3 = (y - 10) / (80 - 100)

- 1 / 3 = (y - 10) / ( - 20 )

y = (20/3) + 10 = 16.66

The intersection point P3 ( 80 , 16.66 )

So after clipping the line P1P2 against window, new line is P1P3 with coordinates P1(70 , 20) and P3(80 , 16.66)

  


Related Solutions

2. Suppose a consumer has an income of $100. P1=10 and p2=10. a. Draw the consumer's...
2. Suppose a consumer has an income of $100. P1=10 and p2=10. a. Draw the consumer's budget constraint b. On the same drawing, add an indifference curve on which the optimal basket lies. Assume the indifference curve is convex as usual c. On the same drawing, add an indifference curve which has a lower utility level than the optimal basket. Make sure to include the intersections of the curve with the budget constraint, and carefully explain why they cannot be...
1.     Suppose a consumer has an income of $100. P1=10 and p2=10. a. Draw the consumer’s...
1.     Suppose a consumer has an income of $100. P1=10 and p2=10. a. Draw the consumer’s budget constraint b. On the same drawing, add an indifference curve on which the optimal basket lies. Assume the indifference curve is convex as usual c. On the same drawing, add an indifference curve which has a lower utility level than the optimal basket. Make sure to include the intersections of the curve with the budget constraint, and carefully explain why they cannot be...
Problem 10-2A Straight-Line: Amortization of bond discount LO P1, P2 Hillside issues $1,900,000 of 5%, 15-year...
Problem 10-2A Straight-Line: Amortization of bond discount LO P1, P2 Hillside issues $1,900,000 of 5%, 15-year bonds dated January 1, 2018, that pay interest semiannually on June 30 and December 31. The bonds are issued at a price of $1,641,812. Required: 1. Prepare the January 1, 2018, journal entry to record the bonds’ issuance. 2(a) For each semiannual period, complete the table below to calculate the cash payment. 2(b) For each semiannual period, complete the table below to calculate the...
You want to protect $100 million in bond investments against rising rates and plan to use 10-year treasury futures.
You want to protect $100 million in bond investments against rising rates and plan to use 10-year treasury futures.Do you go long or short futures?       Current rates are 3%.If rates go up to 4%, what is your gain or loss on the contract?You plan to buy a 10-year corporate bond in one month. Current yields for corporate bonds are 4% when treasury rates are 3%. You want to protect against rates falling.Do you go long or short treasury futures?Treasury rates fall...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT