X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f996b,8ae611e029f9880b X-Google-Attributes: gidf996b,public X-Google-ArrivalTime: 2002-11-14 02:52:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!ra.nrl.navy.mil!dca6-feed2.news.algx.net!jfk3-feed1.news.algx.net!allegiance!newspeer.monmouth.com!uninett.no!uio.no!nntp.uio.no!ifi.uio.no!not-for-mail From: Kjetil Torgrim Homme Newsgroups: alt.ascii-art Subject: Re: ASCII-Art function plotting, advice needed... Date: 14 Nov 2002 11:52:22 +0100 Organization: Dept. of Informatics, Univ. of Oslo, Norway Lines: 80 Message-ID: <1rvg3077a1.fsf@tiu.ifi.uio.no> References: NNTP-Posting-Host: tiu.ifi.uio.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: maud.ifi.uio.no 1037271142 22418 129.240.65.210 (14 Nov 2002 10:52:22 GMT) X-Complaints-To: abuse@ifi.uio.no NNTP-Posting-Date: 14 Nov 2002 10:52:22 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com alt.ascii-art:20657 [Josef 'Jupp' Schugt]: > > > sin(x) for x ranging from -3 to 3 > > ______________________________________________________________ 1 > > | | _-"""""-_ | > > | | _" -_ | > > | | _" - | > > | | - "_ | > > | | - _ |_ > > | | - - | > > | | " - | > > | | " -| > > | |_" - > > |___________________________________________________________|__ 0 > > | _| | > > - _ | | > > |- _ | | > > | - _ | | > > | " _ | | > > | " - | |_ > > | "_ - | | > > | - _" | | > > | "_ _- | | > > |_________"-_____-"___________|_____________________________|__ -1 > > | ' | ' | ' | ' | ' | ' | > > -3 -2 -1 0 1 2 3 > > The idea of achieving a good vertical resolution is mapping > > [0.000, 0.025) to '_', [0.025, 0.075) to '-', [0.075, 0.100) to '"'. > > (left boundary included, right one excluded that is) - note that the > above plot may slightly differ from this mapping; it was done > manually and to err is human. > > Anybody has a better mapping? Forget about '^' or similar characters > that look very different in different fonts - I can't control the > font that is used. The ideal mapping would take into account not only > the value at a given point but also the left and right neighbor > (which is an approximation for the slope). I think it is better to consider each character a box, and to use the intersection points to select the character. that is, at (-2, -1), you have a box which is _really_ covering the area (-2.05, -0.8) (-1.95, -1.0). to plot that point, consider sin(-2.05) == -0.887 (43.5% into the box) and sin(-1.95) == -0.929 (64.5% into the box) +-----+ 0% | | 20% * | 40% | * 60% | | 80% +-----+ 100% in addition to these percentages, the intersection on one side can happen in a box above or below it. let's call these cases just A and B. now you need to map these into characters. A B | B A | B 80 , 20 A ' 0 100 \ 100 0 / 100 100 _ B 100 _ 100 B _ 0 0 " 0 A " A 0 " 50 50 - the above values should _really_ be ranges, of course. Kjetil T.