Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdahl!uunet!cadnetix.COM!cadnetix!erik From: erik@cadnetix.COM (Erik Hyypia) Newsgroups: comp.graphics Subject: Re: 2-D clipping Summary: Cohen/Sutherland Keywords: integer algorithms Message-ID: <4342@cadnetix.COM> Date: 4 Oct 88 15:50:51 GMT References: <5760@utah-cs.UUCP> Sender: news@cadnetix.COM Reply-To: erik@cadnetix.COM (Erik Hyypia) Organization: Cadnetix Corp., Boulder, CO Lines: 20 In article <5760@utah-cs.UUCP> banks@utah-cs.UUCP (Michael J. Banks) writes: >I have need of an algorithm to clip 2-D lines to a rectangle. >All of the references I have been able to find give algorithms >for clipping lines in "world coordinates" and rely on floating >point numbers. > >Can anyone direct me to an efficient integer algorithm for >clipping lines to rectangles? Try the Cohen/Sutherland clipping algorithm, described in Principles of Interactive Computer Graphics, by Newman and Sproull, McGraw Hill. It is efficient at finding intersection points of lines which cross the rectangle boundries, and also at trivially rejecting lines which are wholly outside the clip region (good for operations like zooming in, where the majority of lines are rejected). We successfully implemented an integer version of this algorithm. (Corporate info, can't post it). Good luck, erik@cadnetix.COM (Erik Hyypia)