From: loth AT cow-net DOT com (Burton Radons) Newsgroups: comp.os.msdos.djgpp Subject: Re: how do I draw triangles? Date: Mon, 24 May 1999 06:39:51 GMT Organization: Posted via RemarQ Communities, Inc. Lines: 26 Message-ID: <374bf1b9.89459708@news.cow-net.com> References: <7i8uum$o69$1 AT news8 DOT svr DOT pol DOT co DOT uk> NNTP-Posting-Host: 207.107.185.199 NNTP-Posting-Date: Mon, 24 May 1999 06:37:37 GMT X-Trace: 927527857.771.43 7OKJ3DJHCB9C7CF6BC usenet80.supernews.com X-Complaints-To: newsabuse AT remarQ DOT com X-Newsreader: Forte Agent 1.5/32.452 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Sun, 23 May 1999 14:09:11 +0100, "Justin Blackwell" wrote: >Anyone got any good code on how to draw triangles - not polygons or any >other shapes - just triangles :) > >C++ code is good, but any nice documents would be greatly appreciated. Sort the triangle so that the y increases with each point. Now there are two triangles to draw. The hypotenuse (The side that goes from the highest to the lowest point) is the edge for each triangle. Now take the x ratio of each side (as float). Start the first triangle; add onto x the ratio each y for the hypotenuse and the favoured edge. Swap the sides if necessary and draw the segment; continue up to the middle point. Do the same for the second triangle to the end point. There are many ways to enhance this, but that's the basic algorithm. The PCGPE (Available at x2ftp.oulu.fi) has a file "tut9.txt", which explains a better way, although I think he uses quads instead. tut3 has a lines algorithm that can be applied to triangles. - Burton Radons, loth AT cow-net DOT com Vancouver Island, British Columbia, Canada (main) http://csoft.net/~loth/index.shtml