From - Sat Sep 1 10:48:51 2001 Return-Path: Received: from smtp9.xs4all.nl (smtp9.xs4all.nl [194.109.127.135]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f818mdm47998 for ; Sat, 1 Sep 2001 10:48:39 +0200 (CEST) Received: from server-1.pragma-ade.nl (s340-isdn2632.dial.xs4all.nl [194.109.190.72]) by smtp9.xs4all.nl (8.9.3/8.9.3) with ESMTP id KAA24744; Sat, 1 Sep 2001 10:48:38 +0200 (CEST) Received: from laptop-2.wxs.nl (laptop-1.pragma-ade.nl [200.1.1.26]) by server-1.pragma-ade.nl (8.11.2/8.9.3) with ESMTP id f818gBo03482; Sat, 1 Sep 2001 10:42:11 +0200 Message-Id: <5.1.0.14.1.20010831214836.024bcde8@server-1> X-Sender: hagen@server-1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 31 Aug 2001 21:49:41 +0200 To: Esben Haabendal Soerensen From: Hans Hagen Subject: Re: [metafont] Margin error with pdflatex when using ps files from metapost Cc: pdftex@tug.org, metafont@ens.fr In-Reply-To: <878zg02vvk.fsf@ford.lan.haabendal.dk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 480 Precedence: list At 03:37 PM 8/31/2001 +0200, Esben Haabendal Soerensen wrote: >I attach two small LaTex and MetaPost files to reproduce the error. >Can someone suggest me what I might be doing wrong, or if this is a >real bug, and if so where to look (metapost or pdflatex). it's is unrelated to the converter, but probably due to the way the converter is called in latex; maybe a \leavevmode, or \noindent in front of the includeg... helps Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- From - Mon Sep 17 23:07:40 2001 Return-Path: Received: from smtp1.utaiop.at (mx2.utanet.at [195.70.253.46]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8HL7Un38245 for ; Mon, 17 Sep 2001 23:07:30 +0200 (CEST) Received: from multi2.utaiop.at ([10.70.253.36]) by smtp1.utaiop.at (Netscape Messaging Server 4.15 smtp1 Jun 13 2001 14:38:13) with ESMTP id GJTS0D0D.41E for ; Mon, 17 Sep 2001 23:07:25 +0200 Received: from gmx.at ([212.152.210.175]) by multi2.utaiop.at (Netscape Messaging Server 4.15 multi2 Jun 13 2001 14:38:13) with ESMTP id GJTS0N05.Y11 for ; Mon, 17 Sep 2001 23:07:35 +0200 Message-Id: <3BA665A2.21CD4C2@gmx.at> Date: Mon, 17 Sep 2001 23:05:38 +0200 From: Roland Smiderkal X-Mailer: Mozilla 4.7 [de] (Win98; I) X-Accept-Language: de Mime-Version: 1.0 To: metafont@ens.fr Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 481 Precedence: list Subject: [metafont] How to create parallel pathes I'm looking for a macro that creates a parallel path to a given path. I've already written something like this: > def parpath(expr basepath, dist, f) = > begingroup > > save i, p, d, resultpath; > pair p, d; > path resultpath; > > for i := 0 step f until length basepath: > p := point i of basepath; > d := direction i of basepath; > p := p+(dist, 0) rotated (angle(d)+90); > > resultpath := if i>0: resultpath.. fi p{d}; > endfor > > resultpath > > endgroup > enddef; This is not an exact solution, but good enough for my purposes. The problem is, that this only works for a path with smooth edges. Before writing a new macro that copes with sharp edges, too, I'd like to ask if there is already such a macro. Thanks in advance Roland Smiderkal From - Tue Sep 18 10:41:13 2001 Return-Path: Received: from smtp8.xs4all.nl (smtp8.xs4all.nl [194.109.127.134]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8I8exn79902 for ; Tue, 18 Sep 2001 10:41:00 +0200 (CEST) Received: from server-1.pragma-ade.nl (s340-isdn1884.dial.xs4all.nl [194.109.187.92]) by smtp8.xs4all.nl (8.9.3/8.9.3) with ESMTP id KAA00341; Tue, 18 Sep 2001 10:40:53 +0200 (CEST) Received: from laptop-2.wxs.nl (laptop-1.pragma-ade.nl [200.1.1.26]) by server-1.pragma-ade.nl (8.11.2/8.9.3) with ESMTP id f8I8aUq03374; Tue, 18 Sep 2001 10:36:30 +0200 Message-Id: <5.1.0.14.1.20010918093500.0231bc08@server-1> X-Sender: hagen@server-1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 18 Sep 2001 10:31:31 +0200 To: Roland Smiderkal From: Hans Hagen Subject: Re: [metafont] How to create parallel pathes Cc: metafont@ens.fr In-Reply-To: <3BA665A2.21CD4C2@gmx.at> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 482 Precedence: list At 11:05 PM 9/17/2001 +0200, Roland Smiderkal wrote: >I'm looking for a macro that creates a parallel path to a given path. >I've already written something like this: > > > def parpath(expr basepath, dist, f) = > > begingroup > > > > save i, p, d, resultpath; > > pair p, d; > > path resultpath; > > > > for i := 0 step f until length basepath: > > p := point i of basepath; > > d := direction i of basepath; > > p := p+(dist, 0) rotated (angle(d)+90); > > > > resultpath := if i>0: resultpath.. fi p{d}; > > endfor > > > > resultpath > > > > endgroup > > enddef; > >This is not an exact solution, but good enough for my purposes. The >problem is, that this only works for a path with smooth edges. Before >writing a new macro that copes with sharp edges, too, I'd like to ask if >there is already such a macro. How about: primarydef p parallel s = begingroup ; save q, b ; path q ; numeric b ; b := xpart (lrcorner p - llcorner p) ; q := p if b>0 : scaled ((b+2s)/b) fi ; (q shifted (center p-center q)) endgroup enddef ; beginfig(1) ; pickup pencircle scaled 1mm ; path p ; p := unitsquare scaled 10cm rotated 30 shifted (3cm,3cm) ; draw p ; draw p parallel 3cm ; endfig ; Even more interesting: input mp-tool ; % part of metafun / context primarydef p parallel s = begingroup ; save q, w, h ; path q ; numeric w, h ; w := bbwidth(p) ; h := bbheight(p) ; q := p if (w>0) and (h>0) : xyscaled ((w+2*xpart paired(s))/w,(h+2*ypart paired(s))/h) fi ; (q shifted (center p-center q)) endgroup enddef ; beginfig(2) ; pickup pencircle scaled 1mm ; path p ; p := fullcircle scaled 10cm shifted (3cm,3cm) randomized 1cm ; draw p ; draw p parallel 3cm ; draw p parallel (2cm,3cm) ; endfig ; end. I will move this alternative into mp-tool.mp Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- From - Tue Sep 18 11:51:47 2001 Return-Path: Received: from linux.bop.com.pl (pg85.gdansk.sdi.tpnet.pl [213.77.190.85]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8I9pWn88316 for ; Tue, 18 Sep 2001 11:51:32 +0200 (CEST) Received: from localhost (bop@localhost) by linux.bop.com.pl (8.9.3/8.9.3) with ESMTP id LAA27270; Tue, 18 Sep 2001 11:50:47 +0200 X-Authentication-Warning: linux.bop.com.pl: bop owned process doing -bs Date: Tue, 18 Sep 2001 11:50:47 +0200 (CEST) From: Boguslaw Jackowski X-Sender: bop@linux.bop.com.pl To: Hans Hagen Cc: The Discussion List of METAFONT/METAPOST , Roland Smiderkal Subject: Re: [metafont] How to create parallel pathes Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 483 Precedence: list Hi, [RS=Roland Smiderkal, HH=Hans Hagen] RS>I'm looking for a macro that creates a parallel path to a given path. RS>I've already written something like this: RS[...] RS> This is not an exact solution, but good enough for my purposes. The RS> problem is, that this only works for a path with smooth edges. Before RS> writing a new macro that copes with sharp edges, too, I'd like to ask if RS> there is already such a macro. As far as I know, the notion of ``being parallel'' is defined only for straight lines ;-) The problem of drawing a ``parallel'' path is, in general, vexingly hard. I'd define it as the problem of finding an envelope of a circular-pen-stroked path. Well, not exactly, the problem of sharp corners has to be considered separately... As far as straight lines are considered, the problem can somehow be solved (although troubles may emerge in the case of abruptly turning or nearly colinear segments). What to do with curvilinear paths---it is an open question (the envelope of B\'ezier segment is not a B\'ezier segment!). During the conference in Kerkrade we will present our package for creating Type 1 fonts using METAPOST (plus AWK and t1utils). A part of the package is the extension of plain.mp, plain_ex.mp (actually it is a lone-standing set of macros). It contains, among others, macros that emulate expanding stroke, i.e., finding an envelope of a pen-stroked path---the code is fairly complex. HH> How about: HH> primarydef p parallel s = HH> begingroup ; save q, b ; path q ; numeric b ; HH> b := xpart (lrcorner p - llcorner p) ; HH> q := p if b>0 : scaled ((b+2s)/b) fi ; HH> (q shifted (center p-center q)) HH> endgroup HH> enddef ; HH> HH> beginfig(1) ; HH> pickup pencircle scaled 1mm ; HH> path p ; p := unitsquare scaled 10cm rotated 30 shifted (3cm,3cm) ; HH> draw p ; HH> draw p parallel 3cm ; HH> endfig ; Very nice, but at which point the distance is 3cm? To see the problem draw, e.g.: beginfig(100) ; pickup pencircle scaled 1mm ; path p ; p := unitsquare scaled 10cm rotated 30 shifted (3cm,3cm) ; draw p ; draw p parallel 3cm ; draw fullcircle scaled 6cm shifted point .5 of p withcolor red; draw fullcircle scaled 6cm shifted point 1 of p withcolor red; endfig ; Perhaps a name ``enlarge'' for your macro would be more adequate? Cheers, Jacko =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Bogus\l{}aw Jackowski: B.Jackowski@GUST.ORG.PL ---------------------------------------------------------------- Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- From - Tue Sep 18 14:12:07 2001 Return-Path: Received: from smtp7.xs4all.nl (smtp7.xs4all.nl [194.109.127.133]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8ICBvn03991 for ; Tue, 18 Sep 2001 14:11:57 +0200 (CEST) Received: from server-1.pragma-ade.nl (s340-isdn1819.dial.xs4all.nl [194.109.187.27]) by smtp7.xs4all.nl (8.9.3/8.9.3) with ESMTP id OAA19401; Tue, 18 Sep 2001 14:11:46 +0200 (CEST) Received: from laptop-2.wxs.nl (laptop-1.pragma-ade.nl [200.1.1.26]) by server-1.pragma-ade.nl (8.11.2/8.9.3) with ESMTP id f8IC1Aq04408; Tue, 18 Sep 2001 14:01:10 +0200 Message-Id: <5.1.0.14.1.20010918131910.0233d640@server-1> X-Sender: hagen@server-1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 18 Sep 2001 13:22:02 +0200 To: Boguslaw Jackowski From: Hans Hagen Subject: Re: [metafont] How to create parallel pathes Cc: The Discussion List of METAFONT/METAPOST , Roland Smiderkal In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 484 Precedence: list At 11:50 AM 9/18/2001 +0200, Boguslaw Jackowski wrote: >The problem of drawing a ``parallel'' path is, in general, vexingly hard. >I'd define it as the problem of finding an envelope of a circular-pen-stroked >path. Well, not exactly, the problem of sharp corners has to be considered >separately... What exactly is the transformation needed or the corner? Since we can walk over a path and manipulate its control points ... [i'm not a math guru like you so for me it comes down to trial and error -)] Or better: what is the intended usage? Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- From - Tue Sep 18 15:37:03 2001 Return-Path: Received: from linux.bop.com.pl (pg85.gdansk.sdi.tpnet.pl [213.77.190.85]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8IDZen13932 for ; Tue, 18 Sep 2001 15:36:42 +0200 (CEST) Received: from localhost (bop@localhost) by linux.bop.com.pl (8.9.3/8.9.3) with ESMTP id PAA27693; Tue, 18 Sep 2001 15:33:42 +0200 X-Authentication-Warning: linux.bop.com.pl: bop owned process doing -bs Date: Tue, 18 Sep 2001 15:33:42 +0200 (CEST) From: Boguslaw Jackowski X-Sender: bop@linux.bop.com.pl To: Hans Hagen Cc: The Discussion List of METAFONT/METAPOST , Roland Smiderkal Subject: Re: [metafont] How to create parallel pathes Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 485 Precedence: list Hi again, [BJ=Bogus\l{}aw Jackowski, HH=Hans Hagen] BJ> The problem of drawing a ``parallel'' path is, in general, vexingly BJ> hard. I'd define it as the problem of finding an envelope of BJ> a circular-pen-stroked path. Well, not exactly, the problem of BJ> sharp corners has to be considered separately... HH> What exactly is the transformation needed or the corner? Since HH> we can walk over a path and manipulate its control points Not accidentally, PostScript offers three values for the `setlinejoin' operator: 0 -- miter join 1 -- round join (this corresponds exactly to moving a circular pen along a path) 2 -- bevel join I'd propose the fourth one (actually, we've implemented it in our plain_ex.mp), namely, an extrapolated join. More precisely: For each B\'ezier segment, let's find its ``envelope'' being the edge of a circular pen _without ends_. As a result, one obtains two B\'ezier segments (edges); such edges for consecutive segments of a path (on a given side of a path) either intersect, which is a trivial case (well, not really, trivial is the case when they intersect only once), or do not intersect. In the latter case, we have to decide how to prolongate segments to make them meet. The solution offered by PostScript is clever and fairly general but sometimes insufficient -- there are cases when the extrapolation (i.e., finding a superpath, as opposed to subpath, of a given B\'ezier segment) of the neighbouring edges gives much better results. Such an operation, however, may lead to unexpected results... There remains a problem of ends for non-cyclic paths, but I'd better not dig too deeply into details -- maybe in Kerkrade we'll find a while to talk about? HH> Or better: what is the intended usage? Good question. Cheers -- Jacko =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Bogus\l{}aw Jackowski: B.Jackowski@GUST.ORG.PL ---------------------------------------------------------------- Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- From - Tue Sep 18 17:02:09 2001 Return-Path: Received: from smtp8.xs4all.nl (smtp8.xs4all.nl [194.109.127.134]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8IF1wn22214 for ; Tue, 18 Sep 2001 17:02:00 +0200 (CEST) Received: from server-1.pragma-ade.nl (s340-isdn2410.dial.xs4all.nl [194.109.189.106]) by smtp8.xs4all.nl (8.9.3/8.9.3) with ESMTP id QAA02187; Tue, 18 Sep 2001 16:11:13 +0200 (CEST) Received: from laptop-2.wxs.nl (laptop-1.pragma-ade.nl [200.1.1.26]) by server-1.pragma-ade.nl (8.11.2/8.9.3) with ESMTP id f8IDkfq04890; Tue, 18 Sep 2001 15:46:41 +0200 Message-Id: <5.1.0.14.1.20010918154017.02333e10@server-1> X-Sender: hagen@server-1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 18 Sep 2001 15:41:30 +0200 To: Boguslaw Jackowski From: Hans Hagen Subject: Re: [metafont] How to create parallel pathes Cc: The Discussion List of METAFONT/METAPOST , Roland Smiderkal In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 486 Precedence: list At 03:33 PM 9/18/2001 +0200, Boguslaw Jackowski wrote: >There remains a problem of ends for non-cyclic paths, but I'd better not >dig too deeply into details -- maybe in Kerkrade we'll find a while to talk >about? Ok, given earlier experiencec with tex conferences, we have some 20 hours in a day there so we should manage to discuss it, Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- From - Wed Sep 19 00:28:35 2001 Return-Path: Received: from smtp1.utaiop.at (mx2.utanet.at [195.70.253.46]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8IMSSn62470 for ; Wed, 19 Sep 2001 00:28:28 +0200 (CEST) Received: from multi2.utaiop.at ([10.70.253.36]) by smtp1.utaiop.at (Netscape Messaging Server 4.15 smtp1 Jun 13 2001 14:38:13) with ESMTP id GJVQFE08.01N for ; Wed, 19 Sep 2001 00:28:26 +0200 Received: from gmx.at ([212.152.217.141]) by multi2.utaiop.at (Netscape Messaging Server 4.15 multi2 Jun 13 2001 14:38:13) with ESMTP id GJVQFQ01.O1H for ; Wed, 19 Sep 2001 00:28:38 +0200 Message-Id: <3BA7CA75.62BFA95F@gmx.at> Date: Wed, 19 Sep 2001 00:28:05 +0200 From: Roland Smiderkal X-Mailer: Mozilla 4.7 [de] (Win98; I) X-Accept-Language: de Mime-Version: 1.0 To: metafont@ens.fr Subject: Re: [metafont] How to create parallel pathes References: <5.1.0.14.1.20010918131910.0233d640@server-1> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 487 Precedence: list Hans Hagen schrieb: > What exactly is the transformation needed or the corner? Since we can walk > over a path and manipulate its control points ... [i'm not a math guru like > you so for me it comes down to trial and error -)] > > Or better: what is the intended usage? O.k. I should have mentioned it. If I have a path like (0cm,0cm)--(1cm,0cm)--(2cm,1cm)--(3cm,1cm) the belonging "parallel" path (in a distance of 1 cm) would be (calculated manually) (0cm,1cm)--(0.586cm,1cm)--(1.586cm,2cm)--(3cm,2cm) The pathes in question are not much more complicated than in this example (except that I want to mix straight and curved lines), so the macros would not have to cope with the problems which Boguslaw Jackowski mentioned. As I see, there is most propably no ready-to-use solution. But maybe you could give me a hint, how to determine wether a corner is sharp or smooth? One idea is to split a path into subpathes and compare the direction at the end of one subpath with the direction at the beginning of the next subpath: path p, a, b; pair da, db; p := (0cm,0cm)--(1cm,1cm)--(2cm,0cm); a := subpath(0,1) of p; b := subpath(1,2) of p; da := direction 1 of a; db := direction 0 of b; if da = db: % smooth corner else: % sharp corner fi; Is there a better method? Roland Smiderkal From - Wed Sep 19 09:48:47 2001 Return-Path: Received: from linux.bop.com.pl (pg85.gdansk.sdi.tpnet.pl [213.77.190.85]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8J7mVn97057 for ; Wed, 19 Sep 2001 09:48:32 +0200 (CEST) Received: from localhost (bop@localhost) by linux.bop.com.pl (8.9.3/8.9.3) with ESMTP id JAA28575 for ; Wed, 19 Sep 2001 09:48:32 +0200 X-Authentication-Warning: linux.bop.com.pl: bop owned process doing -bs Date: Wed, 19 Sep 2001 09:48:31 +0200 (CEST) From: Boguslaw Jackowski X-Sender: bop@linux.bop.com.pl To: The Discussion List of METAFONT/METAPOST Subject: Re: [metafont] How to create parallel pathes Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 488 Precedence: list Roland Smiderkal: > path p, a, b; > pair da, db; > p := (0cm,0cm)--(1cm,1cm)--(2cm,0cm); > a := subpath(0,1) of p; > b := subpath(1,2) of p; > da := direction 1 of a; > db := direction 0 of b; > > if da = db: > % smooth corner > else: > % sharp corner > fi; > Is there a better method? The macro direction is defined as follows: vardef direction expr t of p = postcontrol t of p - precontrol t of p enddef; Therefore, the INEQUALITY in your test DOES NOT GUARANTEE the sharpness of the path at the node (in the case of colinear controls of different length)! Try, for example: p:=(0cm,0cm)--(1cm,1cm).. tension 2 .. (2cm,2cm); You should rather use: da := unitvector(direction 1 of a); db := unitvector(direction 0 of b); but then rounding errors enter the scene... I use the following macro which computes the angle between two vectors: vardef turn_ang(expr za,zb) = % The idea of computing the turn angle is based on the following observation: % |z reflectedabout (origin,right)=1/z| for a complex number |z| such that % |abs(z)=1|; recall also that multiplication of complex numbers % (|zscaled| operation) implies addition of their angle arguments. if (abs(za)>=1/1000) and (abs(zb)>=1/1000): % |eps| may be not enough angle(unitvector(za) zscaled (unitvector(zb) reflectedabout (origin,right))) else: whatever fi enddef; Now, you can check the turning angle between ``control'' vectors at a given point using the simple construction vardef is_sharp expr t of p = abs turn_ang( (point t of p)-(precontrol t of p), (postcontrol t of p)-(point t of p)) > 1 % is a one-degree turn a sharp one? enddef; for example: if is_sharp 1 of p: message "is sharp" fi; The weak point of this approach (but I cannot see another approach that would circumvent the problem) is the problem of control nodes coinciding with path nodes, i.e., controls of zero length. In ``normal'' circumstances, however, one has a little chance to encounter such a weird case. All the best -- Jacko =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Bogus\l{}aw Jackowski: B.Jackowski@GUST.ORG.PL ---------------------------------------------------------------- Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- From - Thu Sep 20 21:28:17 2001 Return-Path: Received: from smtp1.utaiop.at (mx2.utanet.at [195.70.253.46]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id f8KJS6n90593 for ; Thu, 20 Sep 2001 21:28:06 +0200 (CEST) Received: from multi2.utaiop.at ([10.70.253.36]) by smtp1.utaiop.at (Netscape Messaging Server 4.15 smtp1 Jun 13 2001 14:38:13) with ESMTP id GJZ7E50C.M13 for ; Thu, 20 Sep 2001 21:27:41 +0200 Received: from gmx.at ([212.152.206.99]) by multi2.utaiop.at (Netscape Messaging Server 4.15 multi2 Jun 13 2001 14:38:13) with ESMTP id GJZ7EH01.Y0Z for ; Thu, 20 Sep 2001 21:27:53 +0200 Message-Id: <3BAA372D.325DCD9@gmx.at> Date: Thu, 20 Sep 2001 20:36:29 +0200 From: Roland Smiderkal X-Mailer: Mozilla 4.7 [de] (Win98; I) X-Accept-Language: de Mime-Version: 1.0 To: metafont@ens.fr Subject: Re: [metafont] How to create parallel pathes References: <200109192325.JAA29064@littleted.maths.uq.edu.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanner: AMaVis 0.2.0-pre6 / Virus Scan X-Loop: metafont@nef.ens.fr X-Sequence: 489 Precedence: list kgs@maths.uq.edu.au schrieb: > > the belonging "parallel" path (in a distance of 1 cm) would be > > (calculated manually) > > > (0cm,1cm)--(0.586cm,1cm)--(1.586cm,2cm)--(3cm,2cm) > ^^^^^^^^^^^ > This point is more than 1 cm from any point on the original path. > Is this what you really mean? Yes, that's what I mean. Sorry, I'm expressing myself not accurately. If I took my own definition seriously I suppose I would have to say something like (0cm,1cm)--(0.586cm,1cm)---(1.2929cm,1.7071cm)..(2cm,2cm)---(3cm,2cm) The purpose of the whole thing is that I want to draw schematic railway track plans. These plans are simplified in that way that turnourts are only represented by straight lines. On the other hand I want to show ordinary curves as curves (confusing, isn't it? this is why I asked a "neutral" question in my first posting). Since a railway line does not consist of "wild" curves many of the problems with "parallel" (better saying aequidistant?) pathes will not occur in my programs. Concerning railway lines one speaks of parallel tracks. I adopted this term for parallel pathes, although there might be no exact geometric definition for this. > What, for example, would you like to have as the "parallel" path to > (0cm,0cm)--(1cm,0cm)--(1cm,1cm)--(3cm,1cm) This is for example a path that will not "happen" to me. But if it happend to me I would say: (0cm,1cm)--(0cm,2cm)--(3cm,2cm) To meet my initial definition I propably would have to say (0cm,1cm){up}..(1cm,2cm)---(3cm,2cm) (assuming that the first path element is really a quarter circle) Regards Roland Smiderkal