<p>Taken from <a href="https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm" rel="nofollow noreferrer">Wikipedia's article on Cohen-Sutherland</a>:</p>

<blockquote>
  <p>Both endpoints are in different regions: in case of this nontrivial situation the algorithm finds one of the two points that is outside the viewport region (there will be at least one point outside). The intersection of the outpoint and extended viewport border is then calculated (i.e. with the parametric equation for the line), and this new point replaces the outpoint. The algorithm repeats until a trivial accept or reject occurs.</p>
</blockquote>

<p>So yes, since your new first point is inside the viewport, but your second point is outside, the situation is non-trivial (i.e. no "go render it all" or "go discard it all"), it will repeat with the second point. Afterwards, both points will be inside the viewport, therefore it is a trivial draw and no further action is needed.</p>

CC BY-SA 3.0
2018-03-21T14:54:14.850Z
2018-03-21T14:54:14.850Z
Tare
<p>Specify individually the translation and scaling matrices required to transform a 2D
window of [Xmin=-234, Ymin=156] and [Xmax=66, Ymax=456] to a display viewport
of [Umin=45, Vmin=35] and [Umax=245, Vmax=185].</p>

<p><strong>Ignore the question above since I solved the matrix, the information is just relevant for the question I'm stuck on</strong></p>

<p>I was asked to compute the view-port positions (U1,V1) and (U2,V2) for two points A (-100,300)
and B (30,-40) in a 2D window and determine if these two points are inside the view-port.</p>

<p>Based on the transformation Matrix I found (U1,V1) to be (403/3, 407) and (U2,v2) to be (221, -103). It turns out that both these points are outside our view-port but part of the line between them is inside.</p>

<p>Now I'm confused about this part below:</p>

<p>Apply a 2D clipping method to the line segment between the two points A and B as
given in above.</p>

<p><strong>My Attempt</strong></p>

<p>delta x = 221-(403/3) = 260/3</p>

<p>delta y = -103 - 406 = -510</p>

<p>m = delta y / delta x = -5.88</p>

<p>I started with U1,V1 since it is above our viewport:</p>

<p>Y = 185</p>

<p>X = 403/3 + (185-407)*(delta x/ delta y)</p>

<p>X = 279.48</p>

<p>Point 1 - (172, 185) </p>

<p>Is this correct? Since the point is now within the view-port. Do I then do the same for the second point?</p>

<clipping>
Cohen-Sutherland Clipping
TheRapture87
# Cohen-Sutherland Clipping

(Asked by: username_0 on 2016-05-07)

Specify individually the translation and scaling matrices required to transform a 2D
window of [Xmin=-234, Ymin=156] and [Xmax=66, Ymax=456] to a display viewport
of [Umin=45, Vmin=35] and [Umax=245, Vmax=185].

**Ignore the question above since I solved the matrix, the information is just relevant for the question I'm stuck on**

I was asked to compute the view-port positions (U1,V1) and (U2,V2) for two points A (-100,300)
and B (30,-40) in a 2D window and determine if these two points are inside the view-port.

Based on the transformation Matrix I found (U1,V1) to be (403/3, 407) and (U2,v2) to be (221, -103). It turns out that both these points are outside our view-port but part of the line between them is inside.

Now I'm confused about this part below:

Apply a 2D clipping method to the line segment between the two points A and B as
given in above.

**My Attempt**

delta x = 221-(403/3) = 260/3

delta y = -103 - 406 = -510

m = delta y / delta x = -5.88

I started with U1,V1 since it is above our viewport:

Y = 185

X = 403/3 + (185-407)\*(delta x/ delta y)

X = 279.48

Point 1 - (172, 185)

Is this correct? Since the point is now within the view-port. Do I then do the same for the second point?

**Tags:** clipping


---

## 1 answers

### Answer by username_1 on 2018-03-21. Score: 1

Taken from [Wikipedia's article on Cohen-Sutherland](https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm):

> Both endpoints are in different regions: in case of this nontrivial situation the algorithm finds one of the two points that is outside the viewport region (there will be at least one point outside). The intersection of the outpoint and extended viewport border is then calculated (i.e. with the parametric equation for the line), and this new point replaces the outpoint. The algorithm repeats until a trivial accept or reject occurs.

So yes, since your new first point is inside the viewport, but your second point is outside, the situation is non-trivial (i.e. no "go render it all" or "go discard it all"), it will repeat with the second point. Afterwards, both points will be inside the viewport, therefore it is a trivial draw and no further action is needed.


---

