Clipping a line into some limits...
Ok, i asked something like this a little while ago in the graphics theory forum, but didn''t really got an answer i could use.
I have the start and end cordiantes of a line. ( xa, ya, xb, yb )
I need to clip it inside some limits without the line appears differently inside the limits. I hope you understand. (like clipping the line inside the screen and remove the outside because it isn''t going t be viewed.)
If i also got the limit numbers ( from 0,0 to 640,480 )
can i then with a mathematical formula clip it into theese limits?
In my case i can''t do it while drawing the actual line...
Here is an overview of my problem:
xa = X
ya = Y
xb = Z
yb = W
limitXa = 0
limitYa = 0
limitXb = 640
limitYb = 480
clippedlineXa = ?
clippedlineYa = ?
clippedlineXb = ?
clippedlineYb = ?
Please help...
Request the code at my email , basically its shuterland-cohen algo, it is very long to explain here, but it is based on integer math , no float and it is pretty fast , it is based also on bytecode testing for proper side clipping.
This forum''s FAQ links to an excellent explanation of the Cohen-Sutherland algorithm, which is indeed what you want:
http://www.cs.brown.edu/courses/cs123/lectures/Clipping.pdf
"Your superior intellect is no match for our puny weapons!"
http://www.cs.brown.edu/courses/cs123/lectures/Clipping.pdf
"Your superior intellect is no match for our puny weapons!"
"Your superior intellect is no match for our puny weapons!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement