:<math>y_{\text{min}} \le y_0 + t \Delta y \le y_{\text{max}}\,\!</math>,
which can be expressed as the 4 inequalities
:<math>t p_kp_i \le q_k, \quad ki = 1, 2, 3, 4\,\!</math>,
where
To compute the final line segment:
# A line parallel to a clipping window edge has <math>p_kp_i = 0</math> for that boundary.
# If for that <math>ki</math>, <math>q_kq_i < 0</math>, the line is completely outside and can be eliminated.
# When <math>p_kp_i < 0</math> the line proceeds outside to inside the clip window and when <math>p_kp_i > 0</math>, the line proceeds inside to outside.
# For nonzero <math>p_k</math>, <math>u = \frac{q_kq_i}{p_kp_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_kp_i < 0</math> (i.e. outside to inside). Take <math>u_1</math> to be the largest among <math>\left\{ 0,\frac{q_kq_i}{p_kp_i} \right\}</math>. For <math>t_2</math>, look at boundaries for which <math>p_kp_i > 0</math> (i.e. inside to outside). Take <math>u_2</math> to be the minimum of <math>\left\{ 1, \frac{q_kq_i}{p_kp_i} \right\}</math>. If <math>u_1t_1 > u_2t_2</math>, the line is outside and therefore rejected.
==See also==
Algorithms used for the same purpose:
|