Content deleted Content added
Now it is working for all sides, before it was working only for bottom and left. |
m change source to syntaxhighlight |
||
Line 30:
# 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.
<
// Liang--Barsky line-clipping algorithm
#include<iostream>
Line 147:
closegraph();
}
</syntaxhighlight>
==See also==
|