Liang–Barsky algorithm: Difference between revisions

Content deleted Content added
Correction of code: The condition of #5: "If u1 > u2, the line is outside and therefore rejected" was missing. Suggestion: rename 'rn1' to 'u1' and 'rn2' to 'u2'?
fix typo
Line 27:
# If for that <math>i</math>, <math>q_i < 0</math>, then the line is completely outside and can be eliminated.
# When <math>p_i < 0</math>, the line proceeds outside to inside the clip window, and when <math>p_i > 0</math>, the line proceeds inside to outside.
# For nonzero <math>p_kp_i</math>, <math>u = q_i / p_i</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_i < 0</math> (i.e. outside to inside). Take <math>u_1</math> to be the largest among <math>\{0, q_i / p_i\}</math>. For <math>u_2</math>, look at boundaries for which <math>p_i > 0</math> (i.e. inside to outside). Take <math>u_2</math> to be the minimum of <math>\{1, q_i / p_i\}</math>. If <math>u_1 > u_2</math>, the line is outside and therefore rejected.