Liang–Barsky algorithm: Difference between revisions

Content deleted Content added
ToastieIL (talk | contribs)
Correct syntax to indicate a group -- parenthesis normally read as an open interval
ToastieIL (talk | contribs)
Correct syntax to indicate a group -- parenthesis normally read as an open interval
Line 25:
# When <math>p_k < 0</math> the line proceeds outside to inside the clip window and when <math>p_k > 0</math>, the line proceeds inside to outside.
# For nonzero <math>p_k</math>, <math>u = \frac{q_k}{p_k}</math> gives the intersection point.
# For each line, calculate <math>u_1</math> and <math>u_2</math>. For <math>u_1</math>, look at boundaries for which <math>p_k < 0</math> (i.e. outside to inside). Take <math>u_1</math> to be the largest among <math>\left\{ 0,\frac{q_k}{p_k} \right\}</math>. For <math>u_2</math>, look at boundaries for which <math>p_k > 0</math> (inside -> out). Take <math>u_2</math> to be the minimum of <math>\left\{ 1, \frac{q_k}{p_k} \right\}</math>. If <math>u_1 > u_2</math>, the line is outside and therefore rejected.
 
==See also==